From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2HTw-0001tq-98 for qemu-devel@nongnu.org; Thu, 25 Jul 2013 05:05:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2HTv-00029N-2n for qemu-devel@nongnu.org; Thu, 25 Jul 2013 05:05:08 -0400 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]:47625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2HTu-00026v-Ob for qemu-devel@nongnu.org; Thu, 25 Jul 2013 05:05:07 -0400 Received: by mail-pa0-f44.google.com with SMTP id jh10so1747168pab.31 for ; Thu, 25 Jul 2013 02:05:04 -0700 (PDT) Date: Thu, 25 Jul 2013 17:04:53 +0800 From: Liu Yuan Message-ID: <20130725090453.GC2604@ubuntu-precise> References: <1374741125-31859-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1374741125-31859-10-git-send-email-morita.kazutaka@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1374741125-31859-10-git-send-email-morita.kazutaka@lab.ntt.co.jp> Subject: Re: [Qemu-devel] [PATCH v3 09/10] sheepdog: cancel aio requests if possible List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: Kevin Wolf , Paolo Bonzini , sheepdog@lists.wpkg.org, qemu-devel@nongnu.org, Stefan Hajnoczi On Thu, Jul 25, 2013 at 05:32:04PM +0900, MORITA Kazutaka wrote: > This patch tries to cancel aio requests in pending queue and failed > queue. When the sheepdog driver cannot cancel the requests, it waits > for them to be completed. > > Signed-off-by: MORITA Kazutaka > --- > block/sheepdog.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 59 insertions(+), 11 deletions(-) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index 9f3fa89..7bf882a 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -294,7 +294,8 @@ struct SheepdogAIOCB { > Coroutine *coroutine; > void (*aio_done_func)(SheepdogAIOCB *); > > - bool canceled; > + bool cancelable; > + bool *finished; > int nr_pending; > }; > > @@ -411,6 +412,7 @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) > { > SheepdogAIOCB *acb = aio_req->aiocb; > > + acb->cancelable = false; > QLIST_REMOVE(aio_req, aio_siblings); > g_free(aio_req); > > @@ -419,23 +421,68 @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) > > static void coroutine_fn sd_finish_aiocb(SheepdogAIOCB *acb) > { > - if (!acb->canceled) { > - qemu_coroutine_enter(acb->coroutine, NULL); > + qemu_coroutine_enter(acb->coroutine, NULL); > + if (acb->finished) { > + *acb->finished = true; > } > qemu_aio_release(acb); > } > > +/* > + * Check whether the specified acb can be canceled > + * > + * We can cancel aio when any request belonging to the acb is: > + * - Not processed by the sheepdog server. > + * - Not linked to the inflight queue. > + */ > +static bool sd_acb_cancelable(const SheepdogAIOCB *acb) > +{ > + BDRVSheepdogState *s = acb->common.bs->opaque; > + AIOReq *aioreq; > + > + if (!acb->cancelable) { > + return false; > + } > + > + QLIST_FOREACH(aioreq, &s->inflight_aio_head, aio_siblings) { > + if (aioreq->aiocb == acb) { > + return false; > + } > + } > + > + return false; return true; ? > +} Thanks Yuan