[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201005261733.29460.rusty@rustcorp.com.au>
Date: Wed, 26 May 2010 17:33:28 +0930
From: Rusty Russell <rusty@...tcorp.com.au>
To: Christoph Hellwig <hch@....de>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virtio-blk: fix minimum number of S/G elements
On Tue, 25 May 2010 09:47:54 pm Christoph Hellwig wrote:
>
> 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@....de>
Seems reasonable: we might as well ignore it if device is obviously talking
crap.
However, the result is awkward (we assign err then don't use it), and assumes
that sg_elems isn't touched on error (true at the moment).
Prefer this:
Subject: virtio-blk: fix minimum number of S/G elements
Date: Tue, 25 May 2010 14:17:54 +0200
From: Christoph Hellwig <hch@....de>
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@....de>
Signed-off-by: Rusty Russell <rusty@...tcorp.com.au> (tweaked logic)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -298,7 +298,9 @@ static int __devinit virtblk_probe(struc
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. */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists