From nobody Sun Oct 5 19:23:35 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 1524607413355101.27127284134463; Tue, 24 Apr 2018 15:03:33 -0700 (PDT) Received: from localhost ([::1]:32790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB628-0003wJ-I6 for importer@patchew.org; Tue, 24 Apr 2018 18:03:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB60x-0003Ur-3Z for qemu-devel@nongnu.org; Tue, 24 Apr 2018 18:02:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB60v-0005bI-Kl for qemu-devel@nongnu.org; Tue, 24 Apr 2018 18:02:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47648 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 1fB60m-0005X4-RT; Tue, 24 Apr 2018 18:02:08 -0400 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 4B0B740858C0; Tue, 24 Apr 2018 22:02:08 +0000 (UTC) Received: from red.redhat.com (ovpn-122-114.rdu2.redhat.com [10.10.122.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id E62447C3C; Tue, 24 Apr 2018 22:02:01 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 17:01:57 -0500 Message-Id: <20180424220157.177385-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]); Tue, 24 Apr 2018 22:02:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 24 Apr 2018 22:02:08 +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] block: Merge .bdrv_co_writev{, _flags} in drivers 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: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , "open list:GLUSTER" , Hitoshi Mitake , Wen Congyang , Jeff Cody , Peter Lieven , "Richard W.M. Jones" , Max Reitz , "open list:Sheepdog" , Ronnie Sahlberg , "Denis V. Lunev" , Paolo Bonzini , Liu Yuan , Xie Changlong 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 have too many driver callback interfaces; simplify the mess somewhat by merging the flags parameter of .bdrv_co_writev_flags() into .bdrv_co_writev_flags(). Note that as long as a driver doesn't set .supported_write_flags, the flags argument will be 0 and behavior is identical. Also note that the public function bdrv_co_writev() still lacks a flags argument; so the driver signature is thus intentionally slightly different. But that's not the end of the world, nor the first time that the driver interface differs slightly from the public interface. Ideally, we should be rewriting all of these drivers to use modern byte-based interfaces. But that's a more invasive patch to write and audit, compared to the simplification done here. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrang=C3=A9 --- Based-on: <20180424192506.149089-1-eblake@redhat.com> ([PATCH v2 0/6] block: byte-based AIO read/write) include/block/block_int.h | 2 -- block/io.c | 13 ++++--------- block/gluster.c | 4 +++- block/iscsi.c | 8 ++++---- block/parallels.c | 4 +++- block/qcow.c | 6 ++++-- block/qed.c | 3 ++- block/replication.c | 4 +++- block/sheepdog.c | 4 +++- block/ssh.c | 4 +++- block/vhdx.c | 4 +++- 11 files changed, 32 insertions(+), 24 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 0bba7ed024a..e3d6219f4e3 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -174,8 +174,6 @@ struct BlockDriver { int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); - int coroutine_fn (*bdrv_co_writev_flags)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); /** * @offset: position in bytes to write at diff --git a/block/io.c b/block/io.c index 6b110b207a0..4fad5ac2fef 100644 --- a/block/io.c +++ b/block/io.c @@ -1000,15 +1000,10 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDr= iverState *bs, 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, - flags & bs->supported_write_flags); - flags &=3D ~bs->supported_write_flags; - } else { - assert(drv->bdrv_co_writev); - assert(!bs->supported_write_flags); - ret =3D drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); - } + assert(drv->bdrv_co_writev); + ret =3D drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov, + flags & bs->supported_write_flags); + flags &=3D ~bs->supported_write_flags; emulate_flags: if (ret =3D=3D 0 && (flags & BDRV_REQ_FUA)) { diff --git a/block/gluster.c b/block/gluster.c index 4adc1a875b1..15e7d7fc351 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1194,8 +1194,10 @@ static coroutine_fn int qemu_gluster_co_readv(BlockD= riverState *bs, static coroutine_fn int qemu_gluster_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, - QEMUIOVector *qiov) + QEMUIOVector *qiov, + int flags) { + assert(!flags); return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 1); } diff --git a/block/iscsi.c b/block/iscsi.c index f5aecfc8834..35423ded03b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -556,8 +556,8 @@ static inline bool iscsi_allocmap_is_valid(IscsiLun *is= csilun, } static int coroutine_fn -iscsi_co_writev_flags(BlockDriverState *bs, int64_t sector_num, int nb_sec= tors, - QEMUIOVector *iov, int flags) +iscsi_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, + QEMUIOVector *iov, int flags) { IscsiLun *iscsilun =3D bs->opaque; struct IscsiTask iTask; @@ -2220,7 +2220,7 @@ static BlockDriver bdrv_iscsi =3D { .bdrv_co_pdiscard =3D iscsi_co_pdiscard, .bdrv_co_pwrite_zeroes =3D iscsi_co_pwrite_zeroes, .bdrv_co_readv =3D iscsi_co_readv, - .bdrv_co_writev_flags =3D iscsi_co_writev_flags, + .bdrv_co_writev =3D iscsi_co_writev, .bdrv_co_flush_to_disk =3D iscsi_co_flush, #ifdef __linux__ @@ -2255,7 +2255,7 @@ static BlockDriver bdrv_iser =3D { .bdrv_co_pdiscard =3D iscsi_co_pdiscard, .bdrv_co_pwrite_zeroes =3D iscsi_co_pwrite_zeroes, .bdrv_co_readv =3D iscsi_co_readv, - .bdrv_co_writev_flags =3D iscsi_co_writev_flags, + .bdrv_co_writev =3D iscsi_co_writev, .bdrv_co_flush_to_disk =3D iscsi_co_flush, #ifdef __linux__ diff --git a/block/parallels.c b/block/parallels.c index 799215e079f..3f74fcb877a 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -311,13 +311,15 @@ static int coroutine_fn parallels_co_block_status(Blo= ckDriverState *bs, } static coroutine_fn int parallels_co_writev(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) + int64_t sector_num, int nb_sec= tors, + QEMUIOVector *qiov, int flags) { BDRVParallelsState *s =3D bs->opaque; uint64_t bytes_done =3D 0; QEMUIOVector hd_qiov; int ret =3D 0; + assert(!flags); qemu_iovec_init(&hd_qiov, qiov->niov); while (nb_sectors > 0) { diff --git a/block/qcow.c b/block/qcow.c index f92891676c9..dd042b8ddbe 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -720,7 +720,8 @@ static coroutine_fn int qcow_co_readv(BlockDriverState = *bs, int64_t sector_num, } static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t secto= r_num, - int nb_sectors, QEMUIOVector *qiov) + int nb_sectors, QEMUIOVector *qiov, + int flags) { BDRVQcowState *s =3D bs->opaque; int index_in_cluster; @@ -731,6 +732,7 @@ static coroutine_fn int qcow_co_writev(BlockDriverState= *bs, int64_t sector_num, uint8_t *buf; void *orig_buf; + assert(!flags); s->cluster_cache_offset =3D -1; /* disable compressed cache */ /* We must always copy the iov when encrypting, so we @@ -1110,7 +1112,7 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint= 64_t offset, if (ret !=3D Z_STREAM_END || out_len >=3D s->cluster_size) { /* could not compress: write normal cluster */ ret =3D qcow_co_writev(bs, offset >> BDRV_SECTOR_BITS, - bytes >> BDRV_SECTOR_BITS, qiov); + bytes >> BDRV_SECTOR_BITS, qiov, 0); if (ret < 0) { goto fail; } diff --git a/block/qed.c b/block/qed.c index 35ff505066f..a3600bd2d07 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1437,8 +1437,9 @@ static int coroutine_fn bdrv_qed_co_readv(BlockDriver= State *bs, static int coroutine_fn bdrv_qed_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sect= ors, - QEMUIOVector *qiov) + QEMUIOVector *qiov, int flags) { + assert(!flags); return qed_co_request(bs, sector_num, qiov, nb_sectors, QED_AIOCB_WRIT= E); } diff --git a/block/replication.c b/block/replication.c index 6c0c7186d9a..48148b884a5 100644 --- a/block/replication.c +++ b/block/replication.c @@ -260,7 +260,8 @@ out: static coroutine_fn int replication_co_writev(BlockDriverState *bs, int64_t sector_num, int remaining_sectors, - QEMUIOVector *qiov) + QEMUIOVector *qiov, + int flags) { BDRVReplicationState *s =3D bs->opaque; QEMUIOVector hd_qiov; @@ -271,6 +272,7 @@ static coroutine_fn int replication_co_writev(BlockDriv= erState *bs, int ret; int64_t n; + assert(!flags); ret =3D replication_get_io_status(s); if (ret < 0) { goto out; diff --git a/block/sheepdog.c b/block/sheepdog.c index 387f59c8aa5..a2f26efc0e2 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2612,13 +2612,15 @@ static void sd_aio_complete(SheepdogAIOCB *acb) } static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_= num, - int nb_sectors, QEMUIOVector *qiov) + int nb_sectors, QEMUIOVector *qiov, + int flags) { SheepdogAIOCB acb; int ret; int64_t offset =3D (sector_num + nb_sectors) * BDRV_SECTOR_SIZE; BDRVSheepdogState *s =3D bs->opaque; + assert(!flags); if (offset > s->inode.vdi_size) { ret =3D sd_truncate(bs, offset, PREALLOC_MODE_OFF, NULL); if (ret < 0) { diff --git a/block/ssh.c b/block/ssh.c index ab3acf0c228..e8ad3d4c46a 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1164,11 +1164,13 @@ static int ssh_write(BDRVSSHState *s, BlockDriverSt= ate *bs, static coroutine_fn int ssh_co_writev(BlockDriverState *bs, int64_t sector_num, - int nb_sectors, QEMUIOVector *qiov) + int nb_sectors, QEMUIOVector *qiov, + int flags) { BDRVSSHState *s =3D bs->opaque; int ret; + assert(!flags); qemu_co_mutex_lock(&s->lock); ret =3D ssh_write(s, bs, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE, qiov); diff --git a/block/vhdx.c b/block/vhdx.c index 6ac0424f61a..0b72d895db4 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1226,7 +1226,8 @@ int vhdx_user_visible_write(BlockDriverState *bs, BDR= VVHDXState *s) } static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t secto= r_num, - int nb_sectors, QEMUIOVector *qiov) + int nb_sectors, QEMUIOVector *qiov, + int flags) { int ret =3D -ENOTSUP; BDRVVHDXState *s =3D bs->opaque; @@ -1242,6 +1243,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverSta= te *bs, int64_t sector_num, uint64_t bat_prior_offset =3D 0; bool bat_update =3D false; + assert(!flags); qemu_iovec_init(&hd_qiov, qiov->niov); qemu_co_mutex_lock(&s->lock); --=20 2.14.3