Skip to contentSkip to conversation

Fix wipe of unaligned qcow2 image [was add blkdebug tests]

PATCH Superseded Eric Blake 2 participants 9 messages Mar 30, 2017 – Mar 31, 2017 Block layer

v7 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

v7 cover Fix wipe of unaligned qcow2 image [was add blkdebug tests]

Available as a tag at:
git fetch git://repo.or.cz/qemu/ericb.git nbd-blkdebug-v7

(which is somewhat of a misnomer for this current version of the series, but historically correct)

v6 was:
https://lists.gnu.org/archive/html/qemu-devel/2017-03/msg01562.html

In that version, Kevin said patches 1 and 2 might be 2.9 material, even if the rest of the series was 2.10 material. But in reviewing patch 2, Max pointed out that my test didn't exercise a particular corner case - and sure enough, improving the test showed that we have a (minor) bug. We don't discard as much of an unaligned image as desired when discard goes through the slow path.

001/3:[----] [--] 'iotests: fix 097 when run with qcow' 002/3:[0082] [FC] 'iotests: Improve image-clear tests on non-aligned image' 003/3:[down] 'qcow2: Discard unaligned tail when wiping image'

(the blkdebug enhancements from the rest of v6 will be rebased and posted as v8 once 2.10 is final)

Daniel P. Berrange (1):
iotests: fix 097 when run with qcow

Eric Blake (2):
iotests: Improve image-clear tests on non-aligned image
qcow2: Discard unaligned tail when wiping image

 block/qcow2-cluster.c      |  10 +--
 tests/qemu-iotests/097     |  27 +++----
 tests/qemu-iotests/097.out | 180 ++++++++++++---------------------------------
 tests/qemu-iotests/176     | 131 +++++++++++++++++++++++++++++++++
 tests/qemu-iotests/176.out | 150 +++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/group   |   1 +
 6 files changed, 345 insertions(+), 154 deletions(-)
 create mode 100755 tests/qemu-iotests/176
 create mode 100644 tests/qemu-iotests/176.out
Signature · 1 line
2.9.3
author
#4 lore raw

PATCH v7 3/3 qcow2: Discard unaligned tail when wiping image

The previous commit pointed out a subtle difference between the fast and slow path of qcow2_make_empty(), where we failed to discard the final (partial) cluster of an unaligned image.

The problem stems from the fact that qcow2_discard_clusters() was silently ignoring sub-cluster head and tail on unaligned requests. A quick audit of all callers shows that qcow2_snapshot_create() has always passed a cluster-aligned request since the call was added in commit 1ebf561; qcow2_co_pdiscard() has passed a cluster-aligned request since commit ecdbead taught the block layer about preferred discard alignment; and qcow2_make_empty() was fixed to pass an aligned start (but not necessarily end) in commit a3e1505.

Asserting that the start is always aligned also points out that we now have a dead check: rounding the end offset down can never result in a value less than the aligned start offset (the check was rendered dead with commit ecdbead). Meanwhile, we do not want to round the end cluster down in the one case of the end offset matching the (unaligned) file size - that final partial cluster should still be discarded.

With those fixes in place, we can adjust the testsuite so that qemu-iotests 97 and 176 are once again identical for qcow2, showing that fast and slow paths are back in sync.

---
v7: new patch

---
 block/qcow2-cluster.c      | 10 ++++------
 tests/qemu-iotests/176.out |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)
block/qcow2-cluster.c +4 -6
index 78c11d4..100398c 100644
@@ -1519,12 +1519,10 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset,
 
     end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS);
 
-    /* Round start up and end down */
-    offset = align_offset(offset, s->cluster_size);
-    end_offset = start_of_cluster(s, end_offset);
-
-    if (offset > end_offset) {
-        return 0;
+    /* The caller must cluster-align start; round end down except at EOF */
+    assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
+    if (end_offset != bs->total_sectors * BDRV_SECTOR_SIZE) {
+        end_offset = start_of_cluster(s, end_offset);
     }
 
     nb_clusters = size_to_clusters(s, end_offset - offset);
tests/qemu-iotests/176.out +1 -1
index 990a41c..6271fa7 100644
@@ -35,7 +35,7 @@ Offset          Length          File
 Offset          Length          File
 0x7ffd0000      0x10000         TEST_DIR/t.IMGFMT.base
 0x7ffe0000      0x20000         TEST_DIR/t.IMGFMT.itmd
-0x83400000      0x200           TEST_DIR/t.IMGFMT
+0x83400000      0x200           TEST_DIR/t.IMGFMT.itmd
 
 === Test pass 1 ===
 
Signature · 1 line
2.9.3
author
#1 lore raw

PATCH v7 1/3 iotests: fix 097 when run with qcow

In reply to Eric Blake

From: "Daniel P. Berrange" <[email protected]>

The previous commit:

commit a3e1505daec31ef56f0489f8c8fff1b8e4ca92bd
Author: Eric Blake <[email protected]>
Date: Mon Dec 5 09:49:34 2016 -0600

qcow2: Don't strand clusters near 2G intervals during commit

extended the 097 test case so that it did two passes, once with an internal snapshot, once without.

qcow (v1) does not support internal snapshots, so this change broke test 097 when run against qcow.

This splits 097 in two, creating a new 176 that tests the internal snapshot codepath, effectively putting 097 back to its content before the above commit.

Message-Id: <[email protected]>

[eblake: test collisions: s/173/176/g]
---
 tests/qemu-iotests/097     |  10 +---
 tests/qemu-iotests/097.out | 125 ++------------------------------------------
 tests/qemu-iotests/176     | 126 +++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/176.out | 119 ++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/group   |   1 +
 5 files changed, 251 insertions(+), 130 deletions(-)
 create mode 100755 tests/qemu-iotests/176
 create mode 100644 tests/qemu-iotests/176.out
tests/qemu-iotests/097 +1 -9
index 4c33e80..1d28aff 100755
@@ -56,26 +56,19 @@ _supported_os Linux
 #  3: Two-layer backing chain, commit to lower backing file
 #     (in this case, the top image will implicitly stay unchanged)
 #
-# Each pass is run twice, since qcow2 has different code paths for cleaning
-# an image depending on whether it has a snapshot.
-#
 # 020 already tests committing, so this only tests whether image chains are
 # working properly and that all images above the base are emptied; therefore,
 # no complicated patterns are necessary.  Check near the 2G mark, as qcow2
 # has been buggy at that boundary in the past.
 for i in 0 1 2 3; do
-for j in 0 1; do
 
 echo
-echo "=== Test pass $i.$j ==="
+echo "=== Test pass $i ==="
 echo
 
 TEST_IMG="$TEST_IMG.base" _make_test_img 2100M
 TEST_IMG="$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M
 _make_test_img -b "$TEST_IMG.itmd" 2100M
-if [ $j -eq 0 ]; then
-    $QEMU_IMG snapshot -c snap "$TEST_IMG"
-fi
 
 $QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io
 $QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io
@@ -121,7 +114,6 @@ $QEMU_IMG map "$TEST_IMG.itmd" | _filter_qemu_img_map
 $QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
 
 done
-done
 
 
 # success, all done
tests/qemu-iotests/097.out +4 -121

148 lines not on this page · raw message

tests/qemu-iotests/176 new file +126 -0

126 lines not on this page · raw message

tests/qemu-iotests/176.out new file +119 -0

119 lines not on this page · raw message

tests/qemu-iotests/group +1 -0
index 1f4bf03..43142dd 100644
@@ -168,3 +168,4 @@
 173 rw auto
 174 auto
 175 auto quick
+176 rw auto backing
Signature · 1 line
2.9.3
author
#2 lore raw

PATCH v7 2/3 iotests: Improve image-clear tests on non-aligned image

In reply to Eric Blake

Tweak 097 and 176 to operate on an image that is not cluster-aligned, to give further coverage of clearing out an entire image.

Tested for qcow (97) and qcow2 (97 and 176).

The fact that there is a subtle difference between the expected outputs of 97 and 176 on pass 0 is evidence that we still don't always clear out the full image in qcow2. Commit a3e1505 fixed the case of clusters stranded at the 2G mark, but did not fix stranding an unaligned tail. That will be the next patch, kept separate to make it easier to see the impact.

---
v7: also write data in the unaligned cluster, and document bug it exposes
v6: new patch

---
 tests/qemu-iotests/097     | 17 +++++++++-----
 tests/qemu-iotests/097.out | 55 ++++++++++++++++++++++++++++++++++++----------
 tests/qemu-iotests/176     | 17 +++++++++-----
 tests/qemu-iotests/176.out | 55 ++++++++++++++++++++++++++++++++++++----------
 4 files changed, 108 insertions(+), 36 deletions(-)
tests/qemu-iotests/097 +11 -6
index 1d28aff..e22670c 100755
@@ -66,13 +66,15 @@ echo
 echo "=== Test pass $i ==="
 echo
 
-TEST_IMG="$TEST_IMG.base" _make_test_img 2100M
-TEST_IMG="$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M
-_make_test_img -b "$TEST_IMG.itmd" 2100M
+len=$((2100 * 1024 * 1024 + 512)) # larger than 2G, and not cluster aligned
+TEST_IMG="$TEST_IMG.base" _make_test_img $len
+TEST_IMG="$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" $len
+_make_test_img -b "$TEST_IMG.itmd" $len
 
-$QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io
-$QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io
-$QEMU_IO -c 'write -P 3 0x7fff0000 64k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -P 1 0x7ffd0000 192k" "$TEST_IMG.base" | _filter_qemu_io
+$QEMU_IO -c "write -P 2 0x7ffe0000 128k" "$TEST_IMG.itmd" | _filter_qemu_io
+$QEMU_IO -c "write -P 3 0x7fff0000 64k" "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -P 4 $(($len - 512)) 512" "$TEST_IMG" | _filter_qemu_io
 
 if [ $i -lt 3 ]; then
     if [ $i == 0 ]; then
@@ -90,11 +92,13 @@ if [ $i -lt 3 ]; then
 
     # Bottom should be unchanged
     $QEMU_IO -c 'read -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io
+    $QEMU_IO -c "read -P 0 $((len - 512)) 512" "$TEST_IMG.base" | _filter_qemu_io
 
     # Intermediate should contain changes from top
     $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.itmd" | _filter_qemu_io
     $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.itmd" | _filter_qemu_io
     $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.itmd" | _filter_qemu_io
+    $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.itmd" | _filter_qemu_io
 
     # And in pass 0, the top image should be empty, whereas in both other passes
     # it should be unchanged (which is both checked by qemu-img map)
@@ -105,6 +109,7 @@ else
     $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.base" | _filter_qemu_io
     $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.base" | _filter_qemu_io
     $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.base" | _filter_qemu_io
+    $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.base" | _filter_qemu_io
 
     # Both top and intermediate should be unchanged
 fi
tests/qemu-iotests/097.out +43 -12

160 lines not on this page · raw message

tests/qemu-iotests/176 +11 -6
index 9a70a87..950b287 100755
@@ -69,14 +69,16 @@ echo
 echo "=== Test pass $i ==="
 echo
 
-TEST_IMG="$TEST_IMG.base" _make_test_img 2100M
-TEST_IMG="$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M
-_make_test_img -b "$TEST_IMG.itmd" 2100M
+len=$((2100 * 1024 * 1024 + 512)) # larger than 2G, and not cluster aligned
+TEST_IMG="$TEST_IMG.base" _make_test_img $len
+TEST_IMG="$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" $len
+_make_test_img -b "$TEST_IMG.itmd" $len
 $QEMU_IMG snapshot -c snap "$TEST_IMG"
 
-$QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io
-$QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io
-$QEMU_IO -c 'write -P 3 0x7fff0000 64k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -P 1 0x7ffd0000 192k" "$TEST_IMG.base" | _filter_qemu_io
+$QEMU_IO -c "write -P 2 0x7ffe0000 128k" "$TEST_IMG.itmd" | _filter_qemu_io
+$QEMU_IO -c "write -P 3 0x7fff0000 64k" "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -P 4 $(($len - 512)) 512" "$TEST_IMG" | _filter_qemu_io
 
 if [ $i -lt 3 ]; then
     if [ $i == 0 ]; then
@@ -94,11 +96,13 @@ if [ $i -lt 3 ]; then
 
     # Bottom should be unchanged
     $QEMU_IO -c 'read -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io
+    $QEMU_IO -c "read -P 0 $((len - 512)) 512" "$TEST_IMG.base" | _filter_qemu_io
 
     # Intermediate should contain changes from top
     $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.itmd" | _filter_qemu_io
     $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.itmd" | _filter_qemu_io
     $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.itmd" | _filter_qemu_io
+    $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.itmd" | _filter_qemu_io
 
     # And in pass 0, the top image should be empty, whereas in both other passes
     # it should be unchanged (which is both checked by qemu-img map)
@@ -109,6 +113,7 @@ else
     $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.base" | _filter_qemu_io
     $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.base" | _filter_qemu_io
     $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.base" | _filter_qemu_io
+    $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.base" | _filter_qemu_io
 
     # Both top and intermediate should be unchanged
 fi
tests/qemu-iotests/176.out +43 -12

160 lines not on this page · raw message

Signature · 1 line
2.9.3
#3 lore raw

Re: [Qemu-devel] [PATCH v7 2/3] iotests: Improve image-clear tests on non-aligned image

Quoted 11 lines · Eric Blake

Tweak 097 and 176 to operate on an image that is not cluster-aligned, to give further coverage of clearing out an entire image.

Tested for qcow (97) and qcow2 (97 and 176).

The fact that there is a subtle difference between the expected outputs of 97 and 176 on pass 0 is evidence that we still don't always clear out the full image in qcow2. Commit a3e1505 fixed the case of clusters stranded at the 2G mark, but did not fix stranding an unaligned tail. That will be the next patch, kept separate to make it easier to see the impact.

I'm not sure I like this very much. The reference output should always be what we actually expect it to be. Therefore, usually the issue is fixed first and the test is added only afterwards.

If I want to see the impact I can just do what I always do in those
cases: Go to the base commit, compile qemu, step forward to commits to the test, run the test, see it fail, compile qemu again, run the test, see it pass.

So would it be possible to switch this and patch 3?

(Apart from that, this patch looks good.)

Max

Quoted 11 lines

---
v7: also write data in the unaligned cluster, and document bug it exposes
v6: new patch

---
 tests/qemu-iotests/097     | 17 +++++++++-----
 tests/qemu-iotests/097.out | 55 ++++++++++++++++++++++++++++++++++++----------
 tests/qemu-iotests/176     | 17 +++++++++-----
 tests/qemu-iotests/176.out | 55 ++++++++++++++++++++++++++++++++++++----------
 4 files changed, 108 insertions(+), 36 deletions(-)
Reviewed-by on v7 3/3
#5 lore raw

Re: [Qemu-devel] [PATCH v7 3/3] qcow2: Discard unaligned tail when wiping image

In reply to Eric Blake
Quoted 43 lines · Eric Blake

The previous commit pointed out a subtle difference between the fast and slow path of qcow2_make_empty(), where we failed to discard the final (partial) cluster of an unaligned image.

The problem stems from the fact that qcow2_discard_clusters() was silently ignoring sub-cluster head and tail on unaligned requests. A quick audit of all callers shows that qcow2_snapshot_create() has always passed a cluster-aligned request since the call was added in commit 1ebf561; qcow2_co_pdiscard() has passed a cluster-aligned request since commit ecdbead taught the block layer about preferred discard alignment; and qcow2_make_empty() was fixed to pass an aligned start (but not necessarily end) in commit a3e1505.

Asserting that the start is always aligned also points out that we now have a dead check: rounding the end offset down can never result in a value less than the aligned start offset (the check was rendered dead with commit ecdbead). Meanwhile, we do not want to round the end cluster down in the one case of the end offset matching the (unaligned) file size - that final partial cluster should still be discarded.

With those fixes in place, we can adjust the testsuite so that qemu-iotests 97 and 176 are once again identical for qcow2, showing that fast and slow paths are back in sync.

---
v7: new patch

---
 block/qcow2-cluster.c      | 10 ++++------
 tests/qemu-iotests/176.out |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)
block/qcow2-cluster.c +0 -1
index 78c11d4..100398c 100644
@@ -1519,12 +1519,10 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset,
 
     end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS);
 
-    /* Round start up and end down */

block/qcow2-cluster.c int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, · line 1526

Quoted 10 lines
block/qcow2-cluster.c +4 -5
-    offset = align_offset(offset, s->cluster_size);
-    end_offset = start_of_cluster(s, end_offset);
-
-    if (offset > end_offset) {
-        return 0;
+    /* The caller must cluster-align start; round end down except at EOF */
+    assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
+    if (end_offset != bs->total_sectors * BDRV_SECTOR_SIZE) {
+        end_offset = start_of_cluster(s, end_offset);
     }

This change looks good and works for qcow2_make_empty(), but qcow2_co_pdiscard() will still drop these requests:

$ ./qemu-img create -f qcow2 foo.qcow2 512
Formatting 'foo.qcow2', fmt=qcow2 size=512 encryption=off
cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ ./qemu-io -c 'write 0 512' foo.qcow2
wrote 512/512 bytes at offset 0
512 bytes, 1 ops; 0.0062 sec (80.167 KiB/sec and 160.3335 ops/sec)
$ ./qemu-img map foo.qcow2
Offset          Length          Mapped to       File
0               0x200           0x50000         foo.qcow2
$ ./qemu-io -c 'discard 0 512' foo.qcow2
discard 512/512 bytes at offset 0
512 bytes, 1 ops; 0.0000 sec (34.877 MiB/sec and 71428.5714 ops/sec)
$ ./qemu-img map foo.qcow2
Offset          Length          Mapped to       File
0               0x200           0x50000         foo.qcow2

We don't necessarily have to fix it for 2.9, so:

Quoted 15 lines
block/qcow2-cluster.c +0 -0
     nb_clusters = size_to_clusters(s, end_offset - offset);
tests/qemu-iotests/176.out +1 -1
index 990a41c..6271fa7 100644
@@ -35,7 +35,7 @@ Offset          Length          File
 Offset          Length          File
 0x7ffd0000      0x10000         TEST_DIR/t.IMGFMT.base
 0x7ffe0000      0x20000         TEST_DIR/t.IMGFMT.itmd
-0x83400000      0x200           TEST_DIR/t.IMGFMT
+0x83400000      0x200           TEST_DIR/t.IMGFMT.itmd
 
 === Test pass 1 ===
 
author
#6 lore raw

Re: [Qemu-devel] [PATCH v7 3/3] qcow2: Discard unaligned tail when wiping image

Quoted 6 lines · Max Reitz
Quoted 4 lines · Eric Blake

The previous commit pointed out a subtle difference between the fast and slow path of qcow2_make_empty(), where we failed to discard the final (partial) cluster of an unaligned image.

Quoted 8 lines

block/qcow2-cluster.c int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, · line 1526

Quoted 5 lines
block/qcow2-cluster.c +4 -0
+    /* The caller must cluster-align start; round end down except at EOF */
+    assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
+    if (end_offset != bs->total_sectors * BDRV_SECTOR_SIZE) {
+        end_offset = start_of_cluster(s, end_offset);
     }

This change looks good and works for qcow2_make_empty(), but qcow2_co_pdiscard() will still drop these requests:

Yes, but qcow2_co_pdiscard() is advisory, and leaving the last partial cluster undiscarded (consistent for what we do for all other partial cluster requests) is different than our documented notion that qcow2_make_empty() gets rid of all clusters no matter what.

Quoted 1 line

We don't necessarily have to fix it for 2.9, so:

Agreed that enhancing pdiscard to special-case a partial cluster at EOF is not a bug fix, and therefore 2.10 material if we even want it.

Quoted 4 lines
Quoted 1 line
Quoted 11 lines

tests/qemu-iotests/176.out Offset Length File · line 38

Quoted 11 lines
     nb_clusters = size_to_clusters(s, end_offset - offset);
tests/qemu-iotests/176.out +1 -1
index 990a41c..6271fa7 100644
@@ -35,7 +35,7 @@ Offset          Length          File
 Offset          Length          File
 0x7ffd0000      0x10000         TEST_DIR/t.IMGFMT.base
 0x7ffe0000      0x20000         TEST_DIR/t.IMGFMT.itmd
-0x83400000      0x200           TEST_DIR/t.IMGFMT
+0x83400000      0x200           TEST_DIR/t.IMGFMT.itmd

As to your comment about swapping patches 2 and 3, if I did that, then I would not have this change to 176.out during the bug fix, and would instead squash this line into the single patch touching the testsuite to add the enhancement. How important is the swapped order? Do I need to respin for that, or is it something a maintainer could tweak, or is the series fine as-is? For what it's worth, the policy of single test after the patch is somewhat opposite of Markus' approach of test first showing the buggy behavior, then patch that includes the testsuite fix to match the patch. But I can live with either order, so I won't respin without an explicit request to do so.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH v7 3/3] qcow2: Discard unaligned tail when wiping image

Quoted 21 lines · Eric Blake
Quoted 6 lines · Max Reitz
Quoted 4 lines · Eric Blake

The previous commit pointed out a subtle difference between the fast and slow path of qcow2_make_empty(), where we failed to discard the final (partial) cluster of an unaligned image.

Quoted 8 lines

block/qcow2-cluster.c int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, · line 1526

Quoted 5 lines
block/qcow2-cluster.c +4 -0
+    /* The caller must cluster-align start; round end down except at EOF */
+    assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
+    if (end_offset != bs->total_sectors * BDRV_SECTOR_SIZE) {
+        end_offset = start_of_cluster(s, end_offset);
     }

This change looks good and works for qcow2_make_empty(), but qcow2_co_pdiscard() will still drop these requests:

Yes, but qcow2_co_pdiscard() is advisory, and leaving the last partial cluster undiscarded (consistent for what we do for all other partial cluster requests) is different than our documented notion that qcow2_make_empty() gets rid of all clusters no matter what.

Quoted 4 lines
Quoted 1 line

We don't necessarily have to fix it for 2.9, so:

Agreed that enhancing pdiscard to special-case a partial cluster at EOF is not a bug fix, and therefore 2.10 material if we even want it.

Why would we not want it? :-)

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 16 lines
Quoted 11 lines

tests/qemu-iotests/176.out Offset Length File · line 38

Quoted 11 lines
     nb_clusters = size_to_clusters(s, end_offset - offset);
tests/qemu-iotests/176.out +1 -1
index 990a41c..6271fa7 100644
@@ -35,7 +35,7 @@ Offset          Length          File
 Offset          Length          File
 0x7ffd0000      0x10000         TEST_DIR/t.IMGFMT.base
 0x7ffe0000      0x20000         TEST_DIR/t.IMGFMT.itmd
-0x83400000      0x200           TEST_DIR/t.IMGFMT
+0x83400000      0x200           TEST_DIR/t.IMGFMT.itmd

As to your comment about swapping patches 2 and 3, if I did that, then I would not have this change to 176.out during the bug fix, and would instead squash this line into the single patch touching the testsuite to add the enhancement.

Right.

Quoted 1 line

How important is the swapped order?

As you can probably guess, technically not important. But I having reference outputs that are not actually a reference kind of defeats the purpose in my opinion.

Quoted 3 lines

Do I need to
respin for that, or is it something a maintainer could tweak, or is the series fine as-is?

Of course I can fix the code, but changing the commit messages is a bit more involved...

Quoted 5 lines

For what it's worth, the policy of single test after
the patch is somewhat opposite of Markus' approach of test first showing the buggy behavior, then patch that includes the testsuite fix to match the patch. But I can live with either order, so I won't respin without an explicit request to do so.

Well, then consider this an explicit request. :-)

Max

author
#8 lore raw

Re: [Qemu-devel] [PATCH v7 3/3] qcow2: Discard unaligned tail when wiping image

Quoted 7 lines · Max Reitz
Quoted 3 lines

Do I need to
respin for that, or is it something a maintainer could tweak, or is the series fine as-is?

Of course I can fix the code, but changing the commit messages is a bit more involved...

Quoted 7 lines
Quoted 5 lines

For what it's worth, the policy of single test after
the patch is somewhat opposite of Markus' approach of test first showing the buggy behavior, then patch that includes the testsuite fix to match the patch. But I can live with either order, so I won't respin without an explicit request to do so.

Well, then consider this an explicit request. :-)

Yes sir! v8 coming right up.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org