4 # Test some parent ptr stuff
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:
76 echo "Print out hardlink names for given path, $path"
80 attr -Fl $path | tee $tmp.attr1
83 nawk >$tmp.attr2 '/^Attribute/ { print $2, $3; next }'
85 while read ino cnt; do
88 # use the ea name to get the filename value
89 attr -Fg "$eaname" $path
91 # use the ea name to get the pathname value
92 attr -Pg "$eaname" $path
102 # Test out some creations
110 touch dir2/dir3/file3
114 p=dir2/dir3/dir4/file4
117 _print_names $p >>$here/$seq.full
119 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/$p
124 # get out the ea name components for all the hardlinks
126 tee -a $here/$seq.full |\
128 nawk '/^Attribute/ { print $2, $3; next }'
133 # given: abc/def/ghi/jkl
136 parent=`echo $child | sed -e 's#/[^/]*$##'`
138 # issue of path starting with '/' or not
139 # relatives paths wouldn't and we need to handle this
140 if [ $child = $parent ]; then
148 # Go thru each component of the hierarchy and compare
149 # inode# from "stat -i" with the ino from the parent EA name
151 # So I need to be given a path and go thru compenent by component.
153 # Need to look at: a a/b a/b/c a/b/c/d
155 # Also need to do this for all the hardlinks
157 _check_parentinos_path()
163 # representing all the hard links for a particular path
165 _get_ea_fields $path |\
166 while read parent_ino cnt; do
168 while [ "$parent" != "$mntpt" ]; do
170 eaname="$parent_ino $cnt"
171 eavalue=`attr -qPg "$eaname" $parent`
172 parentrel=`echo $parent | sed -e "s#^$mntpt##"`
173 if [ "$eavalue" = "$parentrel" ]; then
174 echo "EA path $eavalue matches on path"
176 $verbose && echo "EA path mismatch on $parentrel: $eavalue"
177 break # maybe wrong hardlink
180 # compare parent_ino from ea-name with parent-ino from
181 # actual parent dir using stat
183 parent=`_parent_path $parent`
184 parent_ino_dec=`printf "%d" 0x$parent_ino` # decimal version (not hex)
185 stat_ino=`stat -iq $parent`
187 if [ "$parent_ino_dec" = "$stat_ino" ]; then
188 echo "parent ino $parent_ino_dec matches"
190 echo "parent ino mismatch on $parent: EA=$parent_ino_dec stat=$stat_ino"
194 # go onto next subdir up the path
195 line=`_get_ea_fields $parent`
196 parent_ino=`echo $line | cut -f1 -d' '` # 1st field
197 cnt=`echo $line | cut -f2 -d' '` # 2nd field
205 echo "Testing symlink"
216 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/symlink1
217 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/hlink1
218 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/hlink2
219 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/hlink3
223 # create hardlinks from the same dir
224 # and some from different dirs
226 # test out removing hardlinks too
231 echo "Testing hardlink"
242 paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6"
247 _print_names $p >>$here/$seq.full
250 echo "print out names and check after created hardlinks"
253 _print_names $x | tee -a $here/$seq.full
254 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/$x
258 echo "now try removing half of the hardlinks"
260 paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6"
265 if [ $j -eq 0 ]; then
272 echo "print out names and check after removed hardlinks"
277 _print_names $x | tee -a $here/$seq.full
278 _check_parentinos_path $SCRATCH_MNT $SCRATCH_MNT/$x
285 # in dir, file1 to file2 where file2 does not exist
286 # in dir, file1 to file2 where file2 does exist
287 # dir/file1 to dir2/file2 where file2 does not exist
288 # dir/file1 to dir2/file2 where file2 does exist
289 # dir to dir2 where dir2 does not exist
290 # dir to dir/dir3 - not allowed
296 echo "Testing rename"
300 echo "1. in dir, file1 to file2 where file2 does not exist"
302 d1=$SCRATCH_MNT/ren1/ren2/ren3/ren4
308 _check_parentinos_path $SCRATCH_MNT $p2
311 echo "2. in dir, file1 to file2 where file2 does exist"
315 _check_parentinos_path $SCRATCH_MNT $p2
318 echo "3. dir/file1 to dir2/file2 where file2 does not exist"
320 d2=$SCRATCH_MNT/ren1/ren2/ren3/ren5
325 _check_parentinos_path $SCRATCH_MNT $p3
328 echo "4. dir/file1 to dir2/file2 where file2 does exist"
330 d2=$SCRATCH_MNT/ren1/ren2/ren3/ren5
334 _check_parentinos_path $SCRATCH_MNT $p3
337 echo "5. dir to dir2 where dir2 does not exist"
339 d3=$SCRATCH_MNT/ren1/ren2/ren3/ren6
341 _check_parentinos_path $SCRATCH_MNT $d3
347 sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
348 -e 's/[0-9][0-9]* paths/P paths/g' \
349 -e 's/seed = [0-9][0-9]*/seed = S/'
356 echo "Testing fsstress"
359 out=$SCRATCH_MNT/fsstress.$$
362 -f rmdir=10 -f link=10 -f creat=10 \
363 -f mkdir=10 -f rename=30 -f unlink=10 \
365 -n $count -d $out -p 3"
367 echo "ltp/fsstress $args" | sed -e "s#$out#outdir#"
368 if ! $here/ltp/fsstress $args | _filter_num
370 echo " fsstress $args returned $?"
371 cat $tmp.out | tee -a $here/$seq.full
375 xfs_repair_ipaths -n $SCRATCH_MNT | _filter_num
376 xfs_check_ipaths $SCRATCH_MNT | _filter_num
383 echo "Testing dirstress"
386 out=$SCRATCH_MNT/dirstress.$$
391 echo "!! couldn't mkdir $out"
396 args="-d $out -f $count -k -p 3 -n 1"
397 echo "src/dirstress $args" | sed -e "s#$out#outdir#"
398 if ! $here/src/dirstress $args >$tmp.out 2>&1 | _filter_num
400 echo " dirstress failed"
401 echo "*** dirstress $args" | tee -a $here/$seq.full
402 cat $tmp.out >>$here/$seq.full
407 args="-d $out -f $count -k -p 3 -n 5"
408 echo "src/dirstress $args" | sed -e "s#$out#outdir#"
409 if ! $here/src/dirstress $args >$tmp.out 2>&1 | _filter_num
411 echo " dirstress failed"
412 echo "*** dirstress $args" | tee -a $here/$seq.full
413 cat $tmp.out >>$here/$seq.full
418 xfs_repair_ipaths -n $SCRATCH_MNT | _filter_num
419 xfs_check_ipaths $SCRATCH_MNT | _filter_num
422 # get standard environment, filters and checks
431 rm -f $here/$seq.full
434 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
435 || _fail "mkfs scratch failed"
436 export MKFS_OPTIONS="$MKFS_OPTIONS -i paths=1"
437 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
438 || _notrun "i_paths not supported"
441 _scratch_mount >>$here/$seq.full 2>&1 \
442 || _fail "mount failed: $MOUNT_OPTIONS"
444 # real QA test starts here
448 # initial testing with scripting and modified attr(1)
449 # in order to test parent EAs
455 # stress testing with verification by parent checking programs