2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
7 # Regression test for read corruption of compressed and shared extents after
8 # punching holes into a file.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
14 status=1 # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
23 # get standard environment, filters and checks
28 # real QA test starts here
31 _require_scratch_reflink
32 _require_xfs_io_command "fpunch"
36 _scratch_mkfs >>$seqres.full 2>&1
37 _scratch_mount "-o compress"
39 # Create a file with 3 consecutive compressed extents, each corresponds to 128Kb
40 # of data (uncompressed size) and each is stored on disk as a 4Kb extent
41 # (compressed size, regardless of compression algorithm used).
42 # Each extent starts with 4Kb of zeroes, while the remaining bytes all have a
44 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 384K" \
45 -c "pwrite -S 0x00 0 4K" \
46 -c "pwrite -S 0x00 128K 4K" \
47 -c "pwrite -S 0x00 256K 4K" \
48 $SCRATCH_MNT/foobar | _filter_xfs_io
50 echo "File digest after initial creation:"
51 md5sum $SCRATCH_MNT/foobar | _filter_scratch
53 # Clone the first extent into offsets 128K and 256K.
54 $XFS_IO_PROG -c "reflink $SCRATCH_MNT/foobar 0 128K 128K" \
55 -c "reflink $SCRATCH_MNT/foobar 0 256K 128K" \
56 $SCRATCH_MNT/foobar | _filter_xfs_io
58 echo "File digest after reflinking:"
59 md5sum $SCRATCH_MNT/foobar | _filter_scratch
61 # Punch holes into the regions that are already full of zeroes.
62 $XFS_IO_PROG -c "fpunch 0 4K" \
67 echo "File digest after punching holes:"
68 md5sum $SCRATCH_MNT/foobar | _filter_scratch
70 echo 1 > /proc/sys/vm/drop_caches
72 echo "File digest after dropping page cache:"
73 md5sum $SCRATCH_MNT/foobar | _filter_scratch