2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Check that we can upgrade a filesystem to support inobtcount and that
8 # everything works properly after the upgrade.
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
25 # get standard environment, filters and checks
29 # real QA test starts here
31 _require_scratch_xfs_inobtcount
32 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
33 _require_xfs_repair_upgrade inobtcount
37 # Make sure we can't format a filesystem with inobtcount and not finobt.
38 _scratch_mkfs -m crc=1,inobtcount=1,finobt=0 &> $seqres.full && \
39 echo "Should not be able to format with inobtcount but not finobt."
41 # Make sure we can't upgrade a V4 filesystem
42 _scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
43 _scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
44 _check_scratch_xfs_features INOBTCNT
46 # Make sure we can't upgrade a filesystem to inobtcount without finobt.
47 _scratch_mkfs -m crc=1,inobtcount=0,finobt=0 >> $seqres.full
48 _scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
49 _check_scratch_xfs_features INOBTCNT
51 # Format V5 filesystem without inode btree counter support and populate it.
52 _scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
55 mkdir $SCRATCH_MNT/stress
56 $FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
57 echo moo > $SCRATCH_MNT/urk
61 # Upgrade filesystem to have the counters and inject failure into repair and
62 # make sure that the only path forward is to re-run repair on the filesystem.
63 echo "Fail partway through upgrading"
64 XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
65 test $? -eq 137 || echo "repair should have been killed??"
66 _check_scratch_xfs_features NEEDSREPAIR INOBTCNT
67 _try_scratch_mount &> $tmp.mount
69 _filter_scratch < $tmp.mount
70 if [ $res -eq 0 ]; then
71 echo "needsrepair should have prevented mount"
75 echo "Re-run repair to finish upgrade"
76 _scratch_xfs_repair 2>> $seqres.full
77 _check_scratch_xfs_features NEEDSREPAIR INOBTCNT
79 echo "Filesystem should be usable again"
81 $FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
84 _check_scratch_xfs_features INOBTCNT
86 echo "Make sure we have nonzero counters"
87 _scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
88 sed -e 's/= 0$/= ZERO/g' -e 's/= [0-9]*/= NONZERO/g'
90 echo "Make sure we can't re-add inobtcount"
91 _scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
93 echo "Mount again, look at our files"
94 _scratch_mount >> $seqres.full