2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Make sure that regular fallocate functions work ok when the realtime extent
8 # size is and isn't a power of 2.
11 _begin_fstest auto quick rw realtime
13 # Override the default cleanup function.
17 _scratch_unmount >> $seqres.full 2>&1
18 test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1
19 rm -f $tmp.* $TEST_DIR/$seq.rtvol
22 # Import common functions.
25 # real QA test starts here
28 _require_command "$FILEFRAG_PROG" filefrag
29 _require_xfs_io_command "fpunch"
30 _require_xfs_io_command "fzero"
31 _require_xfs_io_command "fcollapse"
32 _require_xfs_io_command "finsert"
33 # Note that we don't _require_realtime because we synthesize a rt volume
34 # below. This also means we cannot run the post-test check.
35 _require_scratch_nocheck
38 echo "$@" | tee -a $seqres.full
46 -c "pwrite -S 0x57 -b $rextsize 0 $rextsize" \
47 -c "pwrite -S 0x58 -b $rextsize $rextsize $rextsize" \
48 -c "pwrite -S 0x59 -b $rextsize $((rextsize * 2)) $rextsize" \
50 "$file" >> $seqres.full
54 $FILEFRAG_PROG -v "$1" >> $seqres.full
55 od -tx1 -Ad -c "$1" >> $seqres.full
56 md5sum "$1" | _filter_scratch | tee -a $seqres.full
61 local sz=$((rextsize * 3))
62 local unaligned_sz=65536
63 local unaligned_off=$((rextsize * 2 + unaligned_sz))
64 local lunaligned_sz=$((rextsize * 2))
65 local lunaligned_off=$unaligned_sz
67 log "Format rtextsize=$rextsize"
69 _scratch_mkfs -r extsize=$rextsize >> $seqres.full
70 _try_scratch_mount || \
71 _notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
73 # Force all files to be realtime files
74 _xfs_force_bdev realtime $SCRATCH_MNT
76 log "Test regular write, rextsize=$rextsize"
77 mk_file $SCRATCH_MNT/write $rextsize
78 check_file $SCRATCH_MNT/write
80 log "Test aligned falloc, rextsize=$rextsize"
81 $XFS_IO_PROG -f -c "falloc 0 $sz" $SCRATCH_MNT/falloc >> $seqres.full
82 check_file $SCRATCH_MNT/falloc
84 log "Test aligned fcollapse, rextsize=$rextsize"
85 mk_file $SCRATCH_MNT/collapse $rextsize
86 $XFS_IO_PROG -f -c "fcollapse $rextsize $rextsize" $SCRATCH_MNT/collapse >> $seqres.full
87 check_file $SCRATCH_MNT/collapse
89 log "Test aligned finsert, rextsize=$rextsize"
90 mk_file $SCRATCH_MNT/insert $rextsize
91 $XFS_IO_PROG -f -c "finsert $rextsize $rextsize" $SCRATCH_MNT/insert >> $seqres.full
92 check_file $SCRATCH_MNT/insert
94 log "Test aligned fzero, rextsize=$rextsize"
95 mk_file $SCRATCH_MNT/zero $rextsize
96 $XFS_IO_PROG -f -c "fzero $rextsize $rextsize" $SCRATCH_MNT/zero >> $seqres.full
97 check_file $SCRATCH_MNT/zero
99 log "Test aligned fpunch, rextsize=$rextsize"
100 mk_file $SCRATCH_MNT/punch $rextsize
101 $XFS_IO_PROG -f -c "fpunch $rextsize $rextsize" $SCRATCH_MNT/punch >> $seqres.full
102 check_file $SCRATCH_MNT/punch
104 log "Test unaligned falloc, rextsize=$rextsize"
105 $XFS_IO_PROG -f -c "falloc $unaligned_off $unaligned_sz" $SCRATCH_MNT/ufalloc >> $seqres.full
106 check_file $SCRATCH_MNT/ufalloc
108 log "Test unaligned fcollapse, rextsize=$rextsize"
109 mk_file $SCRATCH_MNT/ucollapse $rextsize
110 $XFS_IO_PROG -f -c "fcollapse $unaligned_off $unaligned_sz" $SCRATCH_MNT/ucollapse >> $seqres.full
111 check_file $SCRATCH_MNT/ucollapse
113 log "Test unaligned finsert, rextsize=$rextsize"
114 mk_file $SCRATCH_MNT/uinsert $rextsize
115 $XFS_IO_PROG -f -c "finsert $unaligned_off $unaligned_sz" $SCRATCH_MNT/uinsert >> $seqres.full
116 check_file $SCRATCH_MNT/uinsert
118 log "Test unaligned fzero, rextsize=$rextsize"
119 mk_file $SCRATCH_MNT/uzero $rextsize
120 $XFS_IO_PROG -f -c "fzero $unaligned_off $unaligned_sz" $SCRATCH_MNT/uzero >> $seqres.full
121 check_file $SCRATCH_MNT/uzero
123 log "Test unaligned fpunch, rextsize=$rextsize"
124 mk_file $SCRATCH_MNT/upunch $rextsize
125 $XFS_IO_PROG -f -c "fpunch $unaligned_off $unaligned_sz" $SCRATCH_MNT/upunch >> $seqres.full
126 check_file $SCRATCH_MNT/upunch
128 log "Test large unaligned fzero, rextsize=$rextsize"
129 mk_file $SCRATCH_MNT/luzero $rextsize
130 $XFS_IO_PROG -f -c "fzero $lunaligned_off $lunaligned_sz" $SCRATCH_MNT/luzero >> $seqres.full
131 check_file $SCRATCH_MNT/luzero
133 log "Test large unaligned fpunch, rextsize=$rextsize"
134 mk_file $SCRATCH_MNT/lpunch $rextsize
135 $XFS_IO_PROG -f -c "fpunch $lunaligned_off $lunaligned_sz" $SCRATCH_MNT/lpunch >> $seqres.full
136 check_file $SCRATCH_MNT/lpunch
138 log "Remount and compare"
140 check_file $SCRATCH_MNT/write
141 check_file $SCRATCH_MNT/falloc
142 check_file $SCRATCH_MNT/collapse
143 check_file $SCRATCH_MNT/insert
144 check_file $SCRATCH_MNT/zero
145 check_file $SCRATCH_MNT/punch
146 check_file $SCRATCH_MNT/ufalloc
147 check_file $SCRATCH_MNT/ucollapse
148 check_file $SCRATCH_MNT/uinsert
149 check_file $SCRATCH_MNT/uzero
150 check_file $SCRATCH_MNT/upunch
151 check_file $SCRATCH_MNT/luzero
152 check_file $SCRATCH_MNT/lpunch
154 log "Check everything, rextsize=$rextsize"
158 echo "Create fake rt volume"
159 $XFS_IO_PROG -f -c "truncate 400m" $TEST_DIR/$seq.rtvol
160 rtdev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
162 echo "Make sure synth rt volume works"
163 export USE_EXTERNAL=yes
164 export SCRATCH_RTDEV=$rtdev
165 _scratch_mkfs > $seqres.full
166 _try_scratch_mount || \
167 _notrun "Could not mount with synthetic rt volume"