4 # Make sure that we can handle insert-range followed by collapse-range.
5 # In particular, make sure that fcollapse works for rmap when the
6 # extents on either side of the collapse area are mergeable.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
26 seqres="$RESULT_DIR/$seq"
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
45 # real QA test starts here
48 _require_test_program "punch-alternating"
49 _require_xfs_scratch_rmapbt
50 _require_xfs_io_command "fcollapse"
51 _require_xfs_io_command "finsert"
55 echo "Format and mount"
56 _scratch_mkfs > "$seqres.full" 2>&1
59 blocks1=150 # enough extents to force btree format
60 blocks2=16 # local format
61 len1=$((blocks1 * blksz))
62 len2=$((blocks2 * blksz))
63 file_blksz=$(_get_file_block_size $SCRATCH_MNT)
65 echo "Create some files"
68 -c "pwrite -S 0x68 -b 1048576 0 $len1" \
69 $SCRATCH_MNT/f1 >> $seqres.full
72 -c "pwrite -S 0x68 -b 1048576 0 $len2" \
73 $SCRATCH_MNT/f2 >> $seqres.full
75 ./src/punch-alternating -o $((16 * blksz / file_blksz)) \
76 -s $((blksz / file_blksz)) \
77 -i $((blksz * 2 / file_blksz)) \
78 $SCRATCH_MNT/f1 >> "$seqres.full"
80 echo "Insert and write file range"
82 -c "finsert $((8 * blksz)) $blksz" \
83 -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
85 $SCRATCH_MNT/f1 >> $seqres.full
87 -c "finsert $((8 * blksz)) $blksz" \
88 -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
90 $SCRATCH_MNT/f2 >> $seqres.full
92 # Make reflink copies to force it to use the fancy rmap operations.
93 # The test's functionality doesn't depend on the fs supporting reflink.
94 _cp_reflink $SCRATCH_MNT/f1 $SCRATCH_MNT/e1 >> $seqres.full 2>&1
95 _cp_reflink $SCRATCH_MNT/f2 $SCRATCH_MNT/e2 >> $seqres.full 2>&1
97 echo "f1 bmap" >> $seqres.full
98 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f1 >> $seqres.full
99 echo "f2 bmap" >> $seqres.full
100 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f2 >> $seqres.full
101 echo "fsmap" >> $seqres.full
102 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
110 $XFS_IO_PROG -c "fcollapse $((8 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full
111 $XFS_IO_PROG -c "fcollapse $((8 * blksz)) $blksz" $SCRATCH_MNT/f2 >> $seqres.full
113 echo "f1 bmap" >> $seqres.full
114 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f1 >> $seqres.full
115 echo "f2 bmap" >> $seqres.full
116 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f2 >> $seqres.full
117 echo "fsmap" >> $seqres.full
118 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
121 md5sum $SCRATCH_MNT/f1 | _filter_scratch
122 md5sum $SCRATCH_MNT/f2 | _filter_scratch
123 od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full
124 od -tx1 -Ad -c $SCRATCH_MNT/f2 >> $seqres.full