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
30 _require_scratch_reflink
31 _require_xfs_io_command "fpunch"
35 _scratch_mkfs >>$seqres.full 2>&1
36 _scratch_mount "-o compress"
38 # Create a file with 3 consecutive compressed extents, each corresponds to 128Kb
39 # of data (uncompressed size) and each is stored on disk as a 4Kb extent
40 # (compressed size, regardless of compression algorithm used).
41 # Each extent starts with 4Kb of zeroes, while the remaining bytes all have a
43 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 384K" \
44 -c "pwrite -S 0x00 0 4K" \
45 -c "pwrite -S 0x00 128K 4K" \
46 -c "pwrite -S 0x00 256K 4K" \
47 $SCRATCH_MNT/foobar | _filter_xfs_io
49 echo "File digest after initial creation:"
50 md5sum $SCRATCH_MNT/foobar | _filter_scratch
52 # Clone the first extent into offsets 128K and 256K.
53 $XFS_IO_PROG -c "reflink $SCRATCH_MNT/foobar 0 128K 128K" \
54 -c "reflink $SCRATCH_MNT/foobar 0 256K 128K" \
55 $SCRATCH_MNT/foobar | _filter_xfs_io
57 echo "File digest after reflinking:"
58 md5sum $SCRATCH_MNT/foobar | _filter_scratch
60 # Punch holes into the regions that are already full of zeroes.
61 $XFS_IO_PROG -c "fpunch 0 4K" \
66 echo "File digest after punching holes:"
67 md5sum $SCRATCH_MNT/foobar | _filter_scratch
69 echo 1 > /proc/sys/vm/drop_caches
71 echo "File digest after dropping page cache:"
72 md5sum $SCRATCH_MNT/foobar | _filter_scratch