fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 158
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 158
6 #
7 # Check that we can upgrade a filesystem to support inobtcount and that
8 # everything works properly after the upgrade.
9
10 . ./common/preamble
11 _begin_fstest auto quick inobtcount
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17 _supported_fs xfs
18 _require_scratch_xfs_inobtcount
19 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
20 _require_xfs_repair_upgrade inobtcount
21
22 # Make sure we can't format a filesystem with inobtcount and not finobt.
23 _scratch_mkfs -m crc=1,inobtcount=1,finobt=0 &> $seqres.full && \
24         echo "Should not be able to format with inobtcount but not finobt."
25
26 # Make sure we can't upgrade a V4 filesystem
27 _scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
28 _scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
29 _check_scratch_xfs_features INOBTCNT
30
31 # Make sure we can't upgrade a filesystem to inobtcount without finobt.
32 _scratch_mkfs -m crc=1,inobtcount=0,finobt=0 >> $seqres.full
33 _scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
34 _check_scratch_xfs_features INOBTCNT
35
36 # Format V5 filesystem without inode btree counter support and populate it.
37 _scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
38 _scratch_mount
39
40 mkdir $SCRATCH_MNT/stress
41 $FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
42 echo moo > $SCRATCH_MNT/urk
43
44 _scratch_unmount
45
46 # Upgrade filesystem to have the counters and inject failure into repair and
47 # make sure that the only path forward is to re-run repair on the filesystem.
48 echo "Fail partway through upgrading"
49 XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
50 test $? -eq 137 || echo "repair should have been killed??"
51 _check_scratch_xfs_features NEEDSREPAIR INOBTCNT
52 _try_scratch_mount &> $tmp.mount
53 res=$?
54 _filter_scratch < $tmp.mount
55 if [ $res -eq 0 ]; then
56         echo "needsrepair should have prevented mount"
57         _scratch_unmount
58 fi
59
60 echo "Re-run repair to finish upgrade"
61 _scratch_xfs_repair 2>> $seqres.full
62 _check_scratch_xfs_features NEEDSREPAIR INOBTCNT
63
64 echo "Filesystem should be usable again"
65 _scratch_mount
66 $FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
67 _scratch_unmount
68 _check_scratch_fs
69 _check_scratch_xfs_features INOBTCNT
70
71 echo "Make sure we have nonzero counters"
72 _scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
73         sed -e 's/= 0$/= ZERO/g' -e 's/= [0-9]*/= NONZERO/g'
74
75 echo "Make sure we can't re-add inobtcount"
76 _scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
77
78 echo "Mount again, look at our files"
79 _scratch_mount >> $seqres.full
80 cat $SCRATCH_MNT/urk
81
82 status=0
83 exit