Re: [PATCH v2 01/11] qcow2: make function update_refcount_discard() global

2024-05-21 Thread Alexander Ivanov
x); void GRAPH_RDLOCK qcow2_process_discards(BlockDriverState *bs, int ret); +void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset, + uint64_t length); int GRAPH_RDLOCK qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, Reviewed-by:

Re: [PATCH v2 02/11] qcow2: simplify L2 entries accounting for discard-no-unref

2024-05-21 Thread Alexander Ivanov
} + if (old_l2_entry == new_l2_entry && old_l2_bitmap == new_l2_bitmap) { continue; } Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 03/11] qcow2: put discard requests in the common queue when discard-no-unref enabled

2024-05-21 Thread Alexander Ivanov
, old_l2_entry & L2E_OFFSET_MASK, -s->cluster_size); +discard_no_unref_any_file(bs, old_l2_entry & L2E_OFFSET_MASK, + s->cluster_size, type, + QCOW2_DISCAR

Re: [PATCH v2 04/11] block/file-posix: add trace event for fallocate() calls

2024-05-21 Thread Alexander Ivanov
t_off, int64_t bytes, int flags, int64_t ret) "bs %p src_fd %d offset %"PRIu64" dst_fd %d offset %"PRIu64" bytes %"PRIu64" flags %d ret %"PRId64 file_FindEjectableOpticalMedia(const char *media) "Matching using %s" file_setup_cdrom(const ch

Re: [PATCH v2 05/11] iotests/common.rc: add disk_usage function

2024-05-21 Thread Alexander Ivanov
1 "$1" | awk '{print $1}' +} + # Set the variables to the empty string to turn Valgrind off # for specific processes, e.g. # $ VALGRIND_QEMU_IO= ./check -qcow2 -valgrind 015 Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 06/11] iotests/290: add test case to check 'discard-no-unref' option behavior

2024-05-21 Thread Alexander Ivanov
at images are still identical +Images are identical. +# Output of qemu-img map for the image with dropped reference +[{ "start": 0, "length": 65536, "depth": 0, "present": true, "zero": false, "data": true, "compressed": false, "offset": OFFSET}, +{ "start": 65536, "length": 65536, "depth": 0, "present": true, "zero": true, "data": false, "compressed": false}] +# Output of qemu-img map for the image with kept reference +[{ "start": 0, "length": 65536, "depth": 0, "present": true, "zero": false, "data": true, "compressed": false, "offset": OFFSET}, +{ "start": 65536, "length": 65536, "depth": 0, "present": true, "zero": true, "data": false, "compressed": false, "offset": OFFSET}] *** done Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 07/11] qcow2: add get_sc_range_info() helper for working with subcluster ranges

2024-05-21 Thread Alexander Ivanov
->l2_table_cache, (void **) &l2_slice); - - return ret; +return 0; } int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset, Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 08/11] qcow2: zeroize the entire cluster when there're no non-zero subclusters

2024-05-21 Thread Alexander Ivanov
ubclusters(s, tail)); +ret = zero_l2_subclusters(bs, end_offset, + size_to_subclusters(s, tail), flags); if (ret < 0) { goto fail; } Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 09/11] qcow2: make subclusters discardable

2024-05-21 Thread Alexander Ivanov
# -# Test qcow2_cluster_discard() with full and normal discards +# Test qcow2_subcluster_discard() with full and normal discards for use_backing_file in yes no; do echo echo "### Discarding clusters with non-zero bitmaps (backing file: $use_backing_file) ###" Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 10/11] qcow2: zero_l2_subclusters: fall through to discard operation when requested

2024-05-21 Thread Alexander Ivanov
fset, nb_subclusters, &scri); if (ret < 0) { return ret; Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH v2 11/11] iotests/271: add test cases for subcluster-based discard/unmap

2024-05-21 Thread Alexander Ivanov
ize=1048576 +write -q -P PATTERN 0 32k +L2 entry #0: 0x8005 +discard -q 32k 32k +file_do_fallocate fd=N mode=0x03 offset=360448 len=32768 +L2 entry #0: 0x8005 +write -q -P PATTERN 0 64k +L2 entry #0: 0x8005 +discard -q 0 8

Re: [PATCH v3] block: Use LVM tools for LV block device truncation

2024-06-04 Thread Alexander Ivanov
ping 2 On 3/15/24 09:58, Alexander Ivanov wrote: If a block device is an LVM logical volume we can resize it using standard LVM tools. Add a helper to detect if a device is a DM device. In raw_co_truncate() check if the block device is DM and resize it executing lvresize. Signed-off-by

[PATCH] nbd: Prevent NULL pointer dereference in nbd_blockdev_client_closed()

2024-06-07 Thread Alexander Ivanov
NULL pointer dereference. Signed-off-by: Alexander Ivanov --- blockdev-nbd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 213012435f..fb1f30ae0d 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -52,6 +52,9 @@ int nbd_server_max_connections(void

Re: [PATCH] nbd: Prevent NULL pointer dereference in nbd_blockdev_client_closed()

2024-06-08 Thread Alexander Ivanov
There is a bug reproducer in the attachment. On 6/7/24 17:00, Alexander Ivanov wrote: In some cases, the NBD server can be stopped before nbd_blockdev_client_closed() is called, causing the nbd_server variable to be nullified. This leads to a NULL pointer dereference when accessing nbd_server

Re: [PATCH] nbd: Prevent NULL pointer dereference in nbd_blockdev_client_closed()

2024-06-10 Thread Alexander Ivanov
On 6/10/24 14:33, Eric Blake wrote: On Sat, Jun 08, 2024 at 11:36:59AM GMT, Alexander Ivanov wrote: There is a bug reproducer in the attachment. Summarizing the reproducer, you are repeatedly calling QMP nbd-server-start/nbd-server-stop on qemu as NBD server in one thread, and repeatedly

Re: [PATCH] nbd: Prevent NULL pointer dereference in nbd_blockdev_client_closed()

2024-06-18 Thread Alexander Ivanov
Hello Eric, Do you have any ideas about the bug? Thank you. On 6/10/24 14:33, Eric Blake wrote: On Sat, Jun 08, 2024 at 11:36:59AM GMT, Alexander Ivanov wrote: There is a bug reproducer in the attachment. Summarizing the reproducer, you are repeatedly calling QMP nbd-server-start/nbd-server

Re: [PATCH] nbd: Prevent NULL pointer dereference in nbd_blockdev_client_closed()

2024-06-28 Thread Alexander Ivanov
Ping? On 6/7/24 17:00, Alexander Ivanov wrote: static void nbd_blockdev_client_closed(NBDClient *client, bool ignored) { nbd_client_put(client); +if (nbd_server == NULL) { +return; +} assert(nbd_server->connections > 0); nbd_server->co

Re: [PATCH v3] block: Use LVM tools for LV block device truncation

2024-06-28 Thread Alexander Ivanov
One more ping... On 3/15/24 09:58, Alexander Ivanov wrote: If a block device is an LVM logical volume we can resize it using standard LVM tools. Add a helper to detect if a device is a DM device. In raw_co_truncate() check if the block device is DM and resize it executing lvresize. Signed-off

[PATCH v2 1/3] parallels: Put the image checks in separate functions

2022-08-05 Thread alexander . ivanov
From: Alexander Ivanov We will add more and more checks of images so we need to reorganize the code. Put each check to a separate helper function with a separate loop. Add two helpers: truncate_file() and sync_header(). They will be used in multiple functions. Signed-off-by: Alexander Ivanov

[PATCH v2 0/3] Check and repair duplicated clusters in parallels images

2022-08-05 Thread alexander . ivanov
From: Alexander Ivanov We will add more and more checks of images so we need to reorganize the code. Put each check to a separate helper function with a separate loop. Add two helpers: truncate_file() and sync_header(). They will be used in multiple functions. Parallels image file can be

[PATCH v2 2/3] parallels: Add checking and repairing duplicate offsets in BAT

2022-08-05 Thread alexander . ivanov
From: Alexander Ivanov There could be corruptions in the image file: two guest memory areas refer to the same host cluster. If a duplicate offset is found fix it by copying the content of the referred cluster to a new allocated cluster and replace one of the two referring entries by the new

[PATCH v2 3/3] iotests, parallels: Add a test for duplicated clusters

2022-08-05 Thread alexander . ivanov
From: Alexander Ivanov Check if original and duplicated offsets refer to the same cluster. Repair the image and check that writing to a referred cluster doesn't affects another referred cluster. Signed-off-by: Natalia Kuzmina Signed-off-by: Alexander Ivanov --- tests/qemu-iotest

[PATCH 0/9] parallels: Refactor the code of images checks and fix a bug

2022-08-08 Thread Alexander Ivanov
bdrv_co_pwrite_sync by bdrv_co_flush for writing to the disk only dirty blocks. Merge parallels_check_fragmentation to parallels_collect_statistics. Alexander Ivanov (9): parallels: Move check of unclean image to a separate function parallels: Move check of cluster outside image to a separate

[PATCH 3/9] parallels: Move check of leaks to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 96 --- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7b400ecdcc..6d4cfb738b 100644 --- a/block/parallels.c +++ b/block/parallels.c

[PATCH 1/9] parallels: Move check of unclean image to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..108aa907b8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -413,6 +413,23

[PATCH 4/9] parallels: Move check of fragmentation to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 38 +- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6d4cfb738b..0edbb812dd 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -530,12

[PATCH 7/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-08 Thread Alexander Ivanov
data_end field with the original file size if the image was opened for checking and repairing purposes or raise an error. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 + 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index

[PATCH 5/9] parallels: Move statistic collection to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 25 ++--- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 0edbb812dd..b0982d60d0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -553,13 +553,29

[PATCH 9/9] parallels: Merge parallels_check_fragmentation to parallels_collect_statistics

2022-08-08 Thread Alexander Ivanov
Frgamentation is a part of statistics so it is better to count the statistics in one function. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index

[PATCH 2/9] parallels: Move check of cluster outside image to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 76 +-- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 108aa907b8..7b400ecdcc 100644 --- a/block/parallels.c +++ b/block/parallels.c

[PATCH 8/9] parallels: Replace bdrv_co_pwrite_sync by bdrv_co_flush for BAT flushing

2022-08-08 Thread Alexander Ivanov
It's too costly to write all the BAT to the disk. Let the flush function write only dirty blocks. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 72cf7499c1..38b1482e81 1

[PATCH 6/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-08 Thread Alexander Ivanov
Replace the way that we use mutex in parallels_co_check() for more clean code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index b0982d60d0..3cb5452613 100644 --- a

[PATCH v2 3/8] parallels: Replace bdrv_co_pwrite_sync by bdrv_co_flush for BAT flushing

2022-08-11 Thread Alexander Ivanov
ne in parallels_co_check. Now we use a helper to set BAT entry and mark the block dirty. Signed-off-by: Alexander Ivanov --- block/parallels.c | 19 +++ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7f68f3cbc9..6879e

[PATCH v2 0/8] parallels: Refactor the code of images checks and fix a bug

2022-08-11 Thread Alexander Ivanov
Fix image inflation when offset in BAT is out of image. Replace whole BAT syncing by flushing only dirty blocks. Move all the checks outside the main check function in separate functions Use WITH_QEMU_LOCK_GUARD for more clean code. Alexander Ivanov (8): parallels: Out of image offset in BAT

[PATCH v2 1/8] parallels: Out of image offset in BAT leads to image inflation

2022-08-11 Thread Alexander Ivanov
data_end field with the original file size if the image was opened for checking and repairing purposes or raise an error. v2: No changes. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 + 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block

[PATCH v2 8/8] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-11 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for more clean code. v2: Fix an incorrect usage of WITH_QEMU_LOCK_GUARD. Signed-off-by: Alexander Ivanov --- block/parallels.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/block/parallels.c

[PATCH v2 7/8] parallels: Move statistic collection to a separate function

2022-08-11 Thread Alexander Ivanov
v2: Move fragmentation counting code to this function too. Signed-off-by: Alexander Ivanov --- block/parallels.c | 54 +++ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 8737eadfb4

[PATCH v2 4/8] parallels: Move check of unclean image to a separate function

2022-08-11 Thread Alexander Ivanov
v2: Revert the condition with s->header_unclean. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 +-- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6879ea4597..c53b2810cf 100644 --- a/bl

[PATCH v2 5/8] parallels: Move check of cluster outside image to a separate function

2022-08-11 Thread Alexander Ivanov
v2: Move unrelated helper parallels_set_bat_entry creation to a separate patch. Signed-off-by: Alexander Ivanov --- block/parallels.c | 48 ++- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c

[PATCH v2 2/8] parallels: Move BAT entry setting to a separate function

2022-08-11 Thread Alexander Ivanov
Will need to set BAT entry in multiple places. Move the code of settings entries and marking relevant blocks dirty to a separate helper parallels_set_bat_entry. v2: A new patch - a part of a splitted patch. Signed-off-by: Alexander Ivanov --- block/parallels.c | 12 +--- 1 file changed

[PATCH v2 6/8] parallels: Move check of leaks to a separate function

2022-08-11 Thread Alexander Ivanov
v2: No changes. Signed-off-by: Alexander Ivanov --- block/parallels.c | 85 +-- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 12104ba5ad..8737eadfb4 100644 --- a/block/parallels.c +++ b

[PATCH v3 2/8] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-15 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov --- v2: A new patch - a part of a splitted patch. v3: Fix commit message. block/parallels.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff

[PATCH v3 0/8] parallels: Refactor the code of images checks and fix a bug

2022-08-15 Thread Alexander Ivanov
Fix image inflation when offset in BAT is out of image. Replace whole BAT syncing by flushing only dirty blocks. Move all the checks outside the main check function in separate functions Use WITH_QEMU_LOCK_GUARD for simplier code. Alexander Ivanov (8): parallels: Out of image offset in BAT

[PATCH v3 3/8] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-15 Thread Alexander Ivanov
manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov --- v2: Patch order was changed so the replacement is done in parallels_co_check. Now we use a helper to set BAT

[PATCH v3 4/8] parallels: Move check of unclean image to a separate function

2022-08-15 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- v2: Revert the condition with s->header_unclean. v3: Fix commit message. block/parallels.c |

[PATCH v3 5/8] parallels: Move check of cluster outside image to a separate function

2022-08-15 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- v2: Move unrelated helper parallels_set_bat_entry creation to a separate patch. v3: Fix commit

[PATCH v3 1/8] parallels: Out of image offset in BAT leads to image inflation

2022-08-15 Thread Alexander Ivanov
-off-by: Alexander Ivanov --- v2: No change. v3: Fix commit message. block/parallels.c | 17 + 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..a76cf9d993 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -732,6 +732,7

[PATCH v3 6/8] parallels: Move check of leaks to a separate function

2022-08-15 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- v2: No change. v3: Fix commit message. block/parallels.c | 85

[PATCH v3 7/8] parallels: Move statistic collection to a separate function

2022-08-15 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- v2: Move fragmentation counting code to this function too. v3: Fix commit message. block/parallels.c

[PATCH v3 8/8] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-15 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov --- v2: Fix an incorrect usage of WITH_QEMU_LOCK_GUARD. v3: Fix commit message. block/parallels.c | 26 -- 1 file changed, 12 insertions(+), 14

[PATCH 00/10] parallels: Add duplication check, refactor, fix bugs

2022-08-17 Thread Alexander Ivanov
repairing duplicate offsets in BAT. Add tests for parallels format checks. Refactor and fix old parallels tests. Alexander Ivanov (10): parallels: Incorrect condition in out-of-image check parallels: Incorrect data end calculation in parallels_open parallels: Create parallels_handle_leak() to

[PATCH 01/10] parallels: Incorrect condition in out-of-image check

2022-08-17 Thread Alexander Ivanov
All the offsets in the BAT must be at least one cluster away from the end of the data area. Fix the check condition for correct check. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c

[PATCH 05/10] parallels: Use highest_offset() helper in leak check

2022-08-17 Thread Alexander Ivanov
Deduplicate code by using highest_offset() helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index bd129f44fa..93d21804f2 100644 --- a/block/parallels.c +++ b/block

[PATCH 04/10] parallels: Add checking and repairing duplicate offsets in BAT

2022-08-17 Thread Alexander Ivanov
deduplicate the code. Add highest_offset() helper. It will be used for code deduplication in the next patch. Signed-off-by: Alexander Ivanov --- block/parallels.c | 136 ++ 1 file changed, 136 insertions(+) diff --git a/block/parallels.c b/block

[PATCH 10/10] iotests: Fix cluster size in parallels images tests (131)

2022-08-17 Thread Alexander Ivanov
In this test cluster size is 64k, but modern tools generate images with cluster size 1M. Calculate cluster size using track field from image header. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/131 | 5 - tests/qemu-iotests/131.out | 44

[PATCH 06/10] iotests: Add out-of-image check test for parallels format

2022-08-17 Thread Alexander Ivanov
Fill the image with a pattern to generate entries in the BAT, set the first BAT entry outside the image, try to read the corrupted image, repair and check for zeroes in the first cluster. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/parallels-checks | 78

[PATCH 02/10] parallels: Incorrect data end calculation in parallels_open

2022-08-17 Thread Alexander Ivanov
t data_end contains the offset in bytes. Replace the alignment to sector size by division by sector size. Signed-off-by: Alexander Ivanov --- block/parallels.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index c42c955075..ce04a4da71 10

[PATCH 03/10] parallels: Create parallels_handle_leak() to truncate excess clusters

2022-08-17 Thread Alexander Ivanov
This helper will be reused in the next patch for duplications check. Signed-off-by: Alexander Ivanov --- block/parallels.c | 83 ++- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index ce04a4da71

[PATCH 07/10] iotests: Add leak check test for parallels format

2022-08-17 Thread Alexander Ivanov
Write a pattern to the last cluster, extend the image by 1 claster, repair and check that the last cluster still has the same pattern. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/parallels-checks | 27 +++ tests/qemu-iotests/tests/parallels-checks.out | 22

[PATCH 08/10] iotests: Add test for BAT entries duplication check

2022-08-17 Thread Alexander Ivanov
Fill the image with a pattern and write another pattern in the second cluster. Corrupt the image and check if the pattern changes. Repair the image and check the patterns on guest and host sides. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/parallels-checks | 31

[PATCH 09/10] iotests: Refactor tests of parallels images checks (131)

2022-08-17 Thread Alexander Ivanov
Replace hardcoded numbers by variables. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/131 | 29 - 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/qemu-iotests/131 b/tests/qemu-iotests/131 index a847692b4c..601546c84c 100755 --- a/tests

Re: [PATCH v3 2/8] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-18 Thread Alexander Ivanov
On 17.08.2022 21:21, Vladimir Sementsov-Ogievskiy wrote: On 8/15/22 12:02, Alexander Ivanov wrote: This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Vladimir Sementsov-Ogievskiy --- v2: A new

Re: [PATCH v3 1/8] parallels: Out of image offset in BAT leads to image inflation

2022-08-18 Thread Alexander Ivanov
On 17.08.2022 21:43, Vladimir Sementsov-Ogievskiy wrote: On 8/17/22 22:27, Denis V. Lunev wrote: On 17.08.2022 21:13, Vladimir Sementsov-Ogievskiy wrote: On 8/15/22 12:02, Alexander Ivanov wrote: data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this

Re: [PATCH v3 3/8] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-18 Thread Alexander Ivanov
On 17.08.2022 21:48, Vladimir Sementsov-Ogievskiy wrote: On 8/15/22 12:02, Alexander Ivanov wrote: BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but

Re: [PATCH v3 6/8] parallels: Move check of leaks to a separate function

2022-08-18 Thread Alexander Ivanov
On 17.08.2022 23:00, Vladimir Sementsov-Ogievskiy wrote: On 8/15/22 12:02, Alexander Ivanov wrote: We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov

[PATCH 2/9] parallels: Fix data_end field value in parallels_co_check()

2022-08-18 Thread Alexander Ivanov
When an image is opened for check there is no error if an offset in the BAT points outside the image. In such a way we can repair the image. Out-of-image offsets are repaired in the check, but data_end field still points outside. Fix this field by file size. Signed-off-by: Alexander Ivanov

[PATCH 0/9] parallels: Refactor the code of images checks and fix a bug

2022-08-18 Thread Alexander Ivanov
eck(). Split the check in parallels_open() and the fix in parallels_co_check() to two patches. Move offset convertation to parallels_set_bat_entry(). Fix 'ret' rewriting by bdrv_co_flush() results. Keep 'i' as uint32_t. Alexander Ivanov (9): parallels: Out of image

[PATCH 4/9] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-18 Thread Alexander Ivanov
manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov --- block/parallels.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a

[PATCH 1/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-18 Thread Alexander Ivanov
parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Signed-off-by: Alexander Ivanov --- block/parallels.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..c245ca35cd

[PATCH 3/9] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-18 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 24c05b95e8

[PATCH 6/9] parallels: Move check of cluster outside image to a separate function

2022-08-18 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. s->data_end fix relates to out-of-image check so move it to the helper too. Signed-off-by: Alexander Ivanov --- block/parallels.c |

[PATCH 5/9] parallels: Move check of unclean image to a separate function

2022-08-18 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 +-- 1 file changed, 21 insertions(+), 10 deletions

[PATCH 7/9] parallels: Move check of leaks to a separate function

2022-08-18 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 84 +-- 1 file changed, 52 insertions

[PATCH 8/9] parallels: Move statistic collection to a separate function

2022-08-18 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 53 +++ 1 file changed, 31 insertions

[PATCH 9/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-18 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index

[PATCH v5 0/9] parallels: Refactor the code of images checks and fix a bug

2022-08-22 Thread Alexander Ivanov
use a helper to set BAT entry and mark the block dirty. 4: Revert the condition with s->header_unclean. 5: Move unrelated helper parallels_set_bat_entry creation to a separate patch. 7: Move fragmentation counting code to this function too. 8: Fix an incorrect usage of WITH_QEMU_LOCK_G

[PATCH v5 1/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-22 Thread Alexander Ivanov
parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Signed-off-by: Alexander Ivanov --- block/parallels.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..c245ca35cd

[PATCH v5 3/9] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-22 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions

[PATCH v5 4/9] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-22 Thread Alexander Ivanov
manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov --- block/parallels.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a

[PATCH v5 6/9] parallels: Move check of cluster outside image to a separate function

2022-08-22 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 50

[PATCH v5 5/9] parallels: Move check of unclean image to a separate function

2022-08-22 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31

[PATCH v5 7/9] parallels: Move check of leaks to a separate function

2022-08-22 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 87 +-- 1 file changed, 54 insertions

[PATCH v5 9/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-22 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++--- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block

[PATCH v5 8/9] parallels: Move statistic collection to a separate function

2022-08-22 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53

[PATCH v5 2/9] parallels: Fix data_end field value in parallels_co_check()

2022-08-22 Thread Alexander Ivanov
Make data_end pointing to the end of the last cluster if a leak was fixed. Otherwise set the file size to data_end. Signed-off-by: Alexander Ivanov --- block/parallels.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index

Re: [PATCH v5 1/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 08:58, Vladimir Sementsov-Ogievskiy wrote: On 8/22/22 12:05, Alexander Ivanov wrote: data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the

Re: [PATCH v5 2/9] parallels: Fix data_end field value in parallels_co_check()

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 09:38, Vladimir Sementsov-Ogievskiy wrote: On 8/22/22 12:05, Alexander Ivanov wrote: Make data_end pointing to the end of the last cluster if a leak was fixed. Otherwise set the file size to data_end. Signed-off-by: Alexander Ivanov ---   block/parallels.c | 10 +-   1

Re: [PATCH v5 1/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 11:20, Denis V. Lunev wrote: On 23.08.2022 09:23, Alexander Ivanov wrote: On 23.08.2022 08:58, Vladimir Sementsov-Ogievskiy wrote: On 8/22/22 12:05, Alexander Ivanov wrote: data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is

Re: [PATCH v5 7/9] parallels: Move check of leaks to a separate function

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 11:40, Denis V. Lunev wrote: On 22.08.2022 11:05, Alexander Ivanov wrote: We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov ---   block

Re: [PATCH v5 1/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 11:58, Vladimir Sementsov-Ogievskiy wrote: On 8/23/22 12:20, Denis V. Lunev wrote: On 23.08.2022 09:23, Alexander Ivanov wrote: On 23.08.2022 08:58, Vladimir Sementsov-Ogievskiy wrote: On 8/22/22 12:05, Alexander Ivanov wrote: data_end field in BDRVParallelsState is set to

[PATCH v6 07/10] parallels: Move check of cluster outside image to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 59 ++- 1 file changed, 43 insertions

[PATCH v6 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-25 Thread Alexander Ivanov
manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 23 ++- 1 file changed, 10 insertions(+), 13

[PATCH v6 03/10] parallels: Fix data_end after out-of-image check

2022-08-25 Thread Alexander Ivanov
Set data_end to the end of the last cluster inside the image. In such a way we can be shure that corrupted offsets in the BAT can't affect on the image size. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/parallels.c b/

[PATCH v6 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-25 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff

[PATCH v6 00/10] parallels: Refactor the code of images checks and fix a bug

2022-08-25 Thread Alexander Ivanov
tation counting code to this function too. 8: Fix an incorrect usage of WITH_QEMU_LOCK_GUARD. Alexander Ivanov (10): parallels: Out of image offset in BAT leads to image inflation parallels: Fix high_off calculation in parallels_co_check() parallels: Fix data_end after out-of-image check para

[PATCH v6 08/10] parallels: Move check of leaks to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 84 +-- 1 file changed, 52 insertions

[PATCH v6 06/10] parallels: Move check of unclean image to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31

[PATCH v6 01/10] parallels: Out of image offset in BAT leads to image inflation

2022-08-25 Thread Alexander Ivanov
parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Set data_end to the end of the cluster with the last correct offset. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 + 1 file changed, 17 insertions(+) diff --git

[PATCH v6 09/10] parallels: Move statistic collection to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53

[PATCH v6 02/10] parallels: Fix high_off calculation in parallels_co_check()

2022-08-25 Thread Alexander Ivanov
Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 93bc2750ef..7e8cdbbc3a 100644 -

  1   2   3   4   5   >