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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
22 _scratch_unmount >> $seqres.full 2>&1
23 test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1
24 rm -f $tmp.* $TEST_DIR/$seq.rtvol
27 # get standard environment, filters and checks
31 # real QA test starts here
34 _require_command "$FILEFRAG_PROG" filefrag
35 _require_xfs_io_command "fpunch"
36 _require_xfs_io_command "fzero"
37 _require_xfs_io_command "fcollapse"
38 _require_xfs_io_command "finsert"
39 # Note that we don't _require_realtime because we synthesize a rt volume
40 # below. This also means we cannot run the post-test check.
41 _require_scratch_nocheck
44 echo "$@" | tee -a $seqres.full
52 -c "pwrite -S 0x57 -b $rextsize 0 $rextsize" \
53 -c "pwrite -S 0x58 -b $rextsize $rextsize $rextsize" \
54 -c "pwrite -S 0x59 -b $rextsize $((rextsize * 2)) $rextsize" \
56 "$file" >> $seqres.full
60 $FILEFRAG_PROG -v "$1" >> $seqres.full
61 od -tx1 -Ad -c "$1" >> $seqres.full
62 md5sum "$1" | _filter_scratch | tee -a $seqres.full
67 local sz=$((rextsize * 3))
68 local unaligned_sz=65536
69 local unaligned_off=$((rextsize * 2 + unaligned_sz))
70 local lunaligned_sz=$((rextsize * 2))
71 local lunaligned_off=$unaligned_sz
73 log "Format rtextsize=$rextsize"
75 _scratch_mkfs -r extsize=$rextsize >> $seqres.full
76 _try_scratch_mount || \
77 _notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
79 # Force all files to be realtime files
80 $XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
82 log "Test regular write, rextsize=$rextsize"
83 mk_file $SCRATCH_MNT/write $rextsize
84 check_file $SCRATCH_MNT/write
86 log "Test aligned falloc, rextsize=$rextsize"
87 $XFS_IO_PROG -f -c "falloc 0 $sz" $SCRATCH_MNT/falloc >> $seqres.full
88 check_file $SCRATCH_MNT/falloc
90 log "Test aligned fcollapse, rextsize=$rextsize"
91 mk_file $SCRATCH_MNT/collapse $rextsize
92 $XFS_IO_PROG -f -c "fcollapse $rextsize $rextsize" $SCRATCH_MNT/collapse >> $seqres.full
93 check_file $SCRATCH_MNT/collapse
95 log "Test aligned finsert, rextsize=$rextsize"
96 mk_file $SCRATCH_MNT/insert $rextsize
97 $XFS_IO_PROG -f -c "finsert $rextsize $rextsize" $SCRATCH_MNT/insert >> $seqres.full
98 check_file $SCRATCH_MNT/insert
100 log "Test aligned fzero, rextsize=$rextsize"
101 mk_file $SCRATCH_MNT/zero $rextsize
102 $XFS_IO_PROG -f -c "fzero $rextsize $rextsize" $SCRATCH_MNT/zero >> $seqres.full
103 check_file $SCRATCH_MNT/zero
105 log "Test aligned fpunch, rextsize=$rextsize"
106 mk_file $SCRATCH_MNT/punch $rextsize
107 $XFS_IO_PROG -f -c "fpunch $rextsize $rextsize" $SCRATCH_MNT/punch >> $seqres.full
108 check_file $SCRATCH_MNT/punch
110 log "Test unaligned falloc, rextsize=$rextsize"
111 $XFS_IO_PROG -f -c "falloc $unaligned_off $unaligned_sz" $SCRATCH_MNT/ufalloc >> $seqres.full
112 check_file $SCRATCH_MNT/ufalloc
114 log "Test unaligned fcollapse, rextsize=$rextsize"
115 mk_file $SCRATCH_MNT/ucollapse $rextsize
116 $XFS_IO_PROG -f -c "fcollapse $unaligned_off $unaligned_sz" $SCRATCH_MNT/ucollapse >> $seqres.full
117 check_file $SCRATCH_MNT/ucollapse
119 log "Test unaligned finsert, rextsize=$rextsize"
120 mk_file $SCRATCH_MNT/uinsert $rextsize
121 $XFS_IO_PROG -f -c "finsert $unaligned_off $unaligned_sz" $SCRATCH_MNT/uinsert >> $seqres.full
122 check_file $SCRATCH_MNT/uinsert
124 log "Test unaligned fzero, rextsize=$rextsize"
125 mk_file $SCRATCH_MNT/uzero $rextsize
126 $XFS_IO_PROG -f -c "fzero $unaligned_off $unaligned_sz" $SCRATCH_MNT/uzero >> $seqres.full
127 check_file $SCRATCH_MNT/uzero
129 log "Test unaligned fpunch, rextsize=$rextsize"
130 mk_file $SCRATCH_MNT/upunch $rextsize
131 $XFS_IO_PROG -f -c "fpunch $unaligned_off $unaligned_sz" $SCRATCH_MNT/upunch >> $seqres.full
132 check_file $SCRATCH_MNT/upunch
134 log "Test large unaligned fzero, rextsize=$rextsize"
135 mk_file $SCRATCH_MNT/luzero $rextsize
136 $XFS_IO_PROG -f -c "fzero $lunaligned_off $lunaligned_sz" $SCRATCH_MNT/luzero >> $seqres.full
137 check_file $SCRATCH_MNT/luzero
139 log "Test large unaligned fpunch, rextsize=$rextsize"
140 mk_file $SCRATCH_MNT/lpunch $rextsize
141 $XFS_IO_PROG -f -c "fpunch $lunaligned_off $lunaligned_sz" $SCRATCH_MNT/lpunch >> $seqres.full
142 check_file $SCRATCH_MNT/lpunch
144 log "Remount and compare"
146 check_file $SCRATCH_MNT/write
147 check_file $SCRATCH_MNT/falloc
148 check_file $SCRATCH_MNT/collapse
149 check_file $SCRATCH_MNT/insert
150 check_file $SCRATCH_MNT/zero
151 check_file $SCRATCH_MNT/punch
152 check_file $SCRATCH_MNT/ufalloc
153 check_file $SCRATCH_MNT/ucollapse
154 check_file $SCRATCH_MNT/uinsert
155 check_file $SCRATCH_MNT/uzero
156 check_file $SCRATCH_MNT/upunch
157 check_file $SCRATCH_MNT/luzero
158 check_file $SCRATCH_MNT/lpunch
160 log "Check everything, rextsize=$rextsize"
164 echo "Create fake rt volume"
165 $XFS_IO_PROG -f -c "truncate 400m" $TEST_DIR/$seq.rtvol
166 rtdev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
168 echo "Make sure synth rt volume works"
169 export USE_EXTERNAL=yes
170 export SCRATCH_RTDEV=$rtdev
171 _scratch_mkfs > $seqres.full
172 _try_scratch_mount || \
173 _notrun "Could not mount with synthetic rt volume"