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 modify it
10 # under the terms of version 2 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, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like. Any license provided herein, whether implied or
20 # otherwise, applies only to this software file. Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write the Free Software Foundation, Inc., 59
26 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
28 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
29 # Mountain View, CA 94043, or:
33 # For further information regarding this notice, see:
35 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #-----------------------------------------------------------------------
39 owner=tes@crackle.melbourne.sgi.com
42 echo "QA output created by $seq"
46 status=1 # failure is the default!
47 trap "_cleanup; exit \$status" 0 1 2 3 15
57 # ~/attr -Fl a/b/c/d/foo
58 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
60 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
61 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
64 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
65 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
70 # filter out inode numbers to ordinal numbers
71 # (assumes they come in order)
75 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
78 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
79 | nawk -v inodefile=$tmp.inodes '
82 while (getline < inodefile > 0) {
88 for (i = 1; i <= NF; i++) {
91 $nextone = inodemap[$nextone]
104 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
105 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
109 # get standard environment, filters and checks
118 rm -f $here/$seq.full
121 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
122 || _fail "mkfs scratch failed"
123 export MKFS_OPTIONS="$MKFS_OPTIONS -i paths=1"
124 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
125 || _notrun "i_paths not supported"
128 _scratch_mount >>$here/$seq.full 2>&1 \
129 || _fail "mount failed: $MOUNT_OPTIONS"
131 # real QA test starts here
136 echo "--- create some files and directories to work on ---"
143 touch dir2/dir3/file3
155 echo "--- check all is ok before we start ---"
157 xfs_check_ipaths $SCRATCH_MNT
158 xfs_repair_ipaths -n $SCRATCH_MNT
161 echo "--- now break some stuff ---"
166 echo "1. remove the EA"
169 stat_ino=`stat -iq dir2`
170 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
171 #echo "attrname = $attrname"
172 attr -Fr "$attrname" dir2/file2
176 echo "2. change the EA name"
178 attr -Fl dir2/dir3/file3
180 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
182 attr -Fs "$attrname" -V $attrvalue dir2/dir3/file3
183 attr -Fl dir2/dir3/file3
186 echo "3. change the EA value"
189 stat_ino=`stat -iq $d`
190 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
192 attr -Fs "$attrname" -V "$attrvalue" $d/file4
194 attr -Fg "$attrname" $d/file4
197 echo "4. add an extra EA - diff name, same value"
201 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
203 attr -Fs "$attrname" -V $attrvalue $d/file5
205 attr -Fg "$attrname" $d/file5
208 echo "5. add an extra EA - diff name, diff value"
212 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
214 attr -Fs "$attrname" -V $attrvalue $d/file6
216 attr -Fg "$attrname" $d/file6
219 echo "6. give bad fmt'ed EA name and get rid of existing name"
223 attr -Fs "$attrname" -V $attrvalue $d/file7
224 # remove old attrname
226 stat_ino=`stat -iq $d`
227 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
228 attr -Fr "$attrname" $d/file7
231 echo "--- now check it ---"
235 echo "xfs_check_ipaths"
237 xfs_check_ipaths $SCRATCH_MNT
240 echo "xfs_repair_ipaths"
242 xfs_repair_ipaths -n $SCRATCH_MNT
245 echo "--- now repair it ---"
249 echo "xfs_repair_ipaths"
251 xfs_repair_ipaths $SCRATCH_MNT
254 echo "--- now check it again ---"
259 echo "xfs_check_ipaths"
261 xfs_check_ipaths $SCRATCH_MNT
264 echo "xfs_repair_ipaths"
266 xfs_repair_ipaths -n $SCRATCH_MNT
269 _do_test 2>&1 | tee $seq.full | _filter_inodes