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 seqres="$RESULT_DIR/$seq"
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # real QA test starts here
33 _require_test_program "punch-alternating"
34 _require_xfs_scratch_rmapbt
35 _require_xfs_io_command "falloc"
36 _require_xfs_io_command "fcollapse"
37 _require_xfs_io_command "finsert"
41 echo "Format and mount"
42 _scratch_mkfs > "$seqres.full" 2>&1
45 blocks1=150 # enough extents to force btree format
46 blocks2=16 # local format
47 len1=$((blocks1 * blksz))
48 len2=$((blocks2 * blksz))
49 file_blksz=$(_get_file_block_size $SCRATCH_MNT)
51 echo "Create some files"
54 -c "pwrite -S 0x68 -b 1048576 0 $len1" \
55 $SCRATCH_MNT/f1 >> $seqres.full
58 -c "pwrite -S 0x68 -b 1048576 0 $len2" \
59 $SCRATCH_MNT/f2 >> $seqres.full
61 $here/src/punch-alternating -o $((16 * blksz / file_blksz)) \
62 -s $((blksz / file_blksz)) \
63 -i $((blksz * 2 / file_blksz)) \
64 $SCRATCH_MNT/f1 >> "$seqres.full"
66 echo "Insert and write file range"
68 -c "finsert $((8 * blksz)) $blksz" \
69 -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
71 $SCRATCH_MNT/f1 >> $seqres.full
73 -c "finsert $((8 * blksz)) $blksz" \
74 -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
76 $SCRATCH_MNT/f2 >> $seqres.full
78 # Make reflink copies to force it to use the fancy rmap operations.
79 # The test's functionality doesn't depend on the fs supporting reflink.
80 _cp_reflink $SCRATCH_MNT/f1 $SCRATCH_MNT/e1 >> $seqres.full 2>&1
81 _cp_reflink $SCRATCH_MNT/f2 $SCRATCH_MNT/e2 >> $seqres.full 2>&1
83 echo "f1 bmap" >> $seqres.full
84 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f1 >> $seqres.full
85 echo "f2 bmap" >> $seqres.full
86 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f2 >> $seqres.full
87 echo "fsmap" >> $seqres.full
88 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
96 $XFS_IO_PROG -c "fcollapse $((8 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full
97 $XFS_IO_PROG -c "fcollapse $((8 * blksz)) $blksz" $SCRATCH_MNT/f2 >> $seqres.full
99 echo "f1 bmap" >> $seqres.full
100 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f1 >> $seqres.full
101 echo "f2 bmap" >> $seqres.full
102 $XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/f2 >> $seqres.full
103 echo "fsmap" >> $seqres.full
104 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
107 md5sum $SCRATCH_MNT/f1 | _filter_scratch
108 md5sum $SCRATCH_MNT/f2 | _filter_scratch
109 od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full
110 od -tx1 -Ad -c $SCRATCH_MNT/f2 >> $seqres.full