[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/23] block/block-copy: add block_copy_reset()
From: |
Hanna Reitz |
Subject: |
[PULL 12/23] block/block-copy: add block_copy_reset() |
Date: |
Mon, 7 Mar 2022 11:35:38 +0100 |
From: Vladimir Sementsov-Ogievskiy <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>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220303194349.2304213-6-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.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 b80ad02299..68bbd344b2 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -35,6 +35,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 8aa6ee6a5c..0834e29b6e 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -692,6 +692,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.
@@ -712,14 +724,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.34.1
- [PULL 00/23] Block patches, Hanna Reitz, 2022/03/07
- [PULL 05/23] tests/qemu-iotests/040: Skip TestCommitWithFilters without 'throttle', Hanna Reitz, 2022/03/07
- [PULL 04/23] block: fix preallocate filter: don't do unaligned preallocate requests, Hanna Reitz, 2022/03/07
- [PULL 01/23] ide: Increment BB in-flight counter for TRIM BH, Hanna Reitz, 2022/03/07
- [PULL 02/23] block/curl.c: Set error message string if curl_init_state() fails, Hanna Reitz, 2022/03/07
- [PULL 03/23] block/curl.c: Check error return from curl_easy_setopt(), Hanna Reitz, 2022/03/07
- [PULL 07/23] iotests: Write test output to TEST_DIR, Hanna Reitz, 2022/03/07
- [PULL 06/23] tests/qemu-iotests/testrunner: Quote "case not run" lines in TAP mode, Hanna Reitz, 2022/03/07
- [PULL 09/23] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value, Hanna Reitz, 2022/03/07
- [PULL 10/23] block/block-copy: block_copy_state_new(): add bitmap parameter, Hanna Reitz, 2022/03/07
- [PULL 12/23] block/block-copy: add block_copy_reset(),
Hanna Reitz <=
- [PULL 13/23] block: intoduce reqlist, Hanna Reitz, 2022/03/07
- [PULL 11/23] block/copy-before-write: add bitmap open parameter, Hanna Reitz, 2022/03/07
- [PULL 16/23] block/reqlist: add reqlist_wait_all(), Hanna Reitz, 2022/03/07
- [PULL 17/23] block/io: introduce block driver snapshot-access API, Hanna Reitz, 2022/03/07
- [PULL 22/23] iotests/image-fleecing: add test case with bitmap, Hanna Reitz, 2022/03/07
- [PULL 14/23] block/reqlist: reqlist_find_conflict(): use ranges_overlap(), Hanna Reitz, 2022/03/07
- [PULL 18/23] block: introduce snapshot-access block driver, Hanna Reitz, 2022/03/07
- [PULL 20/23] iotests/image-fleecing: add test-case for fleecing format node, Hanna Reitz, 2022/03/07
- [PULL 21/23] iotests.py: add qemu_io_pipe_and_status(), Hanna Reitz, 2022/03/07
- [PULL 15/23] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status(), Hanna Reitz, 2022/03/07