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 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # ~/attr -Fl a/b/c/d/foo
43 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
45 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
46 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
49 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
50 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
55 # filter out inode numbers to ordinal numbers
56 # (assumes they come in order)
60 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
63 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
64 | nawk -v inodefile=$tmp.inodes '
67 while (getline < inodefile > 0) {
73 for (i = 1; i <= NF; i++) {
76 $nextone = inodemap[$nextone]
89 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
90 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
93 # get standard environment, filters and checks
107 _scratch_mkfs_xfs >>$seqres.full 2>&1 \
108 || _fail "mkfs scratch failed"
109 _scratch_mkfs_xfs -i paths=1 >>$seqres.full 2>&1 \
110 || _notrun "i_paths not supported"
113 _scratch_mount >>$seqres.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
139 echo "--- check all is ok before we start ---"
141 xfs_check_ipaths $SCRATCH_MNT
142 xfs_repair_ipaths -n $SCRATCH_MNT
145 echo "--- now break some stuff ---"
150 echo "1. remove the EA"
152 ${ATTR_PROG} -Fl dir2/file2
153 stat_ino=`stat -iq dir2`
154 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
155 #echo "attrname = $attrname"
156 ${ATTR_PROG} -Fr "$attrname" dir2/file2
157 ${ATTR_PROG} -Fl dir2/file2
160 echo "2. change the EA name"
162 ${ATTR_PROG} -Fl dir2/dir3/file3
164 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
166 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue dir2/dir3/file3
167 ${ATTR_PROG} -Fl dir2/dir3/file3
170 echo "3. change the EA value"
172 ${ATTR_PROG} -Fl $d/file4
173 stat_ino=`stat -iq $d`
174 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
176 ${ATTR_PROG} -Fs "$attrname" -V "$attrvalue" $d/file4
177 ${ATTR_PROG} -Fl $d/file4
178 ${ATTR_PROG} -Fg "$attrname" $d/file4
181 echo "4. add an extra EA - diff name, same value"
183 ${ATTR_PROG} -Fl $d/file5
185 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
187 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file5
188 ${ATTR_PROG} -Fl $d/file5
189 ${ATTR_PROG} -Fg "$attrname" $d/file5
192 echo "5. add an extra EA - diff name, diff value"
194 ${ATTR_PROG} -Fl $d/file6
196 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
198 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file6
199 ${ATTR_PROG} -Fl $d/file6
200 ${ATTR_PROG} -Fg "$attrname" $d/file6
203 echo "6. give bad fmt'ed EA name and get rid of existing name"
207 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file7
208 # remove old attrname
210 stat_ino=`stat -iq $d`
211 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
212 ${ATTR_PROG} -Fr "$attrname" $d/file7
215 echo "--- now check it ---"
219 echo "xfs_check_ipaths"
221 xfs_check_ipaths $SCRATCH_MNT
224 echo "xfs_repair_ipaths"
226 xfs_repair_ipaths -n $SCRATCH_MNT
229 echo "--- now repair it ---"
233 echo "xfs_repair_ipaths"
235 xfs_repair_ipaths $SCRATCH_MNT
238 echo "--- now check it again ---"
243 echo "xfs_check_ipaths"
245 xfs_check_ipaths $SCRATCH_MNT
248 echo "xfs_repair_ipaths"
250 xfs_repair_ipaths -n $SCRATCH_MNT
253 _do_test 2>&1 | tee $seqres.full | _filter_inodes