qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v3 2/7] scsi-generic: Handle canceled request in scsi_command_complete
Date: Thu, 25 Sep 2014 10:20:44 +0800	[thread overview]
Message-ID: <1411611649-11171-3-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1411611649-11171-1-git-send-email-famz@redhat.com>

Now that we always called the cb in bdrv_aio_cancel, let's make scsi-generic
callbacks check io_canceled flag similarly to scsi-disk.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/scsi/scsi-generic.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 20587b4..2a73a43 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -93,6 +93,9 @@ static void scsi_command_complete(void *opaque, int ret)
     SCSIGenericReq *r = (SCSIGenericReq *)opaque;
 
     r->req.aiocb = NULL;
+    if (r->req.io_canceled) {
+        goto done;
+    }
     if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
         r->req.sense_len = r->io_header.sb_len_wr;
     }
@@ -133,6 +136,7 @@ static void scsi_command_complete(void *opaque, int ret)
             r, r->req.tag, status);
 
     scsi_req_complete(&r->req, status);
+done:
     if (!r->req.io_canceled) {
         scsi_req_unref(&r->req);
     }
@@ -186,8 +190,7 @@ static void scsi_read_complete(void * opaque, int ret)
     int len;
 
     r->req.aiocb = NULL;
-    if (ret) {
-        DPRINTF("IO error ret %d\n", ret);
+    if (ret || r->req.io_canceled) {
         scsi_command_complete(r, ret);
         return;
     }
@@ -246,8 +249,7 @@ static void scsi_write_complete(void * opaque, int ret)
 
     DPRINTF("scsi_write_complete() ret = %d\n", ret);
     r->req.aiocb = NULL;
-    if (ret) {
-        DPRINTF("IO error\n");
+    if (ret || r->req.io_canceled) {
         scsi_command_complete(r, ret);
         return;
     }
-- 
1.9.3

  parent reply	other threads:[~2014-09-25  2:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25  2:20 [Qemu-devel] [PATCH v3 0/7] virtio-scsi: Asynchronous cancellation Fam Zheng
2014-09-25  2:20 ` [Qemu-devel] [PATCH v3 1/7] scsi: Drop scsi_req_abort Fam Zheng
2014-09-25  2:20 ` Fam Zheng [this message]
2014-09-25  2:20 ` [Qemu-devel] [PATCH v3 3/7] scsi-bus: Unify request unref in scsi_req_cancel Fam Zheng
2014-09-25  2:20 ` [Qemu-devel] [PATCH v3 4/7] scsi: Drop SCSIReqOps.cancel_io Fam Zheng
2014-09-25  2:20 ` [Qemu-devel] [PATCH v3 5/7] scsi: Introduce scsi_req_cancel_complete Fam Zheng
2014-09-25  8:51   ` Paolo Bonzini
2014-09-25  2:20 ` [Qemu-devel] [PATCH v3 6/7] scsi: Introduce scsi_req_cancel_async Fam Zheng
2014-09-25  8:51   ` Paolo Bonzini
2014-09-28  1:44     ` Fam Zheng
2014-09-25  2:20 ` [Qemu-devel] [PATCH v3 7/7] virtio-scsi: Handle TMF request cancellation asynchronously Fam Zheng

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=1411611649-11171-3-git-send-email-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).