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 #-----------------------------------------------------------------------
25 owner=tes@crackle.melbourne.sgi.com
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # ~/attr -Fl a/b/c/d/foo
44 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
46 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
47 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
50 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
51 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
56 # filter out inode numbers to ordinal numbers
57 # (assumes they come in order)
61 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
64 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
65 | nawk -v inodefile=$tmp.inodes '
68 while (getline < inodefile > 0) {
74 for (i = 1; i <= NF; i++) {
77 $nextone = inodemap[$nextone]
90 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
91 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
95 # get standard environment, filters and checks
106 rm -f $here/$seq.full
109 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
110 || _fail "mkfs scratch failed"
111 _scratch_mkfs_xfs -i paths=1 >>$here/$seq.full 2>&1 \
112 || _notrun "i_paths not supported"
115 _scratch_mount >>$here/$seq.full 2>&1 \
116 || _fail "mount failed: $MOUNT_OPTIONS"
118 # real QA test starts here
123 echo "--- create some files and directories to work on ---"
130 touch dir2/dir3/file3
142 echo "--- check all is ok before we start ---"
144 xfs_check_ipaths $SCRATCH_MNT
145 xfs_repair_ipaths -n $SCRATCH_MNT
148 echo "--- now break some stuff ---"
153 echo "1. remove the EA"
155 ${ATTR_PROG} -Fl dir2/file2
156 stat_ino=`stat -iq dir2`
157 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
158 #echo "attrname = $attrname"
159 ${ATTR_PROG} -Fr "$attrname" dir2/file2
160 ${ATTR_PROG} -Fl dir2/file2
163 echo "2. change the EA name"
165 ${ATTR_PROG} -Fl dir2/dir3/file3
167 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
169 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue dir2/dir3/file3
170 ${ATTR_PROG} -Fl dir2/dir3/file3
173 echo "3. change the EA value"
175 ${ATTR_PROG} -Fl $d/file4
176 stat_ino=`stat -iq $d`
177 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
179 ${ATTR_PROG} -Fs "$attrname" -V "$attrvalue" $d/file4
180 ${ATTR_PROG} -Fl $d/file4
181 ${ATTR_PROG} -Fg "$attrname" $d/file4
184 echo "4. add an extra EA - diff name, same value"
186 ${ATTR_PROG} -Fl $d/file5
188 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
190 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file5
191 ${ATTR_PROG} -Fl $d/file5
192 ${ATTR_PROG} -Fg "$attrname" $d/file5
195 echo "5. add an extra EA - diff name, diff value"
197 ${ATTR_PROG} -Fl $d/file6
199 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
201 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file6
202 ${ATTR_PROG} -Fl $d/file6
203 ${ATTR_PROG} -Fg "$attrname" $d/file6
206 echo "6. give bad fmt'ed EA name and get rid of existing name"
210 ${ATTR_PROG} -Fs "$attrname" -V $attrvalue $d/file7
211 # remove old attrname
213 stat_ino=`stat -iq $d`
214 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
215 ${ATTR_PROG} -Fr "$attrname" $d/file7
218 echo "--- now check it ---"
222 echo "xfs_check_ipaths"
224 xfs_check_ipaths $SCRATCH_MNT
227 echo "xfs_repair_ipaths"
229 xfs_repair_ipaths -n $SCRATCH_MNT
232 echo "--- now repair it ---"
236 echo "xfs_repair_ipaths"
238 xfs_repair_ipaths $SCRATCH_MNT
241 echo "--- now check it again ---"
246 echo "xfs_check_ipaths"
248 xfs_check_ipaths $SCRATCH_MNT
251 echo "xfs_repair_ipaths"
253 xfs_repair_ipaths -n $SCRATCH_MNT
256 _do_test 2>&1 | tee $seq.full | _filter_inodes