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 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # ~/attr -Fl a/b/c/d/foo
45 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
47 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
48 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
51 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
52 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
57 # filter out inode numbers to ordinal numbers
58 # (assumes they come in order)
62 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
65 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
66 | nawk -v inodefile=$tmp.inodes '
69 while (getline < inodefile > 0) {
75 for (i = 1; i <= NF; i++) {
78 $nextone = inodemap[$nextone]
91 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
92 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
96 # get standard environment, filters and checks
110 _scratch_mkfs_xfs >>$seqres.full 2>&1 \
111 || _fail "mkfs scratch failed"
112 _scratch_mkfs_xfs -i paths=1 >>$seqres.full 2>&1 \
113 || _notrun "i_paths not supported"
116 _scratch_mount >>$seqres.full 2>&1 \
117 || _fail "mount failed: $MOUNT_OPTIONS"
119 # real QA test starts here
124 echo "--- create some files and directories to work on ---"
131 touch dir2/dir3/file3
143 echo "--- check all is ok before we start ---"
145 xfs_check_ipaths $SCRATCH_MNT
146 xfs_repair_ipaths -n $SCRATCH_MNT
149 echo "--- now break some stuff ---"
154 echo "1. remove the EA"
156 ${ATTR_PROG} -Fl dir2/file2
157 stat_ino=`stat -iq dir2`
158 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
159 #echo "attrname = $attrname"
160 ${ATTR_PROG} -Fr "$attrname" dir2/file2
161 ${ATTR_PROG} -Fl dir2/file2
164 echo "2. change the EA name"
166 ${ATTR_PROG} -Fl dir2/dir3/file3
168 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
170 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue dir2/dir3/file3
171 ${ATTR_PROG} -Fl dir2/dir3/file3
174 echo "3. change the EA value"
176 ${ATTR_PROG} -Fl $d/file4
177 stat_ino=`stat -iq $d`
178 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
180 ${ATTR_PROG} -Fs "$attrname" -V "$attrvalue" $d/file4
181 ${ATTR_PROG} -Fl $d/file4
182 ${ATTR_PROG} -Fg "$attrname" $d/file4
185 echo "4. add an extra EA - diff name, same value"
187 ${ATTR_PROG} -Fl $d/file5
189 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
191 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file5
192 ${ATTR_PROG} -Fl $d/file5
193 ${ATTR_PROG} -Fg "$attrname" $d/file5
196 echo "5. add an extra EA - diff name, diff value"
198 ${ATTR_PROG} -Fl $d/file6
200 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
202 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file6
203 ${ATTR_PROG} -Fl $d/file6
204 ${ATTR_PROG} -Fg "$attrname" $d/file6
207 echo "6. give bad fmt'ed EA name and get rid of existing name"
211 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file7
212 # remove old attrname
214 stat_ino=`stat -iq $d`
215 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
216 ${ATTR_PROG} -Fr "$attrname" $d/file7
219 echo "--- now check it ---"
223 echo "xfs_check_ipaths"
225 xfs_check_ipaths $SCRATCH_MNT
228 echo "xfs_repair_ipaths"
230 xfs_repair_ipaths -n $SCRATCH_MNT
233 echo "--- now repair it ---"
237 echo "xfs_repair_ipaths"
239 xfs_repair_ipaths $SCRATCH_MNT
242 echo "--- now check it again ---"
247 echo "xfs_check_ipaths"
249 xfs_check_ipaths $SCRATCH_MNT
252 echo "xfs_repair_ipaths"
254 xfs_repair_ipaths -n $SCRATCH_MNT
257 _do_test 2>&1 | tee $seqres.full | _filter_inodes