From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] scsi: Introduce scsi_req_cancel_async
Date: Thu, 18 Sep 2014 11:17:05 +0200 [thread overview]
Message-ID: <541AA311.4080606@redhat.com> (raw)
In-Reply-To: <1411007799-23199-3-git-send-email-famz@redhat.com>
Il 18/09/2014 04:36, Fam Zheng ha scritto:
> + QTAILQ_FOREACH_SAFE(ref, &req->cancel_deps, next, next) {
> + SCSIRequest *r = ref->req;
> + assert(r->cancel_dep_count);
> + r->cancel_dep_count--;
> + if (!r->cancel_dep_count && req->bus->info->cancel_dep_complete) {
> + req->bus->info->cancel_dep_complete(r);
> + }
> + QTAILQ_REMOVE(&req->cancel_deps, ref, next);
> + scsi_req_unref(r);
> + g_free(ref);
> + }
I think there is one problem here.
scsi_req_cancel_async can actually be synchronous if you're unlucky
(because bdrv_aio_cancel_async can be synchronous too, for example in
the case of a linux-aio AIOCB). So you could end up calling
cancel_dep_complete even if the caller intends to cancel more requests.
I think it's better to track the count in virtio-scsi instead. You can
initialize it similar to bdrv_aio_multiwrite:
/* Run the aio requests. */
mcb->num_requests = num_reqs;
for (i = 0; i < num_reqs; i++) {
bdrv_co_aio_rw_vector(bs, reqs[i].sector, reqs[i].qiov,
reqs[i].nb_sectors, reqs[i].flags,
multiwrite_cb, mcb,
true);
}
return 0;
and decrement the count on every call to the notifier.
This is independent of the choice to make bdrv_aio_cancel_async
semantics stricter. In the case of bdrv_aio_multiwrite, we know that
bdrv_co_aio_rw_vector is never synchronous, but the code is simply nicer
that way. :)
Paolo
next prev parent reply other threads:[~2014-09-18 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 2:36 [Qemu-devel] [PATCH 0/3] virtio-scsi: Asynchronous cancellation Fam Zheng
2014-09-18 2:36 ` [Qemu-devel] [PATCH 1/3] scsi-bus: Unify request unref in scsi_req_cancel Fam Zheng
2014-09-18 8:59 ` Paolo Bonzini
2014-09-18 2:36 ` [Qemu-devel] [PATCH 2/3] scsi: Introduce scsi_req_cancel_async Fam Zheng
2014-09-18 9:17 ` Paolo Bonzini [this message]
2014-09-18 9:18 ` Paolo Bonzini
2014-09-18 2:36 ` [Qemu-devel] [PATCH 3/3] 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=541AA311.4080606@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@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 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.