2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc. All Rights Reserved.
7 # XFS mount options sanity check, refer to 'man 5 xfs'.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
22 $UMOUNT_PROG $LOOP_MNT 2>/dev/null
23 if [ -n "$LOOP_DEV" ];then
24 _destroy_loop_device $LOOP_DEV 2>/dev/null
26 if [ -n "$LOOP_SPARE_DEV" ];then
27 _destroy_loop_device $LOOP_SPARE_DEV 2>/dev/null
34 # get standard environment, filters and checks
38 # remove previous $seqres.full before test
41 # real QA test starts here
45 _require_xfs_io_command "falloc"
47 LOOP_IMG=$TEST_DIR/$seq.dev
48 LOOP_SPARE_IMG=$TEST_DIR/$seq.logdev
49 LOOP_MNT=$TEST_DIR/$seq.mnt
51 echo "** create loop device"
52 $XFS_IO_PROG -f -c "truncate 32g" $LOOP_IMG
53 LOOP_DEV=`_create_loop_device $LOOP_IMG`
55 echo "** create loop log device"
56 $XFS_IO_PROG -f -c "truncate 1g" $LOOP_SPARE_IMG
57 LOOP_SPARE_DEV=`_create_loop_device $LOOP_SPARE_IMG`
59 echo "** create loop mount point"
60 rmdir $LOOP_MNT 2>/dev/null
61 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
65 sed -e "s,\B$LOOP_MNT,LOOP_MNT,g" \
66 -e "s,\B$LOOP_DEV,LOOP_DEV,g" \
67 -e "s,\B$LOOP_SPARE_DEV,LOOP_SPARE_DEV,g"
72 sed -e "s,allocsize=$pagesz,allocsize=PAGESIZE,g"
75 # avoid the effection from MKFS_OPTIONS
79 echo "FORMAT: $@" | filter_loop | tee -a $seqres.full
80 $MKFS_XFS_PROG -f $* $LOOP_DEV | _filter_mkfs >>$seqres.full 2>$tmp.mkfs
81 if [ "${PIPESTATUS[0]}" -ne 0 ]; then
82 _fail "Fails on _mkfs_dev $* $LOOP_DEV"
89 findmnt --source $LOOP_DEV >/dev/null
95 findmnt --source $LOOP_DEV -o OPTIONS -n
100 $UMOUNT_PROG $LOOP_MNT >/dev/null 2>&1
103 # _do_test <mount options> <should be mounted?> [<key string> <key should be found?>]
107 local mounted="$2" # pass or fail
109 local found="$4" # true or false
114 _mount $LOOP_DEV $LOOP_MNT $opts 2>>$seqres.full
116 if [ $rc -eq 0 ];then
117 if [ "${mounted}" = "fail" ];then
118 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
119 echo "ERROR: expect mount to fail, but it succeeded"
124 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
125 echo "ERROR: fs not mounted even mount return 0"
129 if [ "${mounted}" = "pass" ];then
130 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
131 echo "ERROR: expect mount to succeed, but it failed"
136 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
137 echo "ERROR: fs is mounted even mount return non-zero"
142 # Skip below checking if "$key" argument isn't specified
143 if [ -z "$key" ];then
146 # Check the mount options after fs mounted.
147 info=`get_mount_info`
148 echo ${info} | grep -q "${key}"
150 if [ $rc -eq 0 ];then
151 if [ "$found" != "true" ];then
152 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
153 echo "ERROR: expected to find \"$key\" in mount info \"$info\""
157 if [ "$found" != "false" ];then
158 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
159 echo "ERROR: did not expect to find \"$key\" in \"$info\""
169 # Print each argument, include nil ones
170 echo -n "TEST:" | tee -a $seqres.full
172 echo -n " \"$i\"" | filter_loop | filter_xfs_opt | tee -a $seqres.full
174 echo | tee -a $seqres.full
176 # force unmount before testing
179 # force unmount after testing
183 echo "** start xfs mount testing ..."
184 # Test allocsize=size
185 # Valid values for this option are page size (typically 4KiB) through to 1GiB
187 pagesz=$(get_page_size)
188 if [ $pagesz -ge 1024 ];then
189 pagesz="$((pagesz / 1024))k"
191 do_test "" pass "allocsize" "false"
192 do_test "-o allocsize=$pagesz" pass "allocsize=$pagesz" "true"
193 do_test "-o allocsize=1048576k" pass "allocsize=1048576k" "true"
194 do_test "-o allocsize=$((dbsize / 2))" fail
195 do_test "-o allocsize=2g" fail
199 do_test "" pass "attr2" "true"
200 do_test "-o attr2" pass "attr2" "true"
201 do_test "-o noattr2" fail
203 do_test "" pass "attr2" "true"
204 do_test "-o attr2" pass "attr2" "true"
205 do_test "-o noattr2" pass "attr2" "false"
209 do_test "" pass "discard" "false"
210 do_test "-o discard" pass "discard" "true"
211 do_test "-o nodiscard" pass "discard" "false"
213 # Test grpid|bsdgroups|nogrpid|sysvgroups
214 do_test "" pass "grpid" "false"
215 do_test "-o grpid" pass "grpid" "true"
216 do_test "-o bsdgroups" pass "grpid" "true"
217 do_test "-o nogrpid" pass "grpid" "false"
218 do_test "-o sysvgroups" pass "grpid" "false"
221 do_test "" pass "filestreams" "false"
222 do_test "-o filestreams" pass "filestreams" "true"
225 do_test "" pass "ikeep" "false"
226 do_test "-o ikeep" pass "ikeep" "true"
227 do_test "-o noikeep" pass "ikeep" "false"
229 # Test inode32|inode64
230 do_test "" pass "inode64" "true"
231 do_test "-o inode32" pass "inode32" "true"
232 do_test "-o inode64" pass "inode64" "true"
235 do_test "" pass "largeio" "false"
236 do_test "-o largeio" pass "largeio" "true"
237 do_test "-o nolargeio" pass "largeio" "false"
239 # Test logbufs=value. Valid numbers range from 2–8 inclusive.
240 # New kernel (refer to 4f62282a3696 xfs: cleanup xlog_get_iclog_buffer_size)
241 # prints "logbufs=N" in /proc/mounts, but old kernel not. So the default
242 # 'display' about logbufs can't be expected, disable this test.
243 #do_test "" pass "logbufs" "false"
244 do_test "-o logbufs=8" pass "logbufs=8" "true"
245 do_test "-o logbufs=2" pass "logbufs=2" "true"
246 do_test "-o logbufs=1" fail
247 do_test "-o logbufs=9" fail
248 do_test "-o logbufs=99999999999999" fail
250 # Test logbsize=value.
251 do_mkfs -m crc=1 -l version=2
252 # New kernel (refer to 4f62282a3696 xfs: cleanup xlog_get_iclog_buffer_size)
253 # prints "logbsize=N" in /proc/mounts, but old kernel not. So the default
254 # 'display' about logbsize can't be expected, disable this test.
255 #do_test "" pass "logbsize" "false"
256 do_test "-o logbsize=16384" pass "logbsize=16k" "true"
257 do_test "-o logbsize=16k" pass "logbsize=16k" "true"
258 do_test "-o logbsize=32k" pass "logbsize=32k" "true"
259 do_test "-o logbsize=64k" pass "logbsize=64k" "true"
260 do_test "-o logbsize=128k" pass "logbsize=128k" "true"
261 do_test "-o logbsize=256k" pass "logbsize=256k" "true"
262 do_test "-o logbsize=8k" fail
263 do_test "-o logbsize=512k" fail
264 do_mkfs -m crc=0 -l version=1
265 # New kernel (refer to 4f62282a3696 xfs: cleanup xlog_get_iclog_buffer_size)
266 # prints "logbsize=N" in /proc/mounts, but old kernel not. So the default
267 # 'display' about logbsize can't be expected, disable this test.
268 #do_test "" pass "logbsize" "false"
269 do_test "-o logbsize=16384" pass "logbsize=16k" "true"
270 do_test "-o logbsize=16k" pass "logbsize=16k" "true"
271 do_test "-o logbsize=32k" pass "logbsize=32k" "true"
272 do_test "-o logbsize=64k" fail
276 do_test "" pass "logdev" "false"
277 do_test "-o logdev=$LOOP_SPARE_DEV" fail
278 do_mkfs -l logdev=$LOOP_SPARE_DEV
279 do_test "-o logdev=$LOOP_SPARE_DEV" pass "logdev=$LOOP_SPARE_DEV" "true"
284 do_test "" pass "noalign" "false"
285 do_test "-o noalign" pass "noalign" "true"
288 do_test "" pass "norecovery" "false"
289 do_test "-o norecovery,ro" pass "norecovery" "true"
290 do_test "-o norecovery" fail
293 do_test "" pass "nouuid" "false"
294 do_test "-o nouuid" pass "nouuid" "true"
297 do_test "" pass "noquota" "true"
298 do_test "-o noquota" pass "noquota" "true"
300 # Test uquota/usrquota/quota/uqnoenforce/qnoenforce
301 do_test "" pass "usrquota" "false"
302 do_test "-o uquota" pass "usrquota" "true"
303 do_test "-o usrquota" pass "usrquota" "true"
304 do_test "-o quota" pass "usrquota" "true"
305 do_test "-o uqnoenforce" pass "usrquota" "true"
306 do_test "-o qnoenforce" pass "usrquota" "true"
308 # Test gquota/grpquota/gqnoenforce
309 do_test "" pass "grpquota" "false"
310 do_test "-o gquota" pass "grpquota" "true"
311 do_test "-o grpquota" pass "grpquota" "true"
312 do_test "-o gqnoenforce" pass "gqnoenforce" "true"
314 # Test pquota/prjquota/pqnoenforce
315 do_test "" pass "prjquota" "false"
316 do_test "-o pquota" pass "prjquota" "true"
317 do_test "-o prjquota" pass "prjquota" "true"
318 do_test "-o pqnoenforce" pass "pqnoenforce" "true"
320 # Test sunit=value and swidth=value
321 do_mkfs -d sunit=128,swidth=128
322 do_test "-o sunit=8,swidth=8" pass "sunit=8,swidth=8" "true"
323 do_test "-o sunit=8,swidth=64" pass "sunit=8,swidth=64" "true"
324 do_test "-o sunit=128,swidth=128" pass "sunit=128,swidth=128" "true"
325 do_test "-o sunit=256,swidth=256" pass "sunit=256,swidth=256" "true"
326 do_test "-o sunit=2,swidth=2" fail
330 do_test "" pass "swalloc" "false"
331 do_test "-o swalloc" pass "swalloc" "true"
334 do_test "" pass "wsync" "false"
335 do_test "-o wsync" pass "wsync" "true"
337 echo "** end of testing"