4 # Test out xfs_repair_ipaths
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
25 owner=tes@crackle.melbourne.sgi.com
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # ~/attr -Fl a/b/c/d/foo
44 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
46 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
47 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
50 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
51 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
56 # filter out inode numbers to ordinal numbers
57 # (assumes they come in order)
61 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
64 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
65 | nawk -v inodefile=$tmp.inodes '
68 while (getline < inodefile > 0) {
74 for (i = 1; i <= NF; i++) {
77 $nextone = inodemap[$nextone]
90 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
91 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
95 # get standard environment, filters and checks
104 rm -f $here/$seq.full
107 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
108 || _fail "mkfs scratch failed"
109 _scratch_mkfs_xfs -i paths=1 >>$here/$seq.full 2>&1 \
110 || _notrun "i_paths not supported"
113 _scratch_mount >>$here/$seq.full 2>&1 \
114 || _fail "mount failed: $MOUNT_OPTIONS"
116 # real QA test starts here
121 echo "--- create some files and directories to work on ---"
128 touch dir2/dir3/file3
140 echo "--- check all is ok before we start ---"
142 xfs_check_ipaths $SCRATCH_MNT
143 xfs_repair_ipaths -n $SCRATCH_MNT
146 echo "--- now break some stuff ---"
151 echo "1. remove the EA"
154 stat_ino=`stat -iq dir2`
155 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
156 #echo "attrname = $attrname"
157 attr -Fr "$attrname" dir2/file2
161 echo "2. change the EA name"
163 attr -Fl dir2/dir3/file3
165 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
167 attr -Fs "$attrname" -V $attrvalue dir2/dir3/file3
168 attr -Fl dir2/dir3/file3
171 echo "3. change the EA value"
174 stat_ino=`stat -iq $d`
175 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
177 attr -Fs "$attrname" -V "$attrvalue" $d/file4
179 attr -Fg "$attrname" $d/file4
182 echo "4. add an extra EA - diff name, same value"
186 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
188 attr -Fs "$attrname" -V $attrvalue $d/file5
190 attr -Fg "$attrname" $d/file5
193 echo "5. add an extra EA - diff name, diff value"
197 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
199 attr -Fs "$attrname" -V $attrvalue $d/file6
201 attr -Fg "$attrname" $d/file6
204 echo "6. give bad fmt'ed EA name and get rid of existing name"
208 attr -Fs "$attrname" -V $attrvalue $d/file7
209 # remove old attrname
211 stat_ino=`stat -iq $d`
212 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
213 attr -Fr "$attrname" $d/file7
216 echo "--- now check it ---"
220 echo "xfs_check_ipaths"
222 xfs_check_ipaths $SCRATCH_MNT
225 echo "xfs_repair_ipaths"
227 xfs_repair_ipaths -n $SCRATCH_MNT
230 echo "--- now repair it ---"
234 echo "xfs_repair_ipaths"
236 xfs_repair_ipaths $SCRATCH_MNT
239 echo "--- now check it again ---"
244 echo "xfs_check_ipaths"
246 xfs_check_ipaths $SCRATCH_MNT
249 echo "xfs_repair_ipaths"
251 xfs_repair_ipaths -n $SCRATCH_MNT
254 _do_test 2>&1 | tee $seq.full | _filter_inodes