Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:z

6 # Copyright (C) 2019-2020 Igalia, S.L.
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # You should have received a copy of the GNU General Public License
26 seq="$(basename $0)"
35 rm -f "$TEST_IMG.raw"
37 trap "_cleanup; exit \$status" 0 1 2 3 15
46 _unsupported_imgopts extended_l2 compat=0.10 cluster_size data_file refcount_bits=1[^0-9]
48 l2_offset=$((0x40000))
52 $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.raw" | grep -v 'Images are identical'
54 grep -v 'No errors were found on the image'
60 entry_no="$1" # L2 entry number, starting from 0
61 expected_alloc="$alloc" # Space-separated list of allocated subcluster indexes
62 expected_zero="$zero" # Space-separated list of zero subcluster indexes
69 expected_bitmap=0
76 printf -v expected_bitmap "%u" $expected_bitmap # Convert to unsigned
78 printf "L2 entry #%d: 0x%016x %016x\n" "$entry_no" "$entry" "$bitmap"
80 printf "ERROR: expecting bitmap 0x%016x\n" "$expected_bitmap"
85 # c: cluster number (0 if unset)
86 # sc: subcluster number inside cluster @c (0 if unset)
87 # off: offset inside subcluster @sc, in kilobytes (0 if unset)
88 # len: request length, passed directly to qemu-io (e.g: 256, 4k, 1M, ...)
89 # cmd: the command to pass to qemu-io, must be one of
90 # write -> write
91 # zero -> write -z
92 # unmap -> write -z -u
93 # compress -> write -c
94 # discard -> discard
99 case "${cmd:-write}" in
101 cmd="write -q -z";;
103 cmd="write -q -z -u";;
105 pat=$((${pat:-0} + 1))
106 cmd="write -q -c -P ${pat}";;
108 pat=$((${pat:-0} + 1))
109 cmd="write -q -P ${pat}";;
111 cmd="discard -q";;
116 c="${c:-0}"
117 sc="${sc:-0}"
118 off="${off:-0}"
120 [ "$offset" != 0 ] && offset="${offset}k"
122 raw_cmd=$(echo $cmd | sed s/-c//) # Raw images don't support -c
123 echo $cmd | sed 's/-P [0-9][0-9]\?/-P PATTERN/'
124 $QEMU_IO -c "$cmd" "$TEST_IMG" | _filter_qemu_io
125 $QEMU_IO -c "$raw_cmd" -f raw "$TEST_IMG.raw" | _filter_qemu_io
133 $QEMU_IMG create -f raw "$TEST_IMG.raw" "$size" | _filter_img_create
135 $QEMU_IMG create -f raw "$TEST_IMG.base" "$size" | _filter_img_create
136 $QEMU_IO -c "write -q -P 0xFF 0 $size" -f raw "$TEST_IMG.base" | _filter_qemu_io
137 $QEMU_IO -c "write -q -P 0xFF 0 $size" -f raw "$TEST_IMG.raw" | _filter_qemu_io
138 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" "$size"
140 _make_test_img -o extended_l2=on "$size"
155 ### Write subcluster #0 (beginning of subcluster) ###
156 alloc="0"; zero=""
157 _run_test sc=0 len=1k
160 alloc="0 1"; zero=""
164 alloc="0 1 2"; zero=""
168 alloc="0 1 2 3"; zero=""
171 ### Write subclusters #4-6 (full subclusters) ###
172 alloc="$(seq 0 6)"; zero=""
175 ### Write subclusters #7-9 (partial subclusters) ###
176 alloc="$(seq 0 9)"; zero=""
180 alloc="$(seq 0 9) 16"; zero=""
183 ### Write subcluster #31-#33 (cluster overlap) ###
184 alloc="$(seq 0 9) 16 31"; zero=""
186 alloc="0 1" ; zero=""
190 alloc="0 $(seq 2 9) 16 31"; zero="1"
193 ### Zero cluster #0
194 alloc=""; zero="$(seq 0 31)"
195 _run_test sc=0 len=64k cmd=zero
197 ### Fill cluster #0 with data
198 alloc="$(seq 0 31)"; zero=""
199 _run_test sc=0 len=64k
201 ### Zero and unmap half of cluster #0 (this won't unmap it)
202 alloc="$(seq 16 31)"; zero="$(seq 0 15)"
203 _run_test sc=0 len=32k cmd=unmap
205 ### Zero and unmap cluster #0
206 alloc=""; zero="$(seq 0 31)"
207 _run_test sc=0 len=64k cmd=unmap
210 alloc="1"; zero="0 $(seq 2 31)"
213 ### Fill cluster #0 with data
214 alloc="$(seq 0 31)"; zero=""
215 _run_test sc=0 len=64k
217 ### Discard cluster #0
218 alloc=""; zero="$(seq 0 31)"
219 _run_test sc=0 len=64k cmd=discard
221 ### Write compressed data to cluster #0
223 _run_test sc=0 len=64k cmd=compress
226 alloc="$(seq 0 31)"; zero=""
234 # calculate_l2_meta() checks if none of the clusters affected by a
236 # returns when they don't. This is a test for that optimization.
237 # Here clusters #0-#3 are overwritten but only #1 and #2 need changes.
242 # Write cluster #0, subclusters #12-#31
256 # Write cluster #3, subclusters #0-#16
257 alloc="$(seq 0 16)"; zero=""
258 _run_test c=3 sc=0 len=34k
260 # Write from cluster #0, subcluster #12 to cluster #3, subcluster #11
263 alloc="$(seq 0 31)"; zero=""
267 alloc="$(seq 0 16)"; zero=""
279 # Note that the image size is not a multiple of the cluster size
282 # Cluster-aligned request from clusters #0 to #2
283 alloc=""; zero="$(seq 0 31)"
284 _run_test c=0 sc=0 len=192k cmd=zero
288 # Subcluster-aligned request from clusters #3 to #5
291 alloc=""; zero="$(seq 0 31)"
293 alloc=""; zero="$(seq 0 15)"
298 alloc="15"; zero="$(seq 16 31)" # copy-on-write happening here
303 alloc=""; zero="$(seq 0 31)"
306 alloc="15"; zero="$(seq 0 14)" # copy-on-write happening here
308 alloc=""; zero="$(seq 0 15)"
315 alloc="$(seq 0 31)"; zero=""
316 _run_test c=9 sc=0 len=576k
326 # Cluster-aligned request from clusters #9 to #11
327 alloc=""; zero="$(seq 0 31)"
328 _run_test c=9 sc=0 len=192k cmd=zero
332 # Subcluster-aligned request from clusters #12 to #14
333 alloc="$(seq 0 15)"; zero="$(seq 16 31)"
335 alloc=""; zero="$(seq 0 31)"
337 alloc="$(seq 16 31)"; zero="$(seq 0 15)"
341 alloc="$(seq 0 15)"; zero="$(seq 16 31)"
343 alloc=""; zero="$(seq 0 31)"
345 alloc="$(seq 15 31)"; zero="$(seq 0 14)"
353 _run_test c=$c sc=0 len=64k cmd=compress
356 # Cluster-aligned request from clusters #18 to #20
357 alloc=""; zero="$(seq 0 31)"
358 _run_test c=18 sc=0 len=192k cmd=zero
362 # Subcluster-aligned request from clusters #21 to #23.
363 # We cannot partially zero a compressed cluster so the code
364 # returns -ENOTSUP, which means copy-on-write of the compressed
367 alloc="$(seq 0 31)"; zero=""
373 # In this case QEMU internally sends a 1k request followed by a
374 # subcluster-aligned 128k request. The first request decompresses
378 alloc="$(seq 0 31)"; zero=""
385 # request does not correspond to a compressed cluster, so it can
388 # there's a backing file we need to perform cow.
389 alloc="$(seq 0 15)"; zero="$(seq 16 31)"
391 alloc=""; zero="$(seq 0 31)"
394 alloc="15"; zero="$(seq 0 14)" # copy-on-write happening here
396 alloc=""; zero="$(seq 0 15)"
404 # If there's a backing file we need to allocate and do
405 # copy-on-write on the partially zeroed subclusters.
408 alloc="15 19"; zero="$(seq 16 18)" # copy-on-write happening here
415 # (the image size is not a multiple of the cluster or subcluster size).
416 alloc=""; zero="$(seq 0 17)"
417 _run_test c=32 sc=0 len=35k cmd=zero
429 # Note that the image size is not a multiple of the cluster size
431 alloc="$(seq 0 31)"; zero=""
432 _run_test c=9 sc=0 len=576k
442 # Cluster-aligned request from clusters #9 to #11
443 alloc=""; zero="$(seq 0 31)"
444 _run_test c=9 sc=0 len=192k cmd=unmap
448 # Subcluster-aligned request from clusters #12 to #14
449 alloc="$(seq 0 15)"; zero="$(seq 16 31)"
451 alloc=""; zero="$(seq 0 31)"
453 alloc="$(seq 16 31)"; zero="$(seq 0 15)"
457 alloc="$(seq 0 15)"; zero="$(seq 16 31)"
459 alloc=""; zero="$(seq 0 31)"
461 alloc="$(seq 15 31)"; zero="$(seq 0 14)"
469 _run_test c=$c sc=0 len=64k cmd=compress
472 # Cluster-aligned request from clusters #18 to #20
473 alloc=""; zero="$(seq 0 31)"
474 _run_test c=18 sc=0 len=192k cmd=unmap
478 # Subcluster-aligned request from clusters #21 to #23.
479 # We cannot partially zero a compressed cluster so the code
480 # returns -ENOTSUP, which means copy-on-write of the compressed
483 alloc="$(seq 0 31)"; zero=""
489 # In this case QEMU internally sends a 1k request followed by a
490 # subcluster-aligned 128k request. The first request decompresses
494 alloc="$(seq 0 31)"; zero=""
501 # request does not correspond to a compressed cluster, so it can
504 # there's a backing file we need to perform cow.
505 alloc="$(seq 0 15)"; zero="$(seq 16 31)"
507 alloc=""; zero="$(seq 0 31)"
510 alloc="15"; zero="$(seq 0 14)" # copy-on-write happening here
512 alloc=""; zero="$(seq 0 15)"
524 echo "### Discarding clusters with non-zero bitmaps (backing file: $use_backing_file) ###"
527 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 1M
529 _make_test_img -o extended_l2=on 1M
531 # Write clusters #0-#2 and then discard them
532 $QEMU_IO -c 'write -q 0 128k' "$TEST_IMG"
533 $QEMU_IO -c 'discard -q 0 128k' "$TEST_IMG"
534 # 'qemu-io discard' doesn't do a full discard, it zeroizes the
536 alloc=""; zero="$(seq 0 31)"
537 _verify_l2_bitmap 0
539 # Now mark the 2nd half of the subclusters from cluster #0 as unallocated
541 # Discard cluster #0 again to see how the zero bits have changed
542 $QEMU_IO -c 'discard -q 0 64k' "$TEST_IMG"
543 # And do a full discard of cluster #1 by shrinking and growing the image
544 $QEMU_IMG resize --shrink "$TEST_IMG" 64k
546 # A normal discard sets all 'zero' bits only if the image has a
549 alloc=""; zero="$(seq 0 31)"
551 alloc=""; zero="$(seq 0 15)"
553 _verify_l2_bitmap 0
554 # A full discard should clear the L2 entry completely. However
555 # when growing an image with a backing file the new clusters are
558 alloc=""; zero="$(seq 0 31)"
573 echo "### Corrupted L2 entries - $corruption_test_cmd test (allocated) ###"
577 # We actually don't consider this a corrupted image.
580 # TODO: maybe treat the image as corrupted and make qemu-img check fix it?
581 _make_test_img -o extended_l2=on 1M
582 $QEMU_IO -c 'write -q -P 0x11 0 2k' "$TEST_IMG"
584 alloc="0"; zero=""
585 _verify_l2_bitmap 0
586 $QEMU_IO -c "$corruption_test_cmd -q -P 0x11 0 1k" "$TEST_IMG"
588 alloc="0"; zero=""
590 _verify_l2_bitmap 0
595 _make_test_img -o extended_l2=on 1M
596 # Write from the middle of cluster #0 to the middle of cluster #2
597 $QEMU_IO -c 'write -q 32k 128k' "$TEST_IMG"
600 alloc="$(seq 0 31)"; zero="0"
602 $QEMU_IO -c "$corruption_test_cmd 0 192k" "$TEST_IMG"
605 echo "### Corrupted L2 entries - $corruption_test_cmd test (unallocated) ###"
609 # We actually don't consider this a corrupted image.
612 # TODO: maybe treat the image as corrupted and make qemu-img check fix it?
613 _make_test_img -o extended_l2=on 1M
614 # We want to modify the (empty) L2 entry from cluster #0,
616 $QEMU_IO -c 'write -q 256k 1k' "$TEST_IMG"
619 _verify_l2_bitmap 0
620 $QEMU_IO -c "$corruption_test_cmd -q 0 1k" "$TEST_IMG"
622 alloc="0"; zero=""
624 _verify_l2_bitmap 0
629 _make_test_img -o extended_l2=on 1M
630 # We want to corrupt the (empty) L2 entry from cluster #0,
632 $QEMU_IO -c 'write -q 256k 1k' "$TEST_IMG"
634 alloc="0"; zero=""
635 _verify_l2_bitmap 0
636 $QEMU_IO -c "$corruption_test_cmd 0 1k" "$TEST_IMG"
641 _make_test_img -o extended_l2=on 1M
644 $QEMU_IO -c 'write -q 256k 1k' "$TEST_IMG"
647 alloc="0"; zero="0"
649 $QEMU_IO -c "$corruption_test_cmd 0 192k" "$TEST_IMG"
652 echo "### Compressed cluster with subcluster bitmap != 0 - $corruption_test_cmd test ###"
654 # We actually don't consider this a corrupted image.
656 _make_test_img -o extended_l2=on 1M
657 $QEMU_IO -c 'write -q -P 11 -c 0 64k' "$TEST_IMG"
658 # Change the L2 bitmap to allocate subcluster #31 and zeroize subcluster #0
660 alloc="31"; zero="0"
661 _verify_l2_bitmap 0
662 $QEMU_IO -c "$corruption_test_cmd -P 11 0 64k" "$TEST_IMG" | _filter_qemu_io
663 # Writing allocates a new uncompressed cluster so we get a new bitmap
665 alloc="$(seq 0 31)"; zero=""
667 _verify_l2_bitmap 0
677 # Create a backing file and fill it with data
678 $QEMU_IMG create -f raw "$TEST_IMG.base" 128k | _filter_img_create
679 $QEMU_IO -c "write -q -P 0xff 0 128k" -f raw "$TEST_IMG.base" | _filter_qemu_io
682 # Create a new image, allocate a cluster and write some data to it
683 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base"
684 $QEMU_IO -c 'write -q -P 1 4k 2k' "$TEST_IMG"
687 # This cannot be repaired, qemu-img check will fail to fix it
688 _check_test_img -r all
690 $QEMU_IO -c 'read -q 0 2k' "$TEST_IMG"
693 # Create a new image, allocate a cluster and zeroize subcluster #2
694 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base"
695 $QEMU_IO -c 'write -q -P 1 4k 2k' "$TEST_IMG"
696 $QEMU_IO -c 'write -q -z 4k 2k' "$TEST_IMG"
700 _check_test_img -r all
702 $QEMU_IO -c 'read -q -P 0xff 0 4k' "$TEST_IMG"
703 $QEMU_IO -c 'read -q -P 0x00 4k 2k' "$TEST_IMG"
704 $QEMU_IO -c 'read -q -P 0xff 6k 122k' "$TEST_IMG"
714 _make_test_img -o extended_l2=on,cluster_size=8k 1M
717 # For preallocation with backing files, create a backing file first
718 $QEMU_IMG create -f raw "$TEST_IMG.base" 1M | _filter_img_create
719 $QEMU_IO -c "write -q -P 0xff 0 1M" -f raw "$TEST_IMG.base" | _filter_qemu_io
721 _make_test_img -o extended_l2=on,preallocation=metadata -F raw -b "$TEST_IMG.base" 512k
723 $QEMU_IO -c 'read -P 0xff 0 512k' "$TEST_IMG" | _filter_qemu_io
724 $QEMU_IO -c 'read -P 0x00 512k 512k' "$TEST_IMG" | _filter_qemu_io
728 _make_test_img -o extended_l2=on,preallocation=falloc -F raw -b "$TEST_IMG.base" 512k
730 $QEMU_IO -c 'read -P 0xff 0 512k' "$TEST_IMG" | _filter_qemu_io
731 $QEMU_IO -c 'read -P 0x00 512k 512k' "$TEST_IMG" | _filter_qemu_io
735 _make_test_img -o extended_l2=on,preallocation=full -F raw -b "$TEST_IMG.base" 512k
737 $QEMU_IO -c 'read -P 0xff 0 512k' "$TEST_IMG" | _filter_qemu_io
738 $QEMU_IO -c 'read -P 0x00 512k 512k' "$TEST_IMG" | _filter_qemu_io
745 echo "# resize --preallocation=metadata"
746 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 503k
747 $QEMU_IMG resize --preallocation=metadata "$TEST_IMG" 1013k
748 $QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
749 $QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
752 echo "# resize --preallocation=falloc"
753 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 503k
754 $QEMU_IMG resize --preallocation=falloc "$TEST_IMG" 1013k
755 $QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
756 $QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
758 echo "# resize --preallocation=full"
759 _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 503k
760 $QEMU_IMG resize --preallocation=full "$TEST_IMG" 1013k
761 $QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
762 $QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
768 echo "# resize --preallocation=metadata"
769 _make_test_img -o extended_l2=on 503k
770 $QEMU_IO -c 'write -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
771 $QEMU_IMG resize --preallocation=metadata "$TEST_IMG" 1013k
772 $QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
773 $QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
776 echo "# resize --preallocation=falloc"
777 _make_test_img -o extended_l2=on 503k
778 $QEMU_IO -c 'write -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
779 $QEMU_IMG resize --preallocation=falloc "$TEST_IMG" 1013k
780 $QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
781 $QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
783 echo "# resize --preallocation=full"
784 _make_test_img -o extended_l2=on 503k
785 $QEMU_IO -c 'write -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
786 $QEMU_IMG resize --preallocation=full "$TEST_IMG" 1013k
787 $QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
788 $QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
791 echo "### qemu-img measure ###"
794 $QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=off
796 $QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=on
799 $QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=off
801 $QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=on
804 $QEMU_IMG measure --size 1M -O qcow2 -o cluster_size=8k,extended_l2=on
807 $QEMU_IMG measure --size 1024T -O qcow2 -o extended_l2=on
809 $QEMU_IMG measure --size 1025T -O qcow2 -o extended_l2=on
812 echo "### qemu-img amend ###"
814 _make_test_img -o extended_l2=on 1M
815 $QEMU_IMG amend -o extended_l2=off "$TEST_IMG" && echo "Unexpected pass"
817 _make_test_img -o extended_l2=off 1M
818 $QEMU_IMG amend -o extended_l2=on "$TEST_IMG" && echo "Unexpected pass"
821 echo "### Test copy-on-write on an image with snapshots ###"
823 _make_test_img -o extended_l2=on 1M
825 # For each cluster from #0 to #9 this loop zeroes subcluster #7
828 for c in $(seq 0 9); do
829 $QEMU_IO -c "write -q -z $((64*$c+14))k 2k" \
830 -c "write -q -P $((0xd0+$c)) $((64*$c+26))k 2k" \
831 -c "write -q -P $((0xe0+$c)) $((64*$c+36))k 2k" "$TEST_IMG"
835 # Create a snapshot and set l2_offset to the new L2 table
836 $QEMU_IMG snapshot -c snap1 "$TEST_IMG"
837 l2_offset=$((0x110000))
840 # in order to see how copy-on-write behaves in each case.
841 $QEMU_IO -c "write -q -P 0xf0 $((64*0+30))k 1k" \
842 -c "write -q -P 0xf1 $((64*1+20))k 1k" \
843 -c "write -q -P 0xf2 $((64*2+40))k 1k" \
844 -c "write -q -P 0xf3 $((64*3+26))k 1k" \
845 -c "write -q -P 0xf4 $((64*4+14))k 1k" \
846 -c "write -q -P 0xf5 $((64*5+1))k 1k" \
847 -c "write -q -z $((64*6+30))k 3k" \
848 -c "write -q -z $((64*7+26))k 2k" \
849 -c "write -q -z $((64*8+26))k 1k" \
850 -c "write -q -z $((64*9+12))k 1k" \
852 alloc="$(seq 13 18)"; zero="7" _verify_l2_bitmap 0
857 alloc="$(seq 0 18)"; zero="" _verify_l2_bitmap 5
861 alloc="13 18"; zero="6 7" _verify_l2_bitmap 9
874 open -o driver=$IMGFMT blkdebug::$TEST_IMG
875 break write_aio A
876 aio_write -P 10 30k 2k
877 wait_break A
878 aio_write -P 11 20k 2k
879 aio_write -P 12 40k 2k
880 resume A
888 open -o driver=$IMGFMT $TEST_IMG
889 read -q -P 10 30k 2k
890 read -q -P 11 20k 2k
891 read -q -P 12 40k 2k
895 _make_test_img -o extended_l2=on 1M
899 sed -e 's/\(20480\|40960\)/OFFSET/'
910 l2_offset=$((0x400000))
916 # Base (new backing): -- -- -- ... -- -- --
917 # Mid (old backing): -- 11 -- ... -- 22 --
918 # Top: -- -- -- ... -- -- --
926 TEST_IMG="$TEST_IMG.base" _make_test_img -o cluster_size=1M,extended_l2=on 1M
927 TEST_IMG="$TEST_IMG.mid" _make_test_img -o cluster_size=1M,extended_l2=on \
928 -b "$TEST_IMG.base" -F qcow2 1M
929 TEST_IMG="$TEST_IMG.top" _make_test_img -o cluster_size=1M,extended_l2=on \
930 -b "$TEST_IMG.mid" -F qcow2 1M
936 $QEMU_IO -c "write -P 0x11 32k 32k" \
937 -c "write -P 0x22 $(( 30 * 32 ))k 32k" \
944 $QEMU_IMG rebase -b "$TEST_IMG.base" -F qcow2 "$TEST_IMG.top"
949 $QEMU_IO -c "read -P 0x00 0 32k" \
950 -c "read -P 0x11 32k 32k" \
951 -c "read -P 0x00 64k $(( 28 * 32 ))k" \
952 -c "read -P 0x22 $(( 30 * 32 ))k 32k" \
953 -c "read -P 0x00 $(( 31 * 32 ))k 32k" \
966 TEST_IMG="$TEST_IMG.top" alloc="1 30" zero="" _verify_l2_bitmap 0
969 # subclusters. When compression is enabled and we allocate a new
977 # Base (new backing): |-- -- .. -- --|11 11 .. 11 11|-- -- .. -- --|
978 # Mid (old backing): |-- -- .. -- 22|-- -- .. -- --|33 -- .. -- --|
979 # Top: |-- -- .. -- --|-- -- -- -- --|-- -- .. -- --|
988 TEST_IMG="$TEST_IMG.base" _make_test_img -o cluster_size=1M,extended_l2=on 3M
989 TEST_IMG="$TEST_IMG.mid" _make_test_img -o cluster_size=1M,extended_l2=on \
990 -b "$TEST_IMG.base" -F qcow2 3M
991 TEST_IMG="$TEST_IMG.top" _make_test_img -o cluster_size=1M,extended_l2=on \
992 -b "$TEST_IMG.mid" -F qcow2 3M
998 $QEMU_IO -c "write -P 0x11 1M 1M" "$TEST_IMG.base" | _filter_qemu_io
999 $QEMU_IO -c "write -P 0x22 $(( 31 * 32 ))k 32k" \
1000 -c "write -P 0x33 $(( 64 * 32 ))k 32k" \
1007 $QEMU_IMG rebase -c -b "$TEST_IMG.base" -F qcow2 "$TEST_IMG.top"
1012 $QEMU_IMG map --output=json "$TEST_IMG.top" | _filter_testdir
1018 $QEMU_IO -c "read -P 0x22 $(( 31 * 32 ))k 32k" \
1019 -c "read -P 0x11 1M 1M" \
1020 -c "read -P 0x33 $(( 64 * 32 ))k 32k" \
1027 # For compressed clusters bitmap is always 0. For unallocated cluster
1028 # there should be no entry at all, thus bitmap is also 0.
1029 TEST_IMG="$TEST_IMG.top" alloc="" zero="" _verify_l2_bitmap 0
1035 rm -f $seq.full
1036 status=0