xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 114
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 114
6 #
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.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick clone rmap collapse insert
13
14 # Import common functions.
15 . ./common/filter
16 . ./common/reflink
17
18 # real QA test starts here
19 _supported_fs xfs
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"
25
26 rm -f "$seqres.full"
27
28 echo "Format and mount"
29 _scratch_mkfs > "$seqres.full" 2>&1
30 _scratch_mount
31 blksz=65536
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)
37
38 echo "Create some files"
39 $XFS_IO_PROG -f \
40         -c "falloc 0 $len1" \
41         -c "pwrite -S 0x68 -b 1048576 0 $len1" \
42         $SCRATCH_MNT/f1 >> $seqres.full
43 $XFS_IO_PROG -f \
44         -c "falloc 0 $len2" \
45         -c "pwrite -S 0x68 -b 1048576 0 $len2" \
46         $SCRATCH_MNT/f2 >> $seqres.full
47
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"
52
53 echo "Insert and write file range"
54 $XFS_IO_PROG \
55         -c "finsert $((8 * blksz)) $blksz" \
56         -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
57         -c "fsync" \
58         $SCRATCH_MNT/f1 >> $seqres.full
59 $XFS_IO_PROG \
60         -c "finsert $((8 * blksz)) $blksz" \
61         -c "pwrite -S 0x69 $((8 * blksz)) $blksz" \
62         -c "fsync" \
63         $SCRATCH_MNT/f2 >> $seqres.full
64
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
69
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
76
77 echo "Remount"
78 _scratch_unmount
79 _scratch_xfs_check
80 _scratch_mount
81
82 echo "Collapse file"
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
85
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
92
93 echo "Check file"
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
98
99 # success, all done
100 status=0
101 exit