From nobody Sun May 5 08:13:09 2024 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529601709738215.9395402459803; Thu, 21 Jun 2018 10:21:49 -0700 (PDT) Received: from localhost ([::1]:56831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fW3HF-0002gU-62 for importer@patchew.org; Thu, 21 Jun 2018 13:21:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fW3FA-0001Lx-15 for qemu-devel@nongnu.org; Thu, 21 Jun 2018 13:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fW3F9-0005QJ-0D for qemu-devel@nongnu.org; Thu, 21 Jun 2018 13:19:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47370 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fW3F3-0005MO-6M; Thu, 21 Jun 2018 13:19:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C62C8406E87A; Thu, 21 Jun 2018 17:19:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-146.ams2.redhat.com [10.36.116.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D8271117643; Thu, 21 Jun 2018 17:19:27 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 21 Jun 2018 19:19:25 +0200 Message-Id: <20180621171925.28925-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 21 Jun 2018 17:19:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 21 Jun 2018 17:19:28 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] file-posix: Implement co versions of discard/flush 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: kwolf@redhat.com, qemu-devel@nongnu.org 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" This simplifies file-posix by implementing the coroutine variants of the discard and flush BlockDriver callbacks. These were the last remaining users of paio_submit(), which can be removed now. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/file-posix.c | 72 ++++++++++++++++++--------------------------------= ---- 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index fa918f2bdb..7b8eecafcd 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1747,31 +1747,6 @@ static inline int paio_submit_co(BlockDriverState *b= s, int fd, return paio_submit_co_full(bs, fd, offset, -1, 0, qiov, bytes, type); } =20 -static BlockAIOCB *paio_submit(BlockDriverState *bs, int fd, - int64_t offset, QEMUIOVector *qiov, int bytes, - BlockCompletionFunc *cb, void *opaque, int type) -{ - RawPosixAIOData *acb =3D g_new(RawPosixAIOData, 1); - ThreadPool *pool; - - acb->bs =3D bs; - acb->aio_type =3D type; - acb->aio_fildes =3D fd; - - acb->aio_nbytes =3D bytes; - acb->aio_offset =3D offset; - - if (qiov) { - acb->aio_iov =3D qiov->iov; - acb->aio_niov =3D qiov->niov; - assert(qiov->size =3D=3D acb->aio_nbytes); - } - - trace_paio_submit(acb, opaque, offset, bytes, type); - pool =3D aio_get_thread_pool(bdrv_get_aio_context(bs)); - return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque); -} - static int coroutine_fn raw_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int= type) { @@ -1838,15 +1813,17 @@ static void raw_aio_unplug(BlockDriverState *bs) #endif } =20 -static BlockAIOCB *raw_aio_flush(BlockDriverState *bs, - BlockCompletionFunc *cb, void *opaque) +static int raw_co_flush_to_disk(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; + int ret; =20 - if (fd_open(bs) < 0) - return NULL; + ret =3D fd_open(bs); + if (ret < 0) { + return ret; + } =20 - return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH); + return paio_submit_co(bs, s->fd, 0, NULL, 0, QEMU_AIO_FLUSH); } =20 static void raw_close(BlockDriverState *bs) @@ -2503,14 +2480,12 @@ static void coroutine_fn raw_co_invalidate_cache(Bl= ockDriverState *bs, #endif /* !__linux__ */ } =20 -static coroutine_fn BlockAIOCB *raw_aio_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes, - BlockCompletionFunc *cb, void *opaque) +static coroutine_fn int +raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { BDRVRawState *s =3D bs->opaque; =20 - return paio_submit(bs, s->fd, offset, NULL, bytes, - cb, opaque, QEMU_AIO_DISCARD); + return paio_submit_co(bs, s->fd, offset, NULL, bytes, QEMU_AIO_DISCARD= ); } =20 static int coroutine_fn raw_co_pwrite_zeroes( @@ -2629,8 +2604,8 @@ BlockDriver bdrv_file =3D { =20 .bdrv_co_preadv =3D raw_co_preadv, .bdrv_co_pwritev =3D raw_co_pwritev, - .bdrv_aio_flush =3D raw_aio_flush, - .bdrv_aio_pdiscard =3D raw_aio_pdiscard, + .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, + .bdrv_co_pdiscard =3D raw_co_pdiscard, .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, @@ -2995,17 +2970,18 @@ static int fd_open(BlockDriverState *bs) return -EIO; } =20 -static coroutine_fn BlockAIOCB *hdev_aio_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes, - BlockCompletionFunc *cb, void *opaque) +static coroutine_fn int +hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { BDRVRawState *s =3D bs->opaque; + int ret; =20 - if (fd_open(bs) < 0) { - return NULL; + ret =3D fd_open(bs); + if (ret < 0) { + return ret; } - return paio_submit(bs, s->fd, offset, NULL, bytes, - cb, opaque, QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV); + return paio_submit_co(bs, s->fd, offset, NULL, bytes, + QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV); } =20 static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs, @@ -3109,8 +3085,8 @@ static BlockDriver bdrv_host_device =3D { =20 .bdrv_co_preadv =3D raw_co_preadv, .bdrv_co_pwritev =3D raw_co_pwritev, - .bdrv_aio_flush =3D raw_aio_flush, - .bdrv_aio_pdiscard =3D hdev_aio_pdiscard, + .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, + .bdrv_co_pdiscard =3D hdev_co_pdiscard, .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, @@ -3234,7 +3210,7 @@ static BlockDriver bdrv_host_cdrom =3D { =20 .bdrv_co_preadv =3D raw_co_preadv, .bdrv_co_pwritev =3D raw_co_pwritev, - .bdrv_aio_flush =3D raw_aio_flush, + .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, @@ -3364,7 +3340,7 @@ static BlockDriver bdrv_host_cdrom =3D { =20 .bdrv_co_preadv =3D raw_co_preadv, .bdrv_co_pwritev =3D raw_co_pwritev, - .bdrv_aio_flush =3D raw_aio_flush, + .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, --=20 2.13.6