From: Hanna Czenczek <hreitz@redhat.com>
To: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, eblake@redhat.com,
berto@igalia.com, den@virtuozzo.com
Subject: Re: [PATCH 7/7] iotests/271: check disk usage on subcluster-based discard/unmap
Date: Fri, 3 Nov 2023 16:51:08 +0100 [thread overview]
Message-ID: <90298f38-fe14-4659-87a3-9b4bd2f516df@redhat.com> (raw)
In-Reply-To: <20231020215622.789260-8-andrey.drobyshev@virtuozzo.com>
On 20.10.23 23:56, Andrey Drobyshev wrote:
> Add _verify_du_delta() checker which is used to check that real disk
> usage delta meets the expectations. For now we use it for checking that
> subcluster-based discard/unmap operations lead to actual disk usage
> decrease (i.e. PUNCH_HOLE operation is performed).
I’m not too happy about checking the disk usage because that relies on
the underlying filesystem actually accepting and executing the unmap.
Why is it not enough to check the L2 bitmap?
…Coming back later (I had to fix the missing `ret = ` I mentioned in
patch 2, or this test would hang, so I couldn’t run it at first), I note
that checking the disk usage in fact doesn’t work on tmpfs. I usually
run the iotests in tmpfs, so that’s not great.
> Also add separate test case for discarding particular subcluster within
> one cluster.
>
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> ---
> tests/qemu-iotests/271 | 25 ++++++++++++++++++++++++-
> tests/qemu-iotests/271.out | 2 ++
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271
> index c7c2cadda0..5fcb209f5f 100755
> --- a/tests/qemu-iotests/271
> +++ b/tests/qemu-iotests/271
> @@ -81,6 +81,15 @@ _verify_l2_bitmap()
> fi
> }
>
> +# Check disk usage delta after a discard/unmap operation
> +# _verify_du_delta $before $after $expected_delta
> +_verify_du_delta()
> +{
> + if [ $(($1 - $2)) -ne $3 ]; then
> + printf "ERROR: unexpected delta: $1 - $2 = $(($1 - $2)) != $3\n"
> + fi
> +}
> +
> # This should be called as _run_test c=XXX sc=XXX off=XXX len=XXX cmd=XXX
> # c: cluster number (0 if unset)
> # sc: subcluster number inside cluster @c (0 if unset)
> @@ -198,9 +207,12 @@ for use_backing_file in yes no; do
> alloc="$(seq 0 31)"; zero=""
> _run_test sc=0 len=64k
>
> - ### Zero and unmap half of cluster #0 (this won't unmap it)
> + ### Zero and unmap half of cluster #0 (this will unmap it)
I think “it” refers to the cluster, and it is not unmapped. This test
case does not use a discard, but write -z instead, so it worked before.
(The L2 bitmap shown in the output doesn’t change, so functionally, this
patch series didn’t change this case.)
> alloc="$(seq 16 31)"; zero="$(seq 0 15)"
> + before=$(disk_usage "$TEST_IMG")
> _run_test sc=0 len=32k cmd=unmap
> + after=$(disk_usage "$TEST_IMG")
> + _verify_du_delta $before $after 32768
>
> ### Zero and unmap cluster #0
> alloc=""; zero="$(seq 0 31)"
For this following case shown truncated here, why don’t we try
“_run_test sc=16 len=32k cmd=unmap” instead of “sc=0 len=64k”? I.e.
unmap only the second half, which, thanks to patch 3, should still unmap
the whole cluster, because the first half is already unmapped.
> @@ -447,7 +459,10 @@ for use_backing_file in yes no; do
>
> # Subcluster-aligned request from clusters #12 to #14
> alloc="$(seq 0 15)"; zero="$(seq 16 31)"
> + before=$(disk_usage "$TEST_IMG")
> _run_test c=12 sc=16 len=128k cmd=unmap
> + after=$(disk_usage "$TEST_IMG")
> + _verify_du_delta $before $after $((128 * 1024))
> alloc=""; zero="$(seq 0 31)"
> _verify_l2_bitmap 13
> alloc="$(seq 16 31)"; zero="$(seq 0 15)"
> @@ -528,6 +543,14 @@ for use_backing_file in yes no; do
> else
> _make_test_img -o extended_l2=on 1M
> fi
> + # Write cluster #0 and discard its subclusters #0-#3
> + $QEMU_IO -c 'write -q 0 64k' "$TEST_IMG"
> + before=$(disk_usage "$TEST_IMG")
> + $QEMU_IO -c 'discard -q 0 8k' "$TEST_IMG"
> + after=$(disk_usage "$TEST_IMG")
> + _verify_du_delta $before $after 8192
> + alloc="$(seq 4 31)"; zero="$(seq 0 3)"
> + _verify_l2_bitmap 0
> # Write clusters #0-#2 and then discard them
> $QEMU_IO -c 'write -q 0 128k' "$TEST_IMG"
> $QEMU_IO -c 'discard -q 0 128k' "$TEST_IMG"
Similarly to above, I think it would be good if we combined this
following case with the one you added, i.e. to write 128k from the
beginning, drop the write here, and change the discard to be “discard -q
8k 120k”, i.e. skip the subclusters we have already discarded, to see
that this is still combined to discard the whole first cluster.
...Ah, see, and when I try this, the following assertion fails:
qemu-io: ../block/qcow2-cache.c:156: qcow2_cache_destroy: Assertion
`c->entries[i].ref == 0' failed.
./common.rc: line 220: 128894 Aborted (core dumped) (
VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec
"${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
Looks like an L2 table is leaked somewhere. That’s why SCRI should be a
g_auto()-able type.
Hanna
> diff --git a/tests/qemu-iotests/271.out b/tests/qemu-iotests/271.out
> index 5be780de76..0da8d72cde 100644
> --- a/tests/qemu-iotests/271.out
> +++ b/tests/qemu-iotests/271.out
> @@ -426,6 +426,7 @@ L2 entry #29: 0x0000000000000000 0000ffff00000000
> ### Discarding clusters with non-zero bitmaps (backing file: yes) ###
>
> Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
> +L2 entry #0: 0x8000000000050000 0000000ffffffff0
> L2 entry #0: 0x0000000000000000 ffffffff00000000
> L2 entry #1: 0x0000000000000000 ffffffff00000000
> Image resized.
> @@ -436,6 +437,7 @@ L2 entry #1: 0x0000000000000000 ffffffff00000000
> ### Discarding clusters with non-zero bitmaps (backing file: no) ###
>
> Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
> +L2 entry #0: 0x8000000000050000 0000000ffffffff0
> L2 entry #0: 0x0000000000000000 ffffffff00000000
> L2 entry #1: 0x0000000000000000 ffffffff00000000
> Image resized.
next prev parent reply other threads:[~2023-11-03 15:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 21:56 [PATCH 0/7] qcow2: make subclusters discardable Andrey Drobyshev
2023-10-20 21:56 ` [PATCH 1/7] qcow2: make function update_refcount_discard() global Andrey Drobyshev
2023-10-31 15:27 ` Hanna Czenczek
2023-10-20 21:56 ` [PATCH 2/7] qcow2: add get_sc_range_info() helper for working with subcluster ranges Andrey Drobyshev
2023-10-31 15:53 ` Hanna Czenczek
2023-11-09 12:32 ` Andrey Drobyshev
2023-10-20 21:56 ` [PATCH 3/7] qcow2: zeroize the entire cluster when there're no non-zero subclusters Andrey Drobyshev
2023-10-31 16:06 ` Hanna Czenczek
2023-10-20 21:56 ` [PATCH 4/7] qcow2: make subclusters discardable Andrey Drobyshev
2023-10-27 11:10 ` Jean-Louis Dupond
2024-04-16 19:56 ` Andrey Drobyshev
2024-04-19 9:06 ` Jean-Louis Dupond
2023-10-31 16:32 ` Hanna Czenczek
2023-11-09 15:05 ` Andrey Drobyshev
2023-10-31 16:33 ` Hanna Czenczek
2023-11-10 13:26 ` Andrey Drobyshev
2023-11-03 15:53 ` Hanna Czenczek
2023-10-20 21:56 ` [PATCH 5/7] qcow2: zero_l2_subclusters: fall through to discard operation when requested Andrey Drobyshev
2023-11-03 15:19 ` Hanna Czenczek
2023-11-10 13:17 ` Andrey Drobyshev
2023-10-20 21:56 ` [PATCH 6/7] iotests/common.rc: add disk_usage function Andrey Drobyshev
2023-11-03 15:20 ` Hanna Czenczek
2023-11-09 12:35 ` Andrey Drobyshev
2023-10-20 21:56 ` [PATCH 7/7] iotests/271: check disk usage on subcluster-based discard/unmap Andrey Drobyshev
2023-11-03 15:51 ` Hanna Czenczek [this message]
2023-11-03 15:59 ` Hanna Czenczek
2023-11-09 14:05 ` Andrey Drobyshev
2023-11-09 13:55 ` Andrey Drobyshev
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=90298f38-fe14-4659-87a3-9b4bd2f516df@redhat.com \
--to=hreitz@redhat.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=berto@igalia.com \
--cc=den@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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.