From: Christoph Hellwig Date: Tue, 25 May 2010 12:17:54 +0000 (+0200) Subject: virtio-blk: fix minimum number of S/G elements X-Git-Tag: v2.6.35-rc2~48^2~2 X-Git-Url: http://bbs.cooldavid.org/git/?a=commitdiff_plain;h=a5b365a652206ca300256974ed9301a7d241a6ed;p=net-next-2.6.git virtio-blk: fix minimum number of S/G elements 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 Signed-off-by: Rusty Russell (tweaked logic) --- diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 83fa09a836c..258bc2ae288 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -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. */