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
46 _require_xfs_io_command "falloc"
48 LOOP_IMG=$TEST_DIR/$seq.dev
49 LOOP_SPARE_IMG=$TEST_DIR/$seq.logdev
50 LOOP_MNT=$TEST_DIR/$seq.mnt
52 echo "** create loop device"
53 $XFS_IO_PROG -f -c "truncate 32g" $LOOP_IMG
54 LOOP_DEV=`_create_loop_device $LOOP_IMG`
56 echo "** create loop log device"
57 $XFS_IO_PROG -f -c "truncate 1g" $LOOP_SPARE_IMG
58 LOOP_SPARE_DEV=`_create_loop_device $LOOP_SPARE_IMG`
60 echo "** create loop mount point"
61 rmdir $LOOP_MNT 2>/dev/null
62 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
66 sed -e "s,\B$LOOP_MNT,LOOP_MNT,g" \
67 -e "s,\B$LOOP_DEV,LOOP_DEV,g" \
68 -e "s,\B$LOOP_SPARE_DEV,LOOP_SPARE_DEV,g"
73 sed -e "s,allocsize=$pagesz,allocsize=PAGESIZE,g"
76 # avoid the effection from MKFS_OPTIONS
80 echo "FORMAT: $@" | filter_loop | tee -a $seqres.full
81 $MKFS_XFS_PROG -f $* $LOOP_DEV | _filter_mkfs >>$seqres.full 2>$tmp.mkfs
82 if [ "${PIPESTATUS[0]}" -ne 0 ]; then
83 _fail "Fails on _mkfs_dev $* $LOOP_DEV"
90 findmnt --source $LOOP_DEV >/dev/null
96 findmnt --source $LOOP_DEV -o OPTIONS -n
101 $UMOUNT_PROG $LOOP_MNT >/dev/null 2>&1
104 # _do_test <mount options> <should be mounted?> [<key string> <key should be found?>]
108 local mounted="$2" # pass or fail
110 local found="$4" # true or false
115 _mount $LOOP_DEV $LOOP_MNT $opts 2>>$seqres.full
117 if [ $rc -eq 0 ];then
118 if [ "${mounted}" = "fail" ];then
119 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
120 echo "ERROR: expect mount to fail, but it succeeded"
125 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
126 echo "ERROR: fs not mounted even mount return 0"
130 if [ "${mounted}" = "pass" ];then
131 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
132 echo "ERROR: expect mount to succeed, but it failed"
137 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
138 echo "ERROR: fs is mounted even mount return non-zero"
143 # Skip below checking if "$key" argument isn't specified
144 if [ -z "$key" ];then
147 # Check the mount options after fs mounted.
148 info=`get_mount_info`
149 echo ${info} | grep -q "${key}"
151 if [ $rc -eq 0 ];then
152 if [ "$found" != "true" ];then
153 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
154 echo "ERROR: expected to find \"$key\" in mount info \"$info\""
158 if [ "$found" != "false" ];then
159 echo "[FAILED]: mount $LOOP_DEV $LOOP_MNT $opts"
160 echo "ERROR: did not expect to find \"$key\" in \"$info\""
170 # Print each argument, include nil ones
171 echo -n "TEST:" | tee -a $seqres.full
173 echo -n " \"$i\"" | filter_loop | filter_xfs_opt | tee -a $seqres.full
175 echo | tee -a $seqres.full
177 # force unmount before testing
180 # force unmount after testing
184 echo "** start xfs mount testing ..."
185 # Test allocsize=size
186 # Valid values for this option are page size (typically 4KiB) through to 1GiB
188 pagesz=$(get_page_size)
189 if [ $pagesz -ge 1024 ];then
190 pagesz="$((pagesz / 1024))k"
192 do_test "" pass "allocsize" "false"
193 do_test "-o allocsize=$pagesz" pass "allocsize=$pagesz" "true"
194 do_test "-o allocsize=1048576k" pass "allocsize=1048576k" "true"
195 do_test "-o allocsize=$((dbsize / 2))" fail
196 do_test "-o allocsize=2g" fail
200 do_test "" pass "attr2" "true"
201 do_test "-o attr2" pass "attr2" "true"
202 do_test "-o noattr2" fail
204 do_test "" pass "attr2" "true"
205 do_test "-o attr2" pass "attr2" "true"
206 do_test "-o noattr2" pass "attr2" "false"
210 do_test "" pass "discard" "false"
211 do_test "-o discard" pass "discard" "true"
212 do_test "-o nodiscard" pass "discard" "false"
214 # Test grpid|bsdgroups|nogrpid|sysvgroups
215 do_test "" pass "grpid" "false"
216 do_test "-o grpid" pass "grpid" "true"
217 do_test "-o bsdgroups" pass "grpid" "true"
218 do_test "-o nogrpid" pass "grpid" "false"
219 do_test "-o sysvgroups" pass "grpid" "false"
222 do_test "" pass "filestreams" "false"
223 do_test "-o filestreams" pass "filestreams" "true"
226 do_test "" pass "ikeep" "false"
227 do_test "-o ikeep" pass "ikeep" "true"
228 do_test "-o noikeep" pass "ikeep" "false"
230 # Test inode32|inode64
231 do_test "" pass "inode64" "true"
232 do_test "-o inode32" pass "inode32" "true"
233 do_test "-o inode64" pass "inode64" "true"
236 do_test "" pass "largeio" "false"
237 do_test "-o largeio" pass "largeio" "true"
238 do_test "-o nolargeio" pass "largeio" "false"
240 # Test logbufs=value. Valid numbers range from 2–8 inclusive.
241 # New kernel (refer to 4f62282a3696 xfs: cleanup xlog_get_iclog_buffer_size)
242 # prints "logbufs=N" in /proc/mounts, but old kernel not. So the default
243 # 'display' about logbufs can't be expected, disable this test.
244 #do_test "" pass "logbufs" "false"
245 do_test "-o logbufs=8" pass "logbufs=8" "true"
246 do_test "-o logbufs=2" pass "logbufs=2" "true"
247 do_test "-o logbufs=1" fail
248 do_test "-o logbufs=9" fail
249 do_test "-o logbufs=99999999999999" fail
251 # Test logbsize=value.
252 do_mkfs -m crc=1 -l version=2
253 # New kernel (refer to 4f62282a3696 xfs: cleanup xlog_get_iclog_buffer_size)
254 # prints "logbsize=N" in /proc/mounts, but old kernel not. So the default
255 # 'display' about logbsize can't be expected, disable this test.
256 #do_test "" pass "logbsize" "false"
257 do_test "-o logbsize=16384" pass "logbsize=16k" "true"
258 do_test "-o logbsize=16k" pass "logbsize=16k" "true"
259 do_test "-o logbsize=32k" pass "logbsize=32k" "true"
260 do_test "-o logbsize=64k" pass "logbsize=64k" "true"
261 do_test "-o logbsize=128k" pass "logbsize=128k" "true"
262 do_test "-o logbsize=256k" pass "logbsize=256k" "true"
263 do_test "-o logbsize=8k" fail
264 do_test "-o logbsize=512k" fail
265 do_mkfs -m crc=0 -l version=1
266 # New kernel (refer to 4f62282a3696 xfs: cleanup xlog_get_iclog_buffer_size)
267 # prints "logbsize=N" in /proc/mounts, but old kernel not. So the default
268 # 'display' about logbsize can't be expected, disable this test.
269 #do_test "" pass "logbsize" "false"
270 do_test "-o logbsize=16384" pass "logbsize=16k" "true"
271 do_test "-o logbsize=16k" pass "logbsize=16k" "true"
272 do_test "-o logbsize=32k" pass "logbsize=32k" "true"
273 do_test "-o logbsize=64k" fail
277 do_test "" pass "logdev" "false"
278 do_test "-o logdev=$LOOP_SPARE_DEV" fail
279 do_mkfs -l logdev=$LOOP_SPARE_DEV
280 do_test "-o logdev=$LOOP_SPARE_DEV" pass "logdev=$LOOP_SPARE_DEV" "true"
285 do_test "" pass "noalign" "false"
286 do_test "-o noalign" pass "noalign" "true"
289 do_test "" pass "norecovery" "false"
290 do_test "-o norecovery,ro" pass "norecovery" "true"
291 do_test "-o norecovery" fail
294 do_test "" pass "nouuid" "false"
295 do_test "-o nouuid" pass "nouuid" "true"
298 do_test "" pass "noquota" "true"
299 do_test "-o noquota" pass "noquota" "true"
301 # Test uquota/usrquota/quota/uqnoenforce/qnoenforce
302 do_test "" pass "usrquota" "false"
303 do_test "-o uquota" pass "usrquota" "true"
304 do_test "-o usrquota" pass "usrquota" "true"
305 do_test "-o quota" pass "usrquota" "true"
306 do_test "-o uqnoenforce" pass "usrquota" "true"
307 do_test "-o qnoenforce" pass "usrquota" "true"
309 # Test gquota/grpquota/gqnoenforce
310 do_test "" pass "grpquota" "false"
311 do_test "-o gquota" pass "grpquota" "true"
312 do_test "-o grpquota" pass "grpquota" "true"
313 do_test "-o gqnoenforce" pass "gqnoenforce" "true"
315 # Test pquota/prjquota/pqnoenforce
316 do_test "" pass "prjquota" "false"
317 do_test "-o pquota" pass "prjquota" "true"
318 do_test "-o prjquota" pass "prjquota" "true"
319 do_test "-o pqnoenforce" pass "pqnoenforce" "true"
321 # Test sunit=value and swidth=value
322 do_mkfs -d sunit=128,swidth=128
323 do_test "-o sunit=8,swidth=8" pass "sunit=8,swidth=8" "true"
324 do_test "-o sunit=8,swidth=64" pass "sunit=8,swidth=64" "true"
325 do_test "-o sunit=128,swidth=128" pass "sunit=128,swidth=128" "true"
326 do_test "-o sunit=256,swidth=256" pass "sunit=256,swidth=256" "true"
327 do_test "-o sunit=2,swidth=2" fail
331 do_test "" pass "swalloc" "false"
332 do_test "-o swalloc" pass "swalloc" "true"
335 do_test "" pass "wsync" "false"
336 do_test "-o wsync" pass "wsync" "true"
338 echo "** end of testing"