From: Rusty Russell <rusty@rustcorp.com.au>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] virtio-blk: fix minimum number of S/G elements
Date: Wed, 26 May 2010 17:33:28 +0930 [thread overview]
Message-ID: <201005261733.29460.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20100525121754.GA8456@lst.de>
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@lst.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@lst.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@lst.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.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. */
prev parent reply other threads:[~2010-05-26 8:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-25 12:17 [PATCH] virtio-blk: fix minimum number of S/G elements Christoph Hellwig
2010-05-26 8:03 ` Rusty Russell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201005261733.29460.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox