From nobody Tue Apr 15 02:10:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1485927641235982.2788385591575; Tue, 31 Jan 2017 21:40:41 -0800 (PST) Received: from localhost ([::1]:42837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYnep-0000Kc-Fi for importer@patchew.org; Wed, 01 Feb 2017 00:40:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYnZC-00044K-J8 for qemu-devel@nongnu.org; Wed, 01 Feb 2017 00:34:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYnZB-0006W2-AK for qemu-devel@nongnu.org; Wed, 01 Feb 2017 00:34:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52380) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cYnZ7-0006UI-DY; Wed, 01 Feb 2017 00:34:45 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 8624C3B722; Wed, 1 Feb 2017 05:34:45 +0000 (UTC) Received: from localhost (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v115Yi8H007938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 1 Feb 2017 00:34:45 -0500 From: Jeff Cody To: qemu-block@nongnu.org Date: Wed, 1 Feb 2017 00:34:38 -0500 Message-Id: <20170201053440.26002-4-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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 01 Feb 2017 05:34:45 +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 3/5] sheepdog: do not use BlockAIOCB 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Sheepdog's AIOCB are completely internal entities for a group of requests and do not need dynamic allocation. Signed-off-by: Paolo Bonzini Message-id: 20161129113245.32724-4-pbonzini@redhat.com Signed-off-by: Jeff Cody --- block/sheepdog.c | 99 ++++++++++++++++++++++------------------------------= ---- 1 file changed, 39 insertions(+), 60 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index e0985df..33ded57 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -306,6 +306,7 @@ static inline size_t count_data_objs(const struct Sheep= dogInode *inode) } while (0) =20 typedef struct SheepdogAIOCB SheepdogAIOCB; +typedef struct BDRVSheepdogState BDRVSheepdogState; =20 typedef struct AIOReq { SheepdogAIOCB *aiocb; @@ -334,7 +335,7 @@ enum AIOCBState { || y->max_affect_data_idx < x->min_affect_data_idx)) =20 struct SheepdogAIOCB { - BlockAIOCB common; + BDRVSheepdogState *s; =20 QEMUIOVector *qiov; =20 @@ -362,7 +363,7 @@ struct SheepdogAIOCB { QLIST_ENTRY(SheepdogAIOCB) aiocb_siblings; }; =20 -typedef struct BDRVSheepdogState { +struct BDRVSheepdogState { BlockDriverState *bs; AioContext *aio_context; =20 @@ -389,7 +390,7 @@ typedef struct BDRVSheepdogState { =20 CoQueue overlapping_queue; QLIST_HEAD(inflight_aiocb_head, SheepdogAIOCB) inflight_aiocb_head; -} BDRVSheepdogState; +}; =20 typedef struct BDRVSheepdogReopenState { int fd; @@ -488,20 +489,15 @@ static inline void free_aio_req(BDRVSheepdogState *s,= AIOReq *aio_req) acb->nr_pending--; } =20 -static const AIOCBInfo sd_aiocb_info =3D { - .aiocb_size =3D sizeof(SheepdogAIOCB), -}; - -static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qio= v, - int64_t sector_num, int nb_sectors) +static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s, + QEMUIOVector *qiov, int64_t sector_num, int nb_se= ctors, + int type) { - SheepdogAIOCB *acb; uint32_t object_size; - BDRVSheepdogState *s =3D bs->opaque; =20 object_size =3D (UINT32_C(1) << s->inode.block_size_shift); =20 - acb =3D qemu_aio_get(&sd_aiocb_info, bs, NULL, NULL); + acb->s =3D s; =20 acb->qiov =3D qiov; =20 @@ -518,8 +514,7 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs= , QEMUIOVector *qiov, =20 acb->min_dirty_data_idx =3D UINT32_MAX; acb->max_dirty_data_idx =3D 0; - - return acb; + acb->aiocb_type =3D type; } =20 /* Return -EIO in case of error, file descriptor on success */ @@ -1967,7 +1962,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t = offset) */ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) { - BDRVSheepdogState *s =3D acb->common.bs->opaque; + BDRVSheepdogState *s =3D acb->s; struct iovec iov; AIOReq *aio_req; uint32_t offset, data_len, mn, mx; @@ -2105,16 +2100,15 @@ out: * Returns 1 when we need to wait a response, 0 when there is no sent * request and -errno in error cases. */ -static void coroutine_fn sd_co_rw_vector(void *p) +static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb) { - SheepdogAIOCB *acb =3D p; int ret =3D 0; unsigned long len, done =3D 0, total =3D acb->nb_sectors * BDRV_SECTOR= _SIZE; unsigned long idx; uint32_t object_size; uint64_t oid; uint64_t offset; - BDRVSheepdogState *s =3D acb->common.bs->opaque; + BDRVSheepdogState *s =3D acb->s; SheepdogInode *inode =3D &s->inode; AIOReq *aio_req; =20 @@ -2222,7 +2216,7 @@ static bool check_overlapping_aiocb(BDRVSheepdogState= *s, SheepdogAIOCB *aiocb) static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_= num, int nb_sectors, QEMUIOVector *qiov) { - SheepdogAIOCB *acb; + SheepdogAIOCB acb; int ret; int64_t offset =3D (sector_num + nb_sectors) * BDRV_SECTOR_SIZE; BDRVSheepdogState *s =3D bs->opaque; @@ -2234,76 +2228,65 @@ static coroutine_fn int sd_co_writev(BlockDriverSta= te *bs, int64_t sector_num, } } =20 - acb =3D sd_aio_setup(bs, qiov, sector_num, nb_sectors); - acb->aiocb_type =3D AIOCB_WRITE_UDATA; + sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_WRITE_UDATA); =20 retry: - if (check_overlapping_aiocb(s, acb)) { + if (check_overlapping_aiocb(s, &acb)) { qemu_co_queue_wait(&s->overlapping_queue); goto retry; } =20 - sd_co_rw_vector(acb); - sd_write_done(acb); + sd_co_rw_vector(&acb); + sd_write_done(&acb); =20 - QLIST_REMOVE(acb, aiocb_siblings); + QLIST_REMOVE(&acb, aiocb_siblings); qemu_co_queue_restart_all(&s->overlapping_queue); - ret =3D acb->ret; - qemu_aio_unref(acb); - return ret; + return acb.ret; } =20 static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_n= um, int nb_sectors, QEMUIOVector *qiov) { - SheepdogAIOCB *acb; - int ret; + SheepdogAIOCB acb; BDRVSheepdogState *s =3D bs->opaque; =20 - acb =3D sd_aio_setup(bs, qiov, sector_num, nb_sectors); - acb->aiocb_type =3D AIOCB_READ_UDATA; + sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_READ_UDATA); =20 retry: - if (check_overlapping_aiocb(s, acb)) { + if (check_overlapping_aiocb(s, &acb)) { qemu_co_queue_wait(&s->overlapping_queue); goto retry; } =20 - sd_co_rw_vector(acb); + sd_co_rw_vector(&acb); =20 - QLIST_REMOVE(acb, aiocb_siblings); + QLIST_REMOVE(&acb, aiocb_siblings); qemu_co_queue_restart_all(&s->overlapping_queue); - ret =3D acb->ret; - qemu_aio_unref(acb); - return ret; + return acb.ret; } =20 static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) { BDRVSheepdogState *s =3D bs->opaque; - SheepdogAIOCB *acb; - int ret; + SheepdogAIOCB acb; AIOReq *aio_req; =20 if (s->cache_flags !=3D SD_FLAG_CMD_CACHE) { return 0; } =20 - acb =3D sd_aio_setup(bs, NULL, 0, 0); - acb->aiocb_type =3D AIOCB_FLUSH_CACHE; + sd_aio_setup(&acb, s, NULL, 0, 0, AIOCB_FLUSH_CACHE); =20 - acb->nr_pending++; - aio_req =3D alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id), + acb.nr_pending++; + aio_req =3D 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); + add_aio_request(s, aio_req, NULL, 0, acb.aiocb_type); =20 - if (--acb->nr_pending) { + if (--acb.nr_pending) { qemu_coroutine_yield(); } - ret =3D acb->ret; - qemu_aio_unref(acb); - return ret; + return acb.ret; } =20 static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_i= nfo) @@ -2737,9 +2720,8 @@ static int sd_load_vmstate(BlockDriverState *bs, QEMU= IOVector *qiov, static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offse= t, int count) { - SheepdogAIOCB *acb; + SheepdogAIOCB acb; BDRVSheepdogState *s =3D bs->opaque; - int ret; QEMUIOVector discard_iov; struct iovec iov; uint32_t zero =3D 0; @@ -2757,23 +2739,20 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverS= tate *bs, int64_t offset, if (!QEMU_IS_ALIGNED(offset | count, BDRV_SECTOR_SIZE)) { return -ENOTSUP; } - acb =3D sd_aio_setup(bs, &discard_iov, offset >> BDRV_SECTOR_BITS, - count >> BDRV_SECTOR_BITS); - acb->aiocb_type =3D AIOCB_DISCARD_OBJ; + sd_aio_setup(&acb, s, &discard_iov, offset >> BDRV_SECTOR_BITS, + count >> BDRV_SECTOR_BITS, AIOCB_DISCARD_OBJ); =20 retry: - if (check_overlapping_aiocb(s, acb)) { + if (check_overlapping_aiocb(s, &acb)) { qemu_co_queue_wait(&s->overlapping_queue); goto retry; } =20 - sd_co_rw_vector(acb); + sd_co_rw_vector(&acb); =20 - QLIST_REMOVE(acb, aiocb_siblings); + QLIST_REMOVE(&acb, aiocb_siblings); qemu_co_queue_restart_all(&s->overlapping_queue); - ret =3D acb->ret; - qemu_aio_unref(acb); - return ret; + return acb.ret; } =20 static coroutine_fn int64_t --=20 2.9.3