2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
7 # Make sure that we can handle insert-range followed by collapse-range.
8 # In particular, make sure that fcollapse works for rmap when the
9 # extents on either side of the collapse area are mergeable.
12 _begin_fstest auto quick clone rmap collapse insert
14 # Import common functions.
18 # real QA test starts here
20 _require_test_program "punch-alternating"
21 _require_xfs_scratch_rmapbt
22 _require_xfs_io_command "falloc"
23 _require_xfs_io_command "fcollapse"
24 _require_xfs_io_command "finsert"
28 echo "Format and mount"
29 _scratch_mkfs > "$seqres.full" 2>&1
32 blocks1=150 # enough extents to force btree format
33 blocks2=16 # local format
34 len1=$((blocks1 * blksz))
35 len2=$((blocks2 * blksz))
36 file_blksz=$(_get_file_block_size $SCRATCH_MNT)
38 echo "Create some files"
41 -c "pwrite -S 0x68 -b 1048576 0 $len1" \
42 $SCRATCH_MNT/f1 >> $seqres.full
45 -c "pwrite -S 0x68 -b 1048576 0 $len2" \
46 $SCRATCH_MNT/f2 >> $seqres.full
48 $here/src/punch-alternating -o $((16 * blksz / file_blksz)) \
49 -s $((blksz / file_blksz)) \
50 -i $((blksz * 2 / file_blksz)) \
51 $SCRATCH_MNT/f1 >> "$seqres.full"
53 echo "Insert and write file range"
55 -c "finsert $((8 * blksz)) $blksz" \
56 -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
58 $SCRATCH_MNT/f1 >> $seqres.full
60 -c "finsert $((8 * blksz)) $blksz" \
61 -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
63 $SCRATCH_MNT/f2 >> $seqres.full
65 # Make reflink copies to force it to use the fancy rmap operations.
66 # The test's functionality doesn't depend on the fs supporting reflink.
67 _cp_reflink $SCRATCH_MNT/f1 $SCRATCH_MNT/e1 >> $seqres.full 2>&1
68 _cp_reflink $SCRATCH_MNT/f2 $SCRATCH_MNT/e2 >> $seqres.full 2>&1
70 echo "f1 bmap" >> $seqres.full
71 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f1 >> $seqres.full
72 echo "f2 bmap" >> $seqres.full
73 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f2 >> $seqres.full
74 echo "fsmap" >> $seqres.full
75 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
83 $XFS_IO_PROG -c "fcollapse $((8 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full
84 $XFS_IO_PROG -c "fcollapse $((8 * blksz)) $blksz" $SCRATCH_MNT/f2 >> $seqres.full
86 echo "f1 bmap" >> $seqres.full
87 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f1 >> $seqres.full
88 echo "f2 bmap" >> $seqres.full
89 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f2 >> $seqres.full
90 echo "fsmap" >> $seqres.full
91 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
94 md5sum $SCRATCH_MNT/f1 | _filter_scratch
95 md5sum $SCRATCH_MNT/f2 | _filter_scratch
96 od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full
97 od -tx1 -Ad -c $SCRATCH_MNT/f2 >> $seqres.full