f521a5d90ee7cc058cbf6ef297c0f37a539a8f8b
[xfstests-dev.git] / tests / xfs / 187
1 #! /bin/bash
2 # FS QA Test No. 187
3 #
4 # To test out the noattr2 flag which is broken in pv#980021
5 # Given an existing attr2 filesystem, we should be able to mount
6 # as noattr2 and go back to an attr1 filesystem.
7 #
8 # Test the case where there are no more features2 bits on and
9 # so the morebitsbit should be off.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #
27 #-----------------------------------------------------------------------
28 #
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 seqres=$RESULT_DIR/$seq
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43     cd /
44     rm -f $tmp.*
45 }
46
47 _filter_version()
48 {
49         tee -a $seqres.full | tr ',' '\n' | egrep 'ATTR|MORE|LAZY'
50 }
51
52 # get standard environment, filters and checks
53 . ./common/rc
54 . ./common/filter
55 . ./common/attr
56
57 # real QA test starts here
58 _supported_fs xfs
59 _supported_os Linux
60
61 _require_scratch
62 _require_attrs
63
64 rm -f $seqres.full
65
66 # lazysb and attr2 are in features2 and will require morebitsbit on
67 # So test with lazysb and without it to see if the morebitsbit is
68 # okay etc....
69 # Reset the options so that we can control what is going on here
70 export MKFS_OPTIONS=""
71 export MOUNT_OPTIONS=""
72
73 # Make sure that when we think we are testing with morebits off
74 # that we really are.
75 # Trying to future-proof in case mkfs defaults change.
76 _scratch_mkfs -i attr=1 -l lazy-count=0 >/dev/null 2>&1
77 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 >$tmp.db
78 if grep -i morebits $tmp.db
79 then
80         echo ""
81         echo "Need to update test $seq so that initial subtests do not use features2"
82         echo ""
83         exit
84 fi
85
86 echo ""
87 echo "*** 1. test attr2 mkfs and then noattr2 mount ***"
88 echo ""
89 echo "attr2 fs"
90 echo ""
91 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
92 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
93 echo ""
94 echo "noattr2 fs"
95 echo ""
96 _scratch_mount -o noattr2
97 $UMOUNT_PROG $SCRATCH_MNT
98 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
99
100 # adding an EA will ensure the ATTR1 flag is turned on
101 echo ""
102 echo "*** 2. test attr2 mkfs and then noattr2 mount with 1 EA ***"
103 echo ""
104 echo "attr2 fs"
105 echo ""
106 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
107 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
108 echo ""
109 echo "noattr2 fs"
110 echo ""
111 _scratch_mount -o noattr2
112 cd $SCRATCH_MNT
113 touch testfile
114 $SETFATTR_PROG -n user.test -v 0xbabe testfile
115 $GETFATTR_PROG testfile
116 cd $here
117 $UMOUNT_PROG $SCRATCH_MNT
118 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
119
120 echo ""
121 echo "*** 3. test noattr2 mount and lazy sb ***"
122 echo ""
123 echo ""
124 echo "attr2 fs"
125 echo ""
126 _scratch_mkfs -i attr=2 -l lazy-count=1 >/dev/null 2>&1
127 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
128 echo ""
129 echo "noattr2 fs"
130 echo ""
131 _scratch_mount -o noattr2
132 cd $SCRATCH_MNT
133 touch testfile
134 cd $here
135 $UMOUNT_PROG $SCRATCH_MNT
136 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
137
138 # success, all done
139 status=0
140 exit