From patchwork Wed Feb 1 05:34:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9548915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EA8F60425 for ; Wed, 1 Feb 2017 05:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60D62283E8 for ; Wed, 1 Feb 2017 05:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55B0928409; Wed, 1 Feb 2017 05:35:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EF744283E8 for ; Wed, 1 Feb 2017 05:35:38 +0000 (UTC) Received: from localhost ([::1]:42814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYnZy-0004Jz-1P for patchwork-qemu-devel@patchwork.kernel.org; Wed, 01 Feb 2017 00:35:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYnZC-00043h-02 for qemu-devel@nongnu.org; Wed, 01 Feb 2017 00:34:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYnZB-0006Vm-0Z for qemu-devel@nongnu.org; Wed, 01 Feb 2017 00:34:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cYnZ8-0006UU-If; Wed, 01 Feb 2017 00:34:46 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2CA681F07; Wed, 1 Feb 2017 05:34:46 +0000 (UTC) Received: from localhost (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v115YjBt006349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 1 Feb 2017 00:34:46 -0500 From: Jeff Cody To: qemu-block@nongnu.org Date: Wed, 1 Feb 2017 00:34:39 -0500 Message-Id: <20170201053440.26002-5-jcody@redhat.com> In-Reply-To: <20170201053440.26002-1-jcody@redhat.com> References: <20170201053440.26002-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 01 Feb 2017 05:34:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/5] sheepdog: simplify inflight_aio_head management X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini Add to the list in add_aio_request and, indirectly, resend_aioreq. Inline free_aio_req in the caller, it does not simply undo alloc_aio_req's job. Signed-off-by: Paolo Bonzini Message-id: 20161129113245.32724-5-pbonzini@redhat.com Signed-off-by: Jeff Cody --- block/sheepdog.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 33ded57..3ef7601 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -479,16 +479,6 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb, return aio_req; } -static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) -{ - SheepdogAIOCB *acb = aio_req->aiocb; - - QLIST_REMOVE(aio_req, aio_siblings); - g_free(aio_req); - - acb->nr_pending--; -} - static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s, QEMUIOVector *qiov, int64_t sector_num, int nb_sectors, int type) @@ -730,7 +720,6 @@ static coroutine_fn void reconnect_to_sdog(void *opaque) while (!QLIST_EMPTY(&s->failed_aio_head)) { aio_req = QLIST_FIRST(&s->failed_aio_head); QLIST_REMOVE(aio_req, aio_siblings); - QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); resend_aioreq(s, aio_req); } } @@ -825,6 +814,7 @@ static void coroutine_fn aio_read_response(void *opaque) */ s->co_recv = NULL; + QLIST_REMOVE(aio_req, aio_siblings); switch (rsp.result) { case SD_RES_SUCCESS: break; @@ -849,8 +839,9 @@ static void coroutine_fn aio_read_response(void *opaque) break; } - free_aio_req(s, aio_req); - if (!acb->nr_pending) { + g_free(aio_req); + + if (!--acb->nr_pending) { /* * We've finished all requests which belong to the AIOCB, so * we can switch back to sd_co_readv/writev now. @@ -1110,6 +1101,8 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, uint64_t old_oid = aio_req->base_oid; bool create = aio_req->create; + QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); + if (!nr_copies) { error_report("bug"); } @@ -1983,7 +1976,6 @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) iov.iov_len = sizeof(s->inode); aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id), data_len, offset, 0, false, 0, offset); - QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); add_aio_request(s, aio_req, &iov, 1, AIOCB_WRITE_UDATA); if (--acb->nr_pending) { qemu_coroutine_yield(); @@ -2185,8 +2177,6 @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb) old_oid, acb->aiocb_type == AIOCB_DISCARD_OBJ ? 0 : done); - QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); - add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, acb->aiocb_type); done: @@ -2280,7 +2270,6 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) acb.nr_pending++; aio_req = alloc_aio_req(s, &acb, vid_to_vdi_oid(s->inode.vdi_id), 0, 0, 0, false, 0, 0); - QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); add_aio_request(s, aio_req, NULL, 0, acb.aiocb_type); if (--acb.nr_pending) {