From nobody Fri Nov 7 05:42:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 154697686741486.22063429499917; Tue, 8 Jan 2019 11:47:47 -0800 (PST) Received: from localhost ([127.0.0.1]:49421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggxLZ-0003ky-95 for importer@patchew.org; Tue, 08 Jan 2019 14:47:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggxK6-00039J-IS for qemu-devel@nongnu.org; Tue, 08 Jan 2019 14:46:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggxK2-0003dc-JN for qemu-devel@nongnu.org; Tue, 08 Jan 2019 14:46:00 -0500 Received: from relay.sw.ru ([185.231.240.75]:53260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggxK2-0003Tj-6M; Tue, 08 Jan 2019 14:45:58 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1ggxJw-0001YF-SN; Tue, 08 Jan 2019 22:45:53 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 8 Jan 2019 22:45:52 +0300 Message-Id: <20190108194552.45453-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH] file-posix: add rough-block-status parameter 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@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_co_block_status digs bs->file for additional, more accurate search for hole inside region, reported as DATA by bs since 5daa74a6ebc. This accuracy is not free: assume we have qcow2 disk. Actually, qcow2 knows, where are holes and where is data. But every block_status request calls lseek additionally. Assume a big disk, full of data, in any iterative copying block job (or img convert) we'll call lseek(HOLE) on every iteration, and each of these lseeks will have to iterate through all metadata up to the end of file. It's obviously ineffective behavior. And for many scenarios we don't need this lseek at all. So, add an option to omit calling lseek. Signed-off-by: Vladimir Sementsov-Ogievskiy --- Hi all! This is a continuation of "do not lseek in qcow2 block_status" thread (https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg05749.html) qapi/block-core.json | 6 +++++- block/file-posix.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 762000f31f..ec5549e5c2 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2645,6 +2645,9 @@ # migration. May cause noticeable delays if the i= mage # file is large, do not use in production. # (default: off) (since: 3.0) +# @rough-block-status: If set, on block-status querying assume that the wh= ole +# file is data and do not try to find holes through s= ystem +# calls (default: off) (since 4.0) # # Since: 2.9 ## @@ -2653,7 +2656,8 @@ '*pr-manager': 'str', '*locking': 'OnOffAuto', '*aio': 'BlockdevAioOptions', - '*x-check-cache-dropped': 'bool' } } + '*x-check-cache-dropped': 'bool', + '*rough-block-status': 'bool' } } =20 ## # @BlockdevOptionsNull: diff --git a/block/file-posix.c b/block/file-posix.c index d8f0b93752..3f6d76a5dc 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -167,6 +167,7 @@ typedef struct BDRVRawState { bool has_fallocate; bool needs_alignment; bool check_cache_dropped; + bool rough_block_status; =20 PRManager *pr_mgr; } BDRVRawState; @@ -439,6 +440,13 @@ static QemuOptsList raw_runtime_opts =3D { .type =3D QEMU_OPT_BOOL, .help =3D "check that page cache was dropped on live migration= (default: off)" }, + { + .name =3D "rough-block-status", + .type =3D QEMU_OPT_BOOL, + .help =3D "If set, on block-status querying assume that the wh= ole " + "file is data and do not try to find holes through sys= tem " + "calls (default: off)" + }, { /* end of list */ } }, }; @@ -525,6 +533,8 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, =20 s->check_cache_dropped =3D qemu_opt_get_bool(opts, "x-check-cache-drop= ped", false); + s->rough_block_status =3D qemu_opt_get_bool(opts, "rough-block-status", + false); =20 s->open_flags =3D open_flags; raw_parse_flags(bdrv_flags, &s->open_flags); @@ -2424,6 +2434,7 @@ static int coroutine_fn raw_co_block_status(BlockDriv= erState *bs, int64_t *map, BlockDriverState **file) { + BDRVRawState *s =3D bs->opaque; off_t data =3D 0, hole =3D 0; int ret; =20 @@ -2432,7 +2443,7 @@ static int coroutine_fn raw_co_block_status(BlockDriv= erState *bs, return ret; } =20 - if (!want_zero) { + if (!want_zero || s->rough_block_status) { *pnum =3D bytes; *map =3D offset; *file =3D bs; --=20 2.18.0