From: Kevin Wolf <kwolf@redhat.com>
To: Bernhard Kohl <bernhard.kohl@nsn.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] scsi-generic: don't report negative length to the SCSI adapter
Date: Thu, 02 Sep 2010 16:32:20 +0200 [thread overview]
Message-ID: <4C7FB574.7090906@redhat.com> (raw)
In-Reply-To: <1283434052-11866-1-git-send-email-bernhard.kohl@nsn.com>
Am 02.09.2010 15:27, schrieb Bernhard Kohl:
> Some drivers report an incorrect number for 'resid'. I found that for
> MODE_SENSE(6) on an IET iSCSI device. This device reports the
> available mode data length minus actually transferred length.
>
> This is already a known problem:
> http://tldp.org/HOWTO/SCSI-Generic-HOWTO/x356.html
>
> Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
> ---
> hw/scsi-generic.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
> index 9538027..836678c 100644
> --- a/hw/scsi-generic.c
> +++ b/hw/scsi-generic.c
> @@ -169,7 +169,11 @@ static void scsi_read_complete(void * opaque, int ret)
> return;
> }
> len = r->io_header.dxfer_len - r->io_header.resid;
> - DPRINTF("Data ready tag=0x%x len=%d\n", r->req.tag, len);
> + if (len < 0) {
> + len = r->io_header.dxfer_len;
> + }
> + DPRINTF("Data ready tag=0x%x len=%d dxfer_len=%d resid=%d\n",
> + r->req.tag, len, r->io_header.dxfer_len, r->io_header.resid);
>
> r->len = -1;
> r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
Can we add a comment why len can become < 0 and that this is a
workaround for buggy drivers? It's in your commit message, but I prefer
this kind of things to be explained in the code.
Also, are we sure that broken drivers always return negative numbers
when their result is wrong, or can we still get incorrect results?
Kevin
next prev parent reply other threads:[~2010-09-02 14:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 13:27 [Qemu-devel] [PATCH] scsi-generic: don't report negative length to the SCSI adapter Bernhard Kohl
2010-09-02 14:32 ` Kevin Wolf [this message]
2010-09-02 16:17 ` Bernhard Kohl
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=4C7FB574.7090906@redhat.com \
--to=kwolf@redhat.com \
--cc=bernhard.kohl@nsn.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).