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 export MKFS_OPTIONS="$MKFS_OPTIONS -i paths=1"
122 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
123 || _fail "mkfs scratch failed"
126 _scratch_mount >>$here/$seq.full 2>&1 \
127 || _fail "mount failed: $MOUNT_OPTIONS"
129 # real QA test starts here
134 echo "--- create some files and directories to work on ---"
141 touch dir2/dir3/file3
153 echo "--- check all is ok before we start ---"
155 xfs_check_ipaths $SCRATCH_MNT
156 xfs_repair_ipaths -n $SCRATCH_MNT
159 echo "--- now break some stuff ---"
164 echo "1. remove the EA"
167 stat_ino=`stat -iq dir2`
168 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
169 #echo "attrname = $attrname"
170 attr -Fr "$attrname" dir2/file2
174 echo "2. change the EA name"
176 attr -Fl dir2/dir3/file3
178 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
180 attr -Fs "$attrname" -V $attrvalue dir2/dir3/file3
181 attr -Fl dir2/dir3/file3
184 echo "3. change the EA value"
187 stat_ino=`stat -iq $d`
188 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
190 attr -Fs "$attrname" -V "$attrvalue" $d/file4
192 attr -Fg "$attrname" $d/file4
195 echo "4. add an extra EA - diff name, same value"
199 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
201 attr -Fs "$attrname" -V $attrvalue $d/file5
203 attr -Fg "$attrname" $d/file5
206 echo "5. add an extra EA - diff name, diff value"
210 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
212 attr -Fs "$attrname" -V $attrvalue $d/file6
214 attr -Fg "$attrname" $d/file6
217 echo "6. give bad fmt'ed EA name and get rid of existing name"
221 attr -Fs "$attrname" -V $attrvalue $d/file7
222 # remove old attrname
224 stat_ino=`stat -iq $d`
225 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
226 attr -Fr "$attrname" $d/file7
229 echo "--- now check it ---"
233 echo "xfs_check_ipaths"
235 xfs_check_ipaths $SCRATCH_MNT
238 echo "xfs_repair_ipaths"
240 xfs_repair_ipaths -n $SCRATCH_MNT
243 echo "--- now repair it ---"
247 echo "xfs_repair_ipaths"
249 xfs_repair_ipaths $SCRATCH_MNT
252 echo "--- now check it again ---"
257 echo "xfs_check_ipaths"
259 xfs_check_ipaths $SCRATCH_MNT
262 echo "xfs_repair_ipaths"
264 xfs_repair_ipaths -n $SCRATCH_MNT
267 _do_test 2>&1 | tee $seq.full | _filter_inodes