From patchwork Tue Aug 26 06:08:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 382956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2FC651400DD for ; Tue, 26 Aug 2014 16:13:02 +1000 (EST) Received: from localhost ([::1]:51862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMA04-0006H3-7Q for incoming@patchwork.ozlabs.org; Tue, 26 Aug 2014 02:13:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XM9vs-0007Ry-Tr for qemu-devel@nongnu.org; Tue, 26 Aug 2014 02:08:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XM9vl-0003Mi-Uf for qemu-devel@nongnu.org; Tue, 26 Aug 2014 02:08:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XM9vl-0003Md-LE for qemu-devel@nongnu.org; Tue, 26 Aug 2014 02:08:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7Q68VkK002137 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 26 Aug 2014 02:08:32 -0400 Received: from T430.nay.redhat.com (dhcp-14-155.nay.redhat.com [10.66.14.155]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7Q67x8X006530; Tue, 26 Aug 2014 02:08:28 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 26 Aug 2014 14:08:18 +0800 Message-Id: <1409033298-5720-9-git-send-email-famz@redhat.com> In-Reply-To: <1409033298-5720-1-git-send-email-famz@redhat.com> References: <1409033298-5720-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi Subject: [Qemu-devel] [RFC PATCH v2 8/8] iscsi: Implement .cancel_async in acb info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Factor out the cancellation submission part in iscsi_aio_cancel, which is all what is needed for .cancel_async. The cb passed to iscsi_task_mgmt_abort_task_async, iscsi_abort_task_cb, will be called later, so for iscsi_bh_cb. In iscsi_bh_cb, acb->canceled is not set if canceled by .cancel_async, so the completion cb is also called. Signed-off-by: Fam Zheng --- block/iscsi.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 3e19202..9ea515f 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -121,6 +121,8 @@ iscsi_bh_cb(void *p) acb->buf = NULL; if (acb->canceled == 0) { + /* Either normally completed or cancelled by iscsi_aio_cancel_async, + * let's call the cb. */ acb->common.cb(acb->common.opaque, acb->status); } @@ -231,7 +233,7 @@ iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data, } static void -iscsi_aio_cancel(BlockDriverAIOCB *blockacb) +iscsi_aio_cancel_async(BlockDriverAIOCB *blockacb) { IscsiAIOCB *acb = (IscsiAIOCB *)blockacb; IscsiLun *iscsilun = acb->iscsilun; @@ -240,12 +242,21 @@ iscsi_aio_cancel(BlockDriverAIOCB *blockacb) return; } - acb->canceled = 1; - /* send a task mgmt call to the target to cancel the task on the target */ iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task, iscsi_abort_task_cb, acb); +} + +static void +iscsi_aio_cancel(BlockDriverAIOCB *blockacb) +{ + IscsiAIOCB *acb = (IscsiAIOCB *)blockacb; + IscsiLun *iscsilun = acb->iscsilun; + + iscsi_aio_cancel_async(blockacb); + + acb->canceled = 1; while (acb->status == -EINPROGRESS) { aio_poll(iscsilun->aio_context, true); } @@ -254,6 +265,7 @@ iscsi_aio_cancel(BlockDriverAIOCB *blockacb) static const AIOCBInfo iscsi_aiocb_info = { .aiocb_size = sizeof(IscsiAIOCB), .cancel = iscsi_aio_cancel, + .cancel_async = iscsi_aio_cancel_async, };