From nobody Sun Oct 5 17:18:01 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.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 1518723535197720.2341559704405; Thu, 15 Feb 2018 11:38:55 -0800 (PST) Received: from localhost ([::1]:52761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPMn-0007AA-NL for importer@patchew.org; Thu, 15 Feb 2018 14:38:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPDA-0006Gs-3p for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emPD8-0000mV-GN for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:52 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38956 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 1emPD2-0000j8-88; Thu, 15 Feb 2018 14:28:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6AE481638F1; Thu, 15 Feb 2018 19:28:43 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C0D5F41A0; Thu, 15 Feb 2018 19:28:40 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 13:28:24 -0600 Message-Id: <20180215192829.9944-2-eblake@redhat.com> In-Reply-To: <20180215192829.9944-1-eblake@redhat.com> References: <20180215192829.9944-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 15 Feb 2018 19:28:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 15 Feb 2018 19:28:43 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@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 1/6] block: Support byte-based aio callbacks 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, Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz 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" We are gradually moving away from sector-based interfaces, towards byte-based. Add new sector-based aio callbacks for read and write, to match the fact that bdrv_aio_pdiscard is already byte-based. Ideally, drivers should be converted to use coroutine callbacks rather than aio; but that is not quite as trivial (if we do that conversion, the null-aio driver will disappear), so for the short term, converting the signature but keeping things with aio is easier. Once all drivers are converted, the sector-based aio callbacks will be removed. Signed-off-by: Eric Blake --- include/block/block_int.h | 6 ++++++ block/io.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 5ae7738cf8d..c882dc4232d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -137,9 +137,15 @@ struct BlockDriver { BlockAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque); + BlockAIOCB *(*bdrv_aio_preadv)(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_writev)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque); + BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pdiscard)(BlockDriverState *bs, diff --git a/block/io.c b/block/io.c index 4d3d1f640a3..84a4caa72b7 100644 --- a/block/io.c +++ b/block/io.c @@ -934,9 +934,11 @@ static int coroutine_fn bdrv_driver_preadv(BlockDriver= State *bs, sector_num =3D offset >> BDRV_SECTOR_BITS; nb_sectors =3D bytes >> BDRV_SECTOR_BITS; - assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); - assert((bytes >> BDRV_SECTOR_BITS) <=3D BDRV_REQUEST_MAX_SECTORS); + if (!drv->bdrv_aio_preadv) { + assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); + assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); + assert((bytes >> BDRV_SECTOR_BITS) <=3D BDRV_REQUEST_MAX_SECTORS); + } if (drv->bdrv_co_readv) { return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); @@ -946,8 +948,13 @@ static int coroutine_fn bdrv_driver_preadv(BlockDriver= State *bs, .coroutine =3D qemu_coroutine_self(), }; - acb =3D bs->drv->bdrv_aio_readv(bs, sector_num, qiov, nb_sectors, - bdrv_co_io_em_complete, &co); + if (drv->bdrv_aio_preadv) { + acb =3D bs->drv->bdrv_aio_preadv(bs, offset, bytes, qiov, flag= s, + bdrv_co_io_em_complete, &co); + } else { + acb =3D bs->drv->bdrv_aio_readv(bs, sector_num, qiov, nb_secto= rs, + bdrv_co_io_em_complete, &co); + } if (acb =3D=3D NULL) { return -EIO; } else { @@ -982,9 +989,11 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDrive= rState *bs, sector_num =3D offset >> BDRV_SECTOR_BITS; nb_sectors =3D bytes >> BDRV_SECTOR_BITS; - assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); - assert((bytes >> BDRV_SECTOR_BITS) <=3D BDRV_REQUEST_MAX_SECTORS); + if (!drv->bdrv_aio_pwritev) { + assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); + assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); + assert((bytes >> BDRV_SECTOR_BITS) <=3D BDRV_REQUEST_MAX_SECTORS); + } if (drv->bdrv_co_writev_flags) { ret =3D drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov, @@ -999,8 +1008,16 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriv= erState *bs, .coroutine =3D qemu_coroutine_self(), }; - acb =3D bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors, - bdrv_co_io_em_complete, &co); + if (drv->bdrv_aio_pwritev) { + acb =3D bs->drv->bdrv_aio_pwritev(bs, offset, bytes, qiov, + flags & bs->supported_write_fl= ags, + bdrv_co_io_em_complete, &co); + flags &=3D ~bs->supported_write_flags; + } else { + assert(!bs->supported_write_flags); + acb =3D bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sect= ors, + bdrv_co_io_em_complete, &co); + } if (acb =3D=3D NULL) { ret =3D -EIO; } else { --=20 2.14.3 From nobody Sun Oct 5 17:18:01 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.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518723059388898.7748238252922; Thu, 15 Feb 2018 11:30:59 -0800 (PST) Received: from localhost ([::1]:52171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPF3-0007gF-Ic for importer@patchew.org; Thu, 15 Feb 2018 14:30:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPD9-0006Fz-Mz for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emPD8-0000ma-Hw for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38912 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 1emPD3-0000jZ-64; Thu, 15 Feb 2018 14:28:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF0E98424D; Thu, 15 Feb 2018 19:28:44 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08D94F41A0; Thu, 15 Feb 2018 19:28:43 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 13:28:25 -0600 Message-Id: <20180215192829.9944-3-eblake@redhat.com> In-Reply-To: <20180215192829.9944-1-eblake@redhat.com> References: <20180215192829.9944-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Feb 2018 19:28:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Feb 2018 19:28:44 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@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 2/6] file-win32: Switch to byte-based callbacks 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, Stefan Weil , qemu-block@nongnu.org, Max Reitz 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" We are gradually moving away from sector-based interfaces, towards byte-based. Make the change for the last few sector-based callbacks in the file-win32 driver. Note that the driver was already using byte-based calls for performing actual I/O, so this just gets rid of a round trip of scaling; however, the block layer defaults this driver to use request_alignment of 512, and I did not change that, because I don't know if Windows is tolerant of non-sector AIO operations. Signed-off-by: Eric Blake --- Compile-tested via 'make docker-test-mingw@fedora', but I don't have a sane way to test whether it actually works. --- include/block/raw-aio.h | 2 +- block/file-win32.c | 36 ++++++++++++++++++------------------ block/win32-aio.c | 5 ++--- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h index a4cdbbf1b7a..9e47b8a629d 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -57,7 +57,7 @@ void win32_aio_cleanup(QEMUWin32AIOState *aio); int win32_aio_attach(QEMUWin32AIOState *aio, HANDLE hfile); BlockAIOCB *win32_aio_submit(BlockDriverState *bs, QEMUWin32AIOState *aio, HANDLE hfile, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, + uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, BlockCompletionFunc *cb, void *opaque, int type); void win32_aio_detach_aio_context(QEMUWin32AIOState *aio, AioContext *old_context); diff --git a/block/file-win32.c b/block/file-win32.c index f24c7bb92c6..7a2e3367946 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -410,32 +410,32 @@ fail: return ret; } -static BlockAIOCB *raw_aio_readv(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_se= ctors, - BlockCompletionFunc *cb, void *opaque) +static BlockAIOCB *raw_aio_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s =3D bs->opaque; if (s->aio) { - return win32_aio_submit(bs, s->aio, s->hfile, sector_num, qiov, - nb_sectors, cb, opaque, QEMU_AIO_READ); + return win32_aio_submit(bs, s->aio, s->hfile, offset, bytes, qiov, + cb, opaque, QEMU_AIO_READ); } else { - return paio_submit(bs, s->hfile, sector_num << BDRV_SECTOR_BITS, q= iov, - nb_sectors << BDRV_SECTOR_BITS, + return paio_submit(bs, s->hfile, offset, qiov, bytes, cb, opaque, QEMU_AIO_READ); } } -static BlockAIOCB *raw_aio_writev(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_s= ectors, - BlockCompletionFunc *cb, void *opaque) +static BlockAIOCB *raw_aio_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s =3D bs->opaque; if (s->aio) { - return win32_aio_submit(bs, s->aio, s->hfile, sector_num, qiov, - nb_sectors, cb, opaque, QEMU_AIO_WRITE); + return win32_aio_submit(bs, s->aio, s->hfile, offset, bytes, qiov, + cb, opaque, QEMU_AIO_WRITE); } else { - return paio_submit(bs, s->hfile, sector_num << BDRV_SECTOR_BITS, q= iov, - nb_sectors << BDRV_SECTOR_BITS, + return paio_submit(bs, s->hfile, offset, qiov, bytes, cb, opaque, QEMU_AIO_WRITE); } } @@ -602,8 +602,8 @@ BlockDriver bdrv_file =3D { .bdrv_create =3D raw_create, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, - .bdrv_aio_readv =3D raw_aio_readv, - .bdrv_aio_writev =3D raw_aio_writev, + .bdrv_aio_preadv =3D raw_aio_preadv, + .bdrv_aio_pwritev =3D raw_aio_pwritev, .bdrv_aio_flush =3D raw_aio_flush, .bdrv_truncate =3D raw_truncate, @@ -764,8 +764,8 @@ static BlockDriver bdrv_host_device =3D { .bdrv_file_open =3D hdev_open, .bdrv_close =3D raw_close, - .bdrv_aio_readv =3D raw_aio_readv, - .bdrv_aio_writev =3D raw_aio_writev, + .bdrv_aio_preadv =3D raw_aio_preadv, + .bdrv_aio_pwritev =3D raw_aio_pwritev, .bdrv_aio_flush =3D raw_aio_flush, .bdrv_detach_aio_context =3D raw_detach_aio_context, diff --git a/block/win32-aio.c b/block/win32-aio.c index 3be8f458fab..9cd355d42f8 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -112,15 +112,14 @@ static const AIOCBInfo win32_aiocb_info =3D { BlockAIOCB *win32_aio_submit(BlockDriverState *bs, QEMUWin32AIOState *aio, HANDLE hfile, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, + uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, BlockCompletionFunc *cb, void *opaque, int type) { struct QEMUWin32AIOCB *waiocb; - uint64_t offset =3D sector_num * 512; DWORD rc; waiocb =3D qemu_aio_get(&win32_aiocb_info, bs, cb, opaque); - waiocb->nbytes =3D nb_sectors * 512; + waiocb->nbytes =3D bytes; waiocb->qiov =3D qiov; waiocb->is_read =3D (type =3D=3D QEMU_AIO_READ); --=20 2.14.3 From nobody Sun Oct 5 17:18:01 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.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 1518723419243685.5152632511077; Thu, 15 Feb 2018 11:36:59 -0800 (PST) Received: from localhost ([::1]:52584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPL0-0005In-8Z for importer@patchew.org; Thu, 15 Feb 2018 14:36:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPD9-0006G2-NY for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emPD8-0000mO-Er for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49468 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 1emPD3-0000jn-QW; Thu, 15 Feb 2018 14:28:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67D024040858; Thu, 15 Feb 2018 19:28:45 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2CD8F41A0; Thu, 15 Feb 2018 19:28:44 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 13:28:26 -0600 Message-Id: <20180215192829.9944-4-eblake@redhat.com> In-Reply-To: <20180215192829.9944-1-eblake@redhat.com> References: <20180215192829.9944-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Feb 2018 19:28:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Feb 2018 19:28:45 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@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 3/6] null: Switch to byte-based read/write 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, Fam Zheng , qemu-block@nongnu.org, Max Reitz 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" We are gradually moving away from sector-based interfaces, towards byte-based. Make the change for the last few sector-based callbacks in the null-co and null-aio drivers. Note that since the null driver does nothing on writes, it trivially supports the BDRV_REQ_FUA flag (all writes have already landed to the same bit-bucket without needing an extra flush call). Furthermore, bdrv_refresh_limits() defaults the block size to 512 for any driver that does not support coroutines; while this is still correct for the other aio-based drivers, the null driver does just as well with byte-based requests, and being explicit means we can avoid cycles wasted on read-modify-write. Signed-off-by: Eric Blake --- block/null.c | 66 ++++++++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/block/null.c b/block/null.c index 806a8631e4d..2381090dfcf 100644 --- a/block/null.c +++ b/block/null.c @@ -93,6 +93,7 @@ static int null_file_open(BlockDriverState *bs, QDict *op= tions, int flags, } s->read_zeroes =3D qemu_opt_get_bool(opts, NULL_OPT_ZEROES, false); qemu_opts_del(opts); + bs->supported_write_flags =3D BDRV_REQ_FUA; return ret; } @@ -116,22 +117,22 @@ static coroutine_fn int null_co_common(BlockDriverSta= te *bs) return 0; } -static coroutine_fn int null_co_readv(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, - QEMUIOVector *qiov) +static coroutine_fn int null_co_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags) { BDRVNullState *s =3D bs->opaque; if (s->read_zeroes) { - qemu_iovec_memset(qiov, 0, 0, nb_sectors * BDRV_SECTOR_SIZE); + qemu_iovec_memset(qiov, 0, 0, bytes); } return null_co_common(bs); } -static coroutine_fn int null_co_writev(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, - QEMUIOVector *qiov) +static coroutine_fn int null_co_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags) { return null_co_common(bs); } @@ -186,26 +187,26 @@ static inline BlockAIOCB *null_aio_common(BlockDriver= State *bs, return &acb->common; } -static BlockAIOCB *null_aio_readv(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, - int nb_sectors, - BlockCompletionFunc *cb, - void *opaque) -{ - BDRVNullState *s =3D bs->opaque; - - if (s->read_zeroes) { - qemu_iovec_memset(qiov, 0, 0, nb_sectors * BDRV_SECTOR_SIZE); - } - - return null_aio_common(bs, cb, opaque); -} - -static BlockAIOCB *null_aio_writev(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, - int nb_sectors, +static BlockAIOCB *null_aio_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque) +{ + BDRVNullState *s =3D bs->opaque; + + if (s->read_zeroes) { + qemu_iovec_memset(qiov, 0, 0, bytes); + } + + return null_aio_common(bs, cb, opaque); +} + +static BlockAIOCB *null_aio_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, + void *opaque) { return null_aio_common(bs, cb, opaque); } @@ -256,6 +257,11 @@ static void null_refresh_filename(BlockDriverState *bs= , QDict *opts) bs->full_open_options =3D opts; } +static void null_refresh_limits(BlockDriverState *bs, Error **errp) +{ + bs->bl.request_alignment =3D 1; +} + static BlockDriver bdrv_null_co =3D { .format_name =3D "null-co", .protocol_name =3D "null-co", @@ -266,14 +272,15 @@ static BlockDriver bdrv_null_co =3D { .bdrv_close =3D null_close, .bdrv_getlength =3D null_getlength, - .bdrv_co_readv =3D null_co_readv, - .bdrv_co_writev =3D null_co_writev, + .bdrv_co_preadv =3D null_co_preadv, + .bdrv_co_pwritev =3D null_co_pwritev, .bdrv_co_flush_to_disk =3D null_co_flush, .bdrv_reopen_prepare =3D null_reopen_prepare, .bdrv_co_block_status =3D null_co_block_status, .bdrv_refresh_filename =3D null_refresh_filename, + .bdrv_refresh_limits =3D null_refresh_limits, }; static BlockDriver bdrv_null_aio =3D { @@ -286,14 +293,15 @@ static BlockDriver bdrv_null_aio =3D { .bdrv_close =3D null_close, .bdrv_getlength =3D null_getlength, - .bdrv_aio_readv =3D null_aio_readv, - .bdrv_aio_writev =3D null_aio_writev, + .bdrv_aio_preadv =3D null_aio_preadv, + .bdrv_aio_pwritev =3D null_aio_pwritev, .bdrv_aio_flush =3D null_aio_flush, .bdrv_reopen_prepare =3D null_reopen_prepare, .bdrv_co_block_status =3D null_co_block_status, .bdrv_refresh_filename =3D null_refresh_filename, + .bdrv_refresh_limits =3D null_refresh_limits, }; static void bdrv_null_init(void) --=20 2.14.3 From nobody Sun Oct 5 17:18:01 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.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518723059839755.3351805545724; Thu, 15 Feb 2018 11:30:59 -0800 (PST) Received: from localhost ([::1]:52175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPF4-0007iq-DF for importer@patchew.org; Thu, 15 Feb 2018 14:30:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPD9-0006Fc-ER for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emPD8-0000m9-Cl for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38916 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 1emPD4-0000k5-Fq; Thu, 15 Feb 2018 14:28:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 224EB84252; Thu, 15 Feb 2018 19:28:46 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CE27FFD26; Thu, 15 Feb 2018 19:28:45 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 13:28:27 -0600 Message-Id: <20180215192829.9944-5-eblake@redhat.com> In-Reply-To: <20180215192829.9944-1-eblake@redhat.com> References: <20180215192829.9944-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Feb 2018 19:28:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Feb 2018 19:28:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@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 4/6] rbd: Switch to byte-based callbacks 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, Josh Durgin , Jeff Cody , qemu-block@nongnu.org, Max Reitz 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" We are gradually moving away from sector-based interfaces, towards byte-based. Make the change for the last few sector-based callbacks in the rbd driver. Note that the driver was already using byte-based calls for performing actual I/O, so this just gets rid of a round trip of scaling; however, the block layer defaults this driver to use request_alignment of 512, and I did not change that. Signed-off-by: Eric Blake --- block/rbd.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 8474b0ba117..b3a613023c1 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -870,27 +870,23 @@ failed: return NULL; } -static BlockAIOCB *qemu_rbd_aio_readv(BlockDriverState *bs, - int64_t sector_num, - QEMUIOVector *qiov, - int nb_sectors, - BlockCompletionFunc *cb, - void *opaque) -{ - return rbd_start_aio(bs, sector_num << BDRV_SECTOR_BITS, qiov, - (int64_t) nb_sectors << BDRV_SECTOR_BITS, cb, opa= que, - RBD_AIO_READ); -} - -static BlockAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs, - int64_t sector_num, - QEMUIOVector *qiov, - int nb_sectors, +static BlockAIOCB *qemu_rbd_aio_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque) { - return rbd_start_aio(bs, sector_num << BDRV_SECTOR_BITS, qiov, - (int64_t) nb_sectors << BDRV_SECTOR_BITS, cb, opa= que, + return rbd_start_aio(bs, offset, qiov, bytes, cb, opaque, + RBD_AIO_READ); +} + +static BlockAIOCB *qemu_rbd_aio_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, + void *opaque) +{ + return rbd_start_aio(bs, offset, qiov, bytes, cb, opaque, RBD_AIO_WRITE); } @@ -1140,8 +1136,8 @@ static BlockDriver bdrv_rbd =3D { .bdrv_truncate =3D qemu_rbd_truncate, .protocol_name =3D "rbd", - .bdrv_aio_readv =3D qemu_rbd_aio_readv, - .bdrv_aio_writev =3D qemu_rbd_aio_writev, + .bdrv_aio_preadv =3D qemu_rbd_aio_preadv, + .bdrv_aio_pwritev =3D qemu_rbd_aio_pwritev, #ifdef LIBRBD_SUPPORTS_AIO_FLUSH .bdrv_aio_flush =3D qemu_rbd_aio_flush, --=20 2.14.3 From nobody Sun Oct 5 17:18:01 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.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 151872322240326.942251623664447; Thu, 15 Feb 2018 11:33:42 -0800 (PST) Received: from localhost ([::1]:52282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPHp-0001hp-Hy for importer@patchew.org; Thu, 15 Feb 2018 14:33:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPD9-0006Fe-Fv for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emPD8-0000mJ-EB for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34330 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 1emPD5-0000kT-A9; Thu, 15 Feb 2018 14:28:47 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB9924023112; Thu, 15 Feb 2018 19:28:46 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45B03F41A0; Thu, 15 Feb 2018 19:28:46 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 13:28:28 -0600 Message-Id: <20180215192829.9944-6-eblake@redhat.com> In-Reply-To: <20180215192829.9944-1-eblake@redhat.com> References: <20180215192829.9944-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Feb 2018 19:28:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Feb 2018 19:28:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@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 5/6] vxhs: Switch to byte-based callbacks 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-block@nongnu.org, Max Reitz 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" We are gradually moving away from sector-based interfaces, towards byte-based. Make the change for the last few sector-based callbacks in the vxhs driver. Note that the driver was already using byte-based calls for performing actual I/O, so this just gets rid of a round trip of scaling; however, the block layer defaults this driver to use request_alignment of 512, and I did not change that. Signed-off-by: Eric Blake --- I was unable to get this to compile, as I do not have the vxhs devel headers installed. By inspection, it should work, but a careful review is appreciated. --- block/vxhs.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/block/vxhs.c b/block/vxhs.c index 75cc6c8672c..c478ae26035 100644 --- a/block/vxhs.c +++ b/block/vxhs.c @@ -424,21 +424,17 @@ static const AIOCBInfo vxhs_aiocb_info =3D { * and is passed to QNIO. When QNIO completes the work, * it will be passed back through the callback. */ -static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num, - QEMUIOVector *qiov, int nb_sectors, +static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, uint64_t offset, + QEMUIOVector *qiov, uint64_t size, BlockCompletionFunc *cb, void *opaque, VDISKAIOCmd iodir) { VXHSAIOCB *acb =3D NULL; BDRVVXHSState *s =3D bs->opaque; - size_t size; - uint64_t offset; int iio_flags =3D 0; int ret =3D 0; void *dev_handle =3D s->vdisk_hostinfo.dev_handle; - offset =3D sector_num * BDRV_SECTOR_SIZE; - size =3D nb_sectors * BDRV_SECTOR_SIZE; acb =3D qemu_aio_get(&vxhs_aiocb_info, bs, cb, opaque); /* @@ -451,11 +447,11 @@ static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, = int64_t sector_num, switch (iodir) { case VDISK_AIO_WRITE: ret =3D iio_writev(dev_handle, acb, qiov->iov, qiov->niov, - offset, (uint64_t)size, iio_flags); + offset, size, iio_flags); break; case VDISK_AIO_READ: ret =3D iio_readv(dev_handle, acb, qiov->iov, qiov->niov, - offset, (uint64_t)size, iio_flags); + offset, size, iio_flags); break; default: trace_vxhs_aio_rw_invalid(iodir); @@ -474,22 +470,20 @@ errout: return NULL; } -static BlockAIOCB *vxhs_aio_readv(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, - int nb_sectors, +static BlockAIOCB *vxhs_aio_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque) { - return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, cb, - opaque, VDISK_AIO_READ); + return vxhs_aio_rw(bs, offset, qiov, bytes, cb, opaque, VDISK_AIO_READ= ); } -static BlockAIOCB *vxhs_aio_writev(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, - int nb_sectors, - BlockCompletionFunc *cb, void *opaque) +static BlockAIOCB *vxhs_aio_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags, + BlockCompletionFunc *cb, void *opaque) { - return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, - cb, opaque, VDISK_AIO_WRITE); + return vxhs_aio_rw(bs, offset, qiov, bytes, cb, opaque, VDISK_AIO_WRIT= E); } static void vxhs_close(BlockDriverState *bs) @@ -563,8 +557,8 @@ static BlockDriver bdrv_vxhs =3D { .bdrv_parse_filename =3D vxhs_parse_filename, .bdrv_close =3D vxhs_close, .bdrv_getlength =3D vxhs_getlength, - .bdrv_aio_readv =3D vxhs_aio_readv, - .bdrv_aio_writev =3D vxhs_aio_writev, + .bdrv_aio_preadv =3D vxhs_aio_preadv, + .bdrv_aio_pwritev =3D vxhs_aio_pwritev, }; static void bdrv_vxhs_init(void) --=20 2.14.3 From nobody Sun Oct 5 17:18:01 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.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 1518723236666579.5651142884465; Thu, 15 Feb 2018 11:33:56 -0800 (PST) Received: from localhost ([::1]:52283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPI3-0001s2-R8 for importer@patchew.org; Thu, 15 Feb 2018 14:33:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emPD9-0006Ff-GB for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emPD8-0000mE-DI for qemu-devel@nongnu.org; Thu, 15 Feb 2018 14:28:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49476 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 1emPD5-0000kp-Q5; Thu, 15 Feb 2018 14:28:47 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65163404085A; Thu, 15 Feb 2018 19:28:47 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF156F41A0; Thu, 15 Feb 2018 19:28:46 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 13:28:29 -0600 Message-Id: <20180215192829.9944-7-eblake@redhat.com> In-Reply-To: <20180215192829.9944-1-eblake@redhat.com> References: <20180215192829.9944-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Feb 2018 19:28:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Feb 2018 19:28:47 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@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 6/6] block: Drop last of the sector-based aio callbacks 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, Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz 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" We are gradually moving away from sector-based interfaces, towards byte-based. Now that all drivers with aio callbacks are using the byte-based interfaces, we can remove the sector-based versions. Signed-off-by: Eric Blake --- include/block/block_int.h | 6 ------ block/io.c | 23 ++++++----------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index c882dc4232d..0f5b7accfa8 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -134,15 +134,9 @@ struct BlockDriver { void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options); /* aio */ - BlockAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, - BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_preadv)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque); - BlockAIOCB *(*bdrv_aio_writev)(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, - BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque); diff --git a/block/io.c b/block/io.c index 84a4caa72b7..04239f01eef 100644 --- a/block/io.c +++ b/block/io.c @@ -948,13 +948,8 @@ static int coroutine_fn bdrv_driver_preadv(BlockDriver= State *bs, .coroutine =3D qemu_coroutine_self(), }; - if (drv->bdrv_aio_preadv) { - acb =3D bs->drv->bdrv_aio_preadv(bs, offset, bytes, qiov, flag= s, - bdrv_co_io_em_complete, &co); - } else { - acb =3D bs->drv->bdrv_aio_readv(bs, sector_num, qiov, nb_secto= rs, - bdrv_co_io_em_complete, &co); - } + acb =3D bs->drv->bdrv_aio_preadv(bs, offset, bytes, qiov, flags, + bdrv_co_io_em_complete, &co); if (acb =3D=3D NULL) { return -EIO; } else { @@ -1008,16 +1003,10 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDr= iverState *bs, .coroutine =3D qemu_coroutine_self(), }; - if (drv->bdrv_aio_pwritev) { - acb =3D bs->drv->bdrv_aio_pwritev(bs, offset, bytes, qiov, - flags & bs->supported_write_fl= ags, - bdrv_co_io_em_complete, &co); - flags &=3D ~bs->supported_write_flags; - } else { - assert(!bs->supported_write_flags); - acb =3D bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sect= ors, - bdrv_co_io_em_complete, &co); - } + acb =3D bs->drv->bdrv_aio_pwritev(bs, offset, bytes, qiov, + flags & bs->supported_write_flags, + bdrv_co_io_em_complete, &co); + flags &=3D ~bs->supported_write_flags; if (acb =3D=3D NULL) { ret =3D -EIO; } else { --=20 2.14.3