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 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # ~/attr -Fl a/b/c/d/foo
42 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
44 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
45 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
48 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
49 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
54 # filter out inode numbers to ordinal numbers
55 # (assumes they come in order)
59 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
62 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
63 | nawk -v inodefile=$tmp.inodes '
66 while (getline < inodefile > 0) {
72 for (i = 1; i <= NF; i++) {
75 $nextone = inodemap[$nextone]
88 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
89 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
93 # 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"
153 ${ATTR_PROG} -Fl dir2/file2
154 stat_ino=`stat -iq dir2`
155 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
156 #echo "attrname = $attrname"
157 ${ATTR_PROG} -Fr "$attrname" dir2/file2
158 ${ATTR_PROG} -Fl dir2/file2
161 echo "2. change the EA name"
163 ${ATTR_PROG} -Fl dir2/dir3/file3
165 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
167 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue dir2/dir3/file3
168 ${ATTR_PROG} -Fl dir2/dir3/file3
171 echo "3. change the EA value"
173 ${ATTR_PROG} -Fl $d/file4
174 stat_ino=`stat -iq $d`
175 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
177 ${ATTR_PROG} -Fs "$attrname" -V "$attrvalue" $d/file4
178 ${ATTR_PROG} -Fl $d/file4
179 ${ATTR_PROG} -Fg "$attrname" $d/file4
182 echo "4. add an extra EA - diff name, same value"
184 ${ATTR_PROG} -Fl $d/file5
186 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
188 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file5
189 ${ATTR_PROG} -Fl $d/file5
190 ${ATTR_PROG} -Fg "$attrname" $d/file5
193 echo "5. add an extra EA - diff name, diff value"
195 ${ATTR_PROG} -Fl $d/file6
197 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
199 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file6
200 ${ATTR_PROG} -Fl $d/file6
201 ${ATTR_PROG} -Fg "$attrname" $d/file6
204 echo "6. give bad fmt'ed EA name and get rid of existing name"
208 ${ATTR_PROG} -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_PROG} -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