[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re [PATCH v3 08/11] mirror: Skip writing zeroes when target is already z
From: |
Sunny Zhu |
Subject: |
Re [PATCH v3 08/11] mirror: Skip writing zeroes when target is already zero |
Date: |
Thu, 1 May 2025 00:38:30 +0800 |
on Thu 24 Apr 2025 19:52:08 -0500, Eric wrote:
> if (s->zero_target) {
> + int64_t bitmap_length = DIV_ROUND_UP(s->bdev_length, s->granularity);
> +
> offset = 0;
> bdrv_graph_co_rdlock();
> ret = bdrv_co_is_all_zeroes(target_bs);
> @@ -856,6 +898,7 @@ static int coroutine_fn GRAPH_UNLOCKED
> mirror_dirty_init(MirrorBlockJob *s)
> if (ret < 0) {
> return ret;
> }
> + s->zero_bitmap = bitmap_new(bitmap_length);
> /*
> * If the destination already reads as zero, and we are not
> * requested to punch holes into existing zeroes, then we can
> @@ -864,6 +907,7 @@ static int coroutine_fn GRAPH_UNLOCKED
> mirror_dirty_init(MirrorBlockJob *s)
> if (ret > 0 &&
> (target_bs->detect_zeroes !=
> BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP ||
> !bdrv_can_write_zeroes_with_unmap(target_bs))) {
> + bitmap_set(s->zero_bitmap, 0, bitmap_length);
when arg->mode != NEW_IMAGE_MODE_EXISTING && bdrv_has_zero_init(target_bs) is
true
in drive_mirror (This means the target image is newly created), in which case
s->zero_target == false, we still need to execute bitmap_set(s->zero_bitmap, 0,
bitmap_length)
> offset = s->bdev_length;
> }
> if (!bdrv_can_write_zeroes_with_unmap(target_bs)) {
> @@ -875,6 +919,7 @@ static int coroutine_fn GRAPH_UNLOCKED
> mirror_dirty_init(MirrorBlockJob *s)
> while (offset < s->bdev_length) {
> int bytes = MIN(s->bdev_length - offset,
> QEMU_ALIGN_DOWN(INT_MAX, s->granularity));
- [PATCH v3 00/11] Make blockdev-mirror dest sparse in more cases, Eric Blake, 2025/04/24
- [PATCH v3 01/11] block: Expand block status mode from bool to flags, Eric Blake, 2025/04/24
- [PATCH v3 02/11] file-posix, gluster: Handle zero block status hint better, Eric Blake, 2025/04/24
- [PATCH v3 03/11] block: Let bdrv_co_is_zero_fast consolidate adjacent extents, Eric Blake, 2025/04/24
- [PATCH v3 04/11] block: Add new bdrv_co_is_all_zeroes() function, Eric Blake, 2025/04/24
- [PATCH v3 05/11] iotests: Improve iotest 194 to mirror data, Eric Blake, 2025/04/24
- [PATCH v3 06/11] mirror: Minor refactoring, Eric Blake, 2025/04/24
- [PATCH v3 07/11] mirror: Skip pre-zeroing destination if it is already zero, Eric Blake, 2025/04/24
- [PATCH v3 08/11] mirror: Skip writing zeroes when target is already zero, Eric Blake, 2025/04/24
- Re [PATCH v3 08/11] mirror: Skip writing zeroes when target is already zero,
Sunny Zhu <=
- [PATCH v3 09/11] iotests/common.rc: add disk_usage function, Eric Blake, 2025/04/24
- [PATCH v3 10/11] tests: Add iotest mirror-sparse for recent patches, Eric Blake, 2025/04/24
- [PATCH v3 11/11] mirror: Allow QMP override to declare target already zero, Eric Blake, 2025/04/24