All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, armbru@redhat.com,
	xiechanglong.d@gmail.com, wencongyang2@huawei.com,
	eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com,
	vsementsov@virtuozzo.com, jsnow@redhat.com,
	nikita.lapshin@virtuozzo.com
Subject: [PATCH v3 05/19] block/block-copy: add block_copy_reset()
Date: Wed, 22 Dec 2021 18:40:04 +0100	[thread overview]
Message-ID: <20211222174018.257550-6-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com>

Split block_copy_reset() out of block_copy_reset_unallocated() to be
used separately later.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/block/block-copy.h |  1 +
 block/block-copy.c         | 21 +++++++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/block/block-copy.h b/include/block/block-copy.h
index 8da4cec1b6..a11e1620f6 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -34,6 +34,7 @@ void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm);
 
 void block_copy_state_free(BlockCopyState *s);
 
+void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes);
 int64_t block_copy_reset_unallocated(BlockCopyState *s,
                                      int64_t offset, int64_t *count);
 
diff --git a/block/block-copy.c b/block/block-copy.c
index f6345e3a4c..6228cf01d4 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -690,6 +690,18 @@ static int block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offset,
     }
 }
 
+void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes)
+{
+    QEMU_LOCK_GUARD(&s->lock);
+
+    bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes);
+    if (s->progress) {
+        progress_set_remaining(s->progress,
+                               bdrv_get_dirty_count(s->copy_bitmap) +
+                               s->in_flight_bytes);
+    }
+}
+
 /*
  * Reset bits in copy_bitmap starting at offset if they represent unallocated
  * data in the image. May reset subsequent contiguous bits.
@@ -710,14 +722,7 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s,
     bytes = clusters * s->cluster_size;
 
     if (!ret) {
-        qemu_co_mutex_lock(&s->lock);
-        bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes);
-        if (s->progress) {
-            progress_set_remaining(s->progress,
-                                   bdrv_get_dirty_count(s->copy_bitmap) +
-                                   s->in_flight_bytes);
-        }
-        qemu_co_mutex_unlock(&s->lock);
+        block_copy_reset(s, offset, bytes);
     }
 
     *count = bytes;
-- 
2.31.1



  parent reply	other threads:[~2021-12-22 17:51 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 17:39 [PATCH v3 00/19] Make image fleecing more usable Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 01/19] block/block-copy: move copy_bitmap initialization to block_copy_state_new() Vladimir Sementsov-Ogievskiy
2022-01-14 16:54   ` Hanna Reitz
2021-12-22 17:40 ` [PATCH v3 02/19] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value Vladimir Sementsov-Ogievskiy
2022-01-14 16:55   ` Hanna Reitz
2021-12-22 17:40 ` [PATCH v3 03/19] block/block-copy: block_copy_state_new(): add bitmap parameter Vladimir Sementsov-Ogievskiy
2022-01-14 16:58   ` Hanna Reitz
2021-12-22 17:40 ` [PATCH v3 04/19] block/copy-before-write: add bitmap open parameter Vladimir Sementsov-Ogievskiy
2022-01-14 17:47   ` Hanna Reitz
2022-01-17 11:36     ` Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` Vladimir Sementsov-Ogievskiy [this message]
2022-01-14 17:51   ` [PATCH v3 05/19] block/block-copy: add block_copy_reset() Hanna Reitz
2021-12-22 17:40 ` [PATCH v3 06/19] block: intoduce reqlist Vladimir Sementsov-Ogievskiy
2022-01-14 18:20   ` Hanna Reitz
2021-12-22 17:40 ` [PATCH v3 07/19] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status() Vladimir Sementsov-Ogievskiy
2022-01-17 10:06   ` Nikta Lapshin
2022-01-17 12:02     ` Vladimir Sementsov-Ogievskiy
2022-01-18 13:31   ` Hanna Reitz
2022-01-26 10:56     ` Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 08/19] block/reqlist: add reqlist_wait_all() Vladimir Sementsov-Ogievskiy
2022-01-17 12:34   ` Nikta Lapshin
2022-01-18 13:44   ` Hanna Reitz
2021-12-22 17:40 ` [PATCH v3 09/19] block: introduce FleecingState class Vladimir Sementsov-Ogievskiy
2022-01-18 16:37   ` Hanna Reitz
2022-01-18 18:35     ` Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 10/19] block: introduce fleecing block driver Vladimir Sementsov-Ogievskiy
2022-01-20 16:11   ` Hanna Reitz
2022-01-21 10:46     ` Vladimir Sementsov-Ogievskiy
2022-01-27 15:28       ` Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 11/19] block/copy-before-write: support " Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 12/19] block/block-copy: add write-unchanged mode Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 13/19] block/copy-before-write: use write-unchanged in fleecing mode Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 14/19] iotests/image-fleecing: add test-case for fleecing format node Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 15/19] iotests.py: add qemu_io_pipe_and_status() Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 16/19] iotests/image-fleecing: add test case with bitmap Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 17/19] block: blk_root(): return non-const pointer Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 18/19] qapi: backup: add immutable-source parameter Vladimir Sementsov-Ogievskiy
2021-12-22 17:40 ` [PATCH v3 19/19] iotests/image-fleecing: test push backup with fleecing Vladimir Sementsov-Ogievskiy

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=20211222174018.257550-6-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=nikita.lapshin@virtuozzo.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wencongyang2@huawei.com \
    --cc=xiechanglong.d@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.