qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, eblake@redhat.com, mreitz@redhat.com,
	kwolf@redhat.com, pbonzini@redhat.com, fam@euphon.net,
	stefanha@redhat.com, den@openvz.org, vsementsov@virtuozzo.com
Subject: [Qemu-devel] [PATCH] file-posix: add rough-block-status parameter
Date: Tue,  8 Jan 2019 22:45:52 +0300	[thread overview]
Message-ID: <20190108194552.45453-1-vsementsov@virtuozzo.com> (raw)

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 <vsementsov@virtuozzo.com>
---

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 image
 #                         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 whole
+#                      file is data and do not try to find holes through system
+#                      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' } }
 
 ##
 # @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;
 
     PRManager *pr_mgr;
 } BDRVRawState;
@@ -439,6 +440,13 @@ static QemuOptsList raw_runtime_opts = {
             .type = QEMU_OPT_BOOL,
             .help = "check that page cache was dropped on live migration (default: off)"
         },
+        {
+            .name = "rough-block-status",
+            .type = QEMU_OPT_BOOL,
+            .help = "If set, on block-status querying assume that the whole "
+                    "file is data and do not try to find holes through system "
+                    "calls (default: off)"
+        },
         { /* end of list */ }
     },
 };
@@ -525,6 +533,8 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
 
     s->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
                                                false);
+    s->rough_block_status = qemu_opt_get_bool(opts, "rough-block-status",
+                                              false);
 
     s->open_flags = open_flags;
     raw_parse_flags(bdrv_flags, &s->open_flags);
@@ -2424,6 +2434,7 @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
                                             int64_t *map,
                                             BlockDriverState **file)
 {
+    BDRVRawState *s = bs->opaque;
     off_t data = 0, hole = 0;
     int ret;
 
@@ -2432,7 +2443,7 @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
         return ret;
     }
 
-    if (!want_zero) {
+    if (!want_zero || s->rough_block_status) {
         *pnum = bytes;
         *map = offset;
         *file = bs;
-- 
2.18.0

             reply	other threads:[~2019-01-08 19:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08 19:45 Vladimir Sementsov-Ogievskiy [this message]
2019-01-08 20:11 ` [Qemu-devel] [PATCH] file-posix: add rough-block-status parameter Eric Blake
2019-01-09 11:23 ` Kevin Wolf
2019-01-09 16:42   ` Paolo Bonzini
2019-01-09 16:51     ` Kevin Wolf
2019-01-09 16:55       ` Paolo Bonzini
2019-01-09 17:09         ` Kevin Wolf
2019-01-09 18:09           ` Denis V.Lunev
2019-01-09 17:00       ` Eric Blake
2019-01-09 12:33 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190108194552.45453-1-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).