xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 187
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 187
6 #
7 # To test out the noattr2 flag which is broken in pv#980021
8 # Given an existing attr2 filesystem, we should be able to mount
9 # as noattr2 and go back to an attr1 filesystem.
10 #
11 # Test the case where there are no more features2 bits on and
12 # so the morebitsbit should be off.
13 #
14 . ./common/preamble
15 _begin_fstest attr auto quick
16
17 _filter_version()
18 {
19         tee -a $seqres.full | tr ',' '\n' | egrep 'ATTR|MORE|LAZY'
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/attr
25
26 # real QA test starts here
27 _supported_fs xfs
28
29 _require_scratch
30 _require_attrs
31 _require_attr_v1
32 _require_projid16bit
33
34 # Reset the options so that we can control what is going on here
35 export MKFS_OPTIONS=""
36 export MOUNT_OPTIONS=""
37
38 # lazysb, attr2 and other feature bits are held in features2 and will require
39 # morebitsbit on So test with lazysb and without it to see if the morebitsbit is
40 # okay etc. If the mkfs defaults change, these need to change as well.
41 MKFS_NO_LAZY="-m crc=0 -l lazy-count=0 -i projid32bit=0"
42 MKFS_LAZY="-m crc=0 -l lazy-count=1 -i projid32bit=0"
43
44 # ftype is also stored in features2, so we have to detect its presence in
45 # mkfs and disable it here too.
46 if _scratch_mkfs --help 2>&1 | grep -q "ftype="; then
47         MKFS_NO_LAZY="$MKFS_NO_LAZY -n ftype=0"
48         MKFS_LAZY="$MKFS_LAZY -n ftype=0"
49 fi
50
51 # Make sure that when we think we are testing with morebits off
52 # that we really are.
53 _scratch_mkfs -i attr=1 $MKFS_NO_LAZY  >/dev/null 2>&1
54 _scratch_xfs_db -c version 2>&1 >$tmp.db
55 if grep -i morebits $tmp.db
56 then
57         echo ""
58         echo "Need to update test $seq so that initial subtests do not use features2"
59         echo ""
60         exit
61 fi
62
63 echo ""
64 echo "*** 1. test attr2 mkfs and then noattr2 mount ***"
65 echo ""
66 echo "attr2 fs"
67 echo ""
68 _scratch_mkfs -i attr=2 $MKFS_NO_LAZY >/dev/null 2>&1
69 _scratch_xfs_db -r -c version 2>&1 | _filter_version
70 echo ""
71 echo "noattr2 fs"
72 echo ""
73 _scratch_mount -o noattr2
74 $UMOUNT_PROG $SCRATCH_MNT
75 _scratch_xfs_db -r -c version 2>&1 | _filter_version
76
77 # adding an EA will ensure the ATTR1 flag is turned on
78 echo ""
79 echo "*** 2. test attr2 mkfs and then noattr2 mount with 1 EA ***"
80 echo ""
81 echo "attr2 fs"
82 echo ""
83 _scratch_mkfs -i attr=2 $MKFS_NO_LAZY >/dev/null 2>&1
84 _scratch_xfs_db -r -c version 2>&1 | _filter_version
85 echo ""
86 echo "noattr2 fs"
87 echo ""
88 _scratch_mount -o noattr2
89 cd $SCRATCH_MNT
90 touch testfile
91 $SETFATTR_PROG -n user.test -v 0xbabe testfile
92 _getfattr testfile
93 cd $here
94 $UMOUNT_PROG $SCRATCH_MNT
95 _scratch_xfs_db -r -c version 2>&1 | _filter_version
96
97 echo ""
98 echo "*** 3. test noattr2 mount and lazy sb ***"
99 echo ""
100 echo ""
101 echo "attr2 fs"
102 echo ""
103 _scratch_mkfs -i attr=2 $MKFS_LAZY >/dev/null 2>&1
104 _scratch_xfs_db -r -c version 2>&1 | _filter_version
105 echo ""
106 echo "noattr2 fs"
107 echo ""
108 _scratch_mount -o noattr2
109 cd $SCRATCH_MNT
110 touch testfile
111 cd $here
112 $UMOUNT_PROG $SCRATCH_MNT
113 _scratch_xfs_db -r -c version 2>&1 | _filter_version
114
115 # success, all done
116 status=0
117 exit