Skip to content

Commit

Permalink
virtio-blk: fix minimum number of S/G elements
Browse files Browse the repository at this point in the history
We need at least one S/G element to operate properly, as does the block
layer which increments it to one anyway.  We hit this due to a qemu
bug which advertises a sg_elements of 0 under some circumstances.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (tweaked logic)
  • Loading branch information
Christoph Hellwig authored and Rusty Russell committed Jun 3, 2010
1 parent aef4b9a commit a5b365a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
err = virtio_config_val(vdev, VIRTIO_BLK_F_SEG_MAX,
offsetof(struct virtio_blk_config, seg_max),
&sg_elems);
if (err)

/* We need at least one SG element, whatever they say. */
if (err || !sg_elems)
sg_elems = 1;

/* We need an extra sg elements at head and tail. */
Expand Down

0 comments on commit a5b365a

Please sign in to comment.