From: Kevin Wolf <kwolf@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] scsi-generic: Remove bogus double complete
Date: Tue, 05 Apr 2011 16:00:00 +0200 [thread overview]
Message-ID: <4D9B2060.3060000@redhat.com> (raw)
In-Reply-To: <1301980051-20866-1-git-send-email-david@gibson.dropbear.id.au>
Am 05.04.2011 07:07, schrieb David Gibson:
> From: Ben Herrenschmidt <benh@kernel.crashing.org>
>
> scsi-generic scsi_read_complete() should not -both- call the client
> complete callback with SCSI_REASON_DATA -and- call
> scsi_command_complete(). The former will cause the client to queue a
> new read or write request, while the later will free the request data
> structure, thus causing the new read or write request to use a
> freed/stale structure when it completes.
>
> This patch fixes the bug, fixing a crash with scsi-generic & RHEL5.5
> installer.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> hw/scsi-generic.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
> index 9be1cca..c06f5df 100644
> --- a/hw/scsi-generic.c
> +++ b/hw/scsi-generic.c
> @@ -173,8 +173,6 @@ static void scsi_read_complete(void * opaque, int ret)
>
> r->len = -1;
> r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
> - if (len == 0)
> - scsi_command_complete(r, 0);
> }
>
> /* Read more data from scsi device into buffer. */
I have a hard time each time I try to understand this SCSI stuff without
reading a lot of code and specs. What I would have expected is this:
if (len == 0) {
scsi_command_complete(r, 0);
} else {
r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
}
This would fix the problem that both functions are called, but still use
SCSI_REASON_DONE if no data is transferred. This is similar to what
scsi-disk seems to be doing. However, if you can explain to me why your
version is more correct, I'll gladly take it.
Kevin
next prev parent reply other threads:[~2011-04-05 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 5:07 [Qemu-devel] [PATCH] scsi-generic: Remove bogus double complete David Gibson
2011-04-05 14:00 ` Kevin Wolf [this message]
2011-05-03 12:14 ` Paolo Bonzini
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=4D9B2060.3060000@redhat.com \
--to=kwolf@redhat.com \
--cc=david@gibson.dropbear.id.au \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.