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 _begin_fstest auto quick clone compress punch
13 # Import common functions.
17 # real QA test starts here
19 _require_scratch_reflink
20 _require_xfs_io_command "fpunch"
22 _scratch_mkfs >>$seqres.full 2>&1
23 _scratch_mount "-o compress"
25 # Create a file with 3 consecutive compressed extents, each corresponds to 128Kb
26 # of data (uncompressed size) and each is stored on disk as a 4Kb extent
27 # (compressed size, regardless of compression algorithm used).
28 # Each extent starts with 4Kb of zeroes, while the remaining bytes all have a
30 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 384K" \
31 -c "pwrite -S 0x00 0 4K" \
32 -c "pwrite -S 0x00 128K 4K" \
33 -c "pwrite -S 0x00 256K 4K" \
34 $SCRATCH_MNT/foobar | _filter_xfs_io
36 echo "File digest after initial creation:"
37 md5sum $SCRATCH_MNT/foobar | _filter_scratch
39 # Clone the first extent into offsets 128K and 256K.
40 $XFS_IO_PROG -c "reflink $SCRATCH_MNT/foobar 0 128K 128K" \
41 -c "reflink $SCRATCH_MNT/foobar 0 256K 128K" \
42 $SCRATCH_MNT/foobar | _filter_xfs_io
44 echo "File digest after reflinking:"
45 md5sum $SCRATCH_MNT/foobar | _filter_scratch
47 # Punch holes into the regions that are already full of zeroes.
48 $XFS_IO_PROG -c "fpunch 0 4K" \
53 echo "File digest after punching holes:"
54 md5sum $SCRATCH_MNT/foobar | _filter_scratch
56 echo 1 > /proc/sys/vm/drop_caches
58 echo "File digest after dropping page cache:"
59 md5sum $SCRATCH_MNT/foobar | _filter_scratch