aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-05-25 14:17:54 +0200
committerRusty Russell <rusty@rustcorp.com.au>2010-06-03 22:39:18 +0930
commita5b365a652206ca300256974ed9301a7d241a6ed (patch)
tree1898846dcce5b1815f8e13d7b0b610c83be1da7f /drivers/block
parentaef4b9aaae1decc775778903922bd0075cce7a88 (diff)
downloadkernel_samsung_aries-a5b365a652206ca300256974ed9301a7d241a6ed.zip
kernel_samsung_aries-a5b365a652206ca300256974ed9301a7d241a6ed.tar.gz
kernel_samsung_aries-a5b365a652206ca300256974ed9301a7d241a6ed.tar.bz2
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 <hch@lst.de> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (tweaked logic)
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/virtio_blk.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 83fa09a..258bc2a 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. */