xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 424
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 424
6 #
7 # This case checks if setting type causes error.
8 #
9 # On crc filesystems, xfs_db doesn't take sector size into account
10 # when setting type, and this can result in an errant crc.
11 # This issue has been fixed in xfsprogs-dev:
12 # '55f224b ("xfs_db: update buffer size when new type is set")'
13 #
14 # On crc filesystems, when setting the type to "inode" the verifier
15 # validates multiple inodes in the current fs block, so setting the
16 # buffer size to that of just one inode is not sufficient and it'll
17 # emit spurious verifier errors for all but the first.
18 # This issue has been fixed in xfsprogs-dev:
19 # '533d1d2 ("xfs_db: properly set inode type")'
20 . ./common/preamble
21 _begin_fstest auto quick db
22
23 filter_dbval()
24 {
25         awk '{ print $4 }'
26 }
27
28 # Import common functions.
29 . ./common/filter
30
31 # Modify as appropriate
32 _supported_fs xfs
33
34 # Since we have an open-coded mkfs call, disable the external devices and
35 # don't let the post-check fsck actually run since it'll trip over us not
36 # using the external devices.
37 _require_scratch_nocheck
38 export SCRATCH_LOGDEV=
39 export SCRATCH_RTDEV=
40
41 echo "Silence is golden."
42
43 # real QA test starts here
44
45 # for different sector sizes, ensure no CRC errors are falsely reported.
46
47 # Supported types include: agf, agfl, agi, attr3, bmapbta,
48 # bmapbtd, bnobt, cntbt, data, dir3, dqblk, inobt, inodata,
49 # inode, log, rtbitmap, rtsummary, sb, symlink, text, finobt.
50 # For various sector sizes, test some types that involve type size.
51 #
52 # NOTE: skip attr3, bmapbta, bmapbtd, dir3, dqblk, inodata, symlink
53 # rtbitmap, rtsummary, log
54 #
55 sec_sz=`_min_dio_alignment $SCRATCH_DEV`
56 while [ $sec_sz -le 4096 ]; do
57         sector_sizes="$sector_sizes $sec_sz"
58         sec_sz=$((sec_sz * 2))
59 done
60
61 for SECTOR_SIZE in $sector_sizes; do
62         finobt_enabled=0
63         $MKFS_XFS_PROG -f -s size=$SECTOR_SIZE $SCRATCH_DEV | \
64                 grep -q 'finobt=1' && finobt_enabled=1
65
66         for TYPE in agf agi agfl sb; do
67                 DADDR=`_scratch_xfs_db -c "$TYPE" -c "daddr" | filter_dbval`
68                 _scratch_xfs_db -c "daddr $DADDR" -c "type $TYPE"
69         done
70
71         DADDR=`_scratch_xfs_db -c "sb" -c "addr rootino" -c "daddr" |
72                 filter_dbval`
73         _scratch_xfs_db -c "daddr $DADDR" -c "type inode"
74         DADDR=`_scratch_xfs_db -c "agf" -c "addr bnoroot" -c "daddr" |
75                 filter_dbval`
76         _scratch_xfs_db -c "daddr $DADDR" -c "type bnobt"
77         DADDR=`_scratch_xfs_db -c "agf" -c "addr cntroot" -c "daddr" |
78                 filter_dbval`
79         _scratch_xfs_db -c "daddr $DADDR" -c "type cntbt"
80         DADDR=`_scratch_xfs_db -c "agi" -c "addr root" -c "daddr" |
81                 filter_dbval`
82         _scratch_xfs_db -c "daddr $DADDR" -c "type inobt"
83         if [ $finobt_enabled -eq 1 ]; then
84                 DADDR=`_scratch_xfs_db -c "agi" -c "addr free_root" -c "daddr" |
85                         filter_dbval`
86                 _scratch_xfs_db -c "daddr $DADDR" -c "type finobt"
87         fi
88
89         _scratch_xfs_db -c "daddr $DADDR" -c "type text"
90         _scratch_xfs_db -c "daddr $DADDR" -c "type data"
91 done
92
93 # success, all done
94 status=0
95 exit