2 #-----------------------------------------------------------------------
3 # Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 # Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
20 # Mountain View, CA 94043, USA, or: http://www.sgi.com
21 #-----------------------------------------------------------------------
25 if [ "$HOSTOS" == "Linux" ]
27 command dd --help | grep noxfer > /dev/null 2>&1
31 command dd status=noxfer $@
44 export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
47 export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
50 export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
53 # acls & xattrs aren't turned on by default on ext$FOO
54 export MOUNT_OPTIONS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
57 # acls & xattrs aren't turned on by default on reiserfs
58 export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
61 # acls aren't turned on by default on gfs2
62 export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
73 export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
76 [ ! -z "$udf_fsize" ] && \
77 UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
78 export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
81 export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
84 export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
87 export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
98 export FSCK_OPTIONS="-nf"
101 export FSCK_OPTIONS="--yes"
104 export FSCK_OPTIONS="-n"
109 [ -z "$FSTYP" ] && FSTYP=xfs
110 [ -z "$MOUNT_OPTIONS" ] && _mount_opts
111 [ -z "$MKFS_OPTIONS" ] && _mkfs_opts
112 [ -z "$FSCK_OPTIONS" ] && _fsck_opts
115 # we need common.config
116 if [ "$iam" != "check" ]
118 if ! . ./common.config
120 echo "$iam: failed to source common.config"
125 # make sure we have a standard umask
130 $MOUNT_PROG `_mount_ops_filter $*`
138 if [ "$FSTYP" != "xfs" ]; then
144 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
153 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
154 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
155 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
156 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
164 if [ "$FSTYP" != "xfs" ]; then
178 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
179 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
180 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
181 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
188 #get mount point to handle dmapi mtpt option correctly
190 [ $last_index -gt 0 ] && shift $last_index
193 # irix is fussy about how it is fed its mount options
194 # - multiple -o's are not allowed
195 # - no spaces between comma delimitered options
196 # the sed script replaces all -o's (except the first) with a comma
197 # not required for linux, but won't hurt
199 echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
200 | sed -e 's/dmapi/dmi/' \
201 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
205 _scratch_mount_options()
207 _scratch_options mount
209 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
214 _mount -t $FSTYP `_scratch_mount_options $*`
219 $UMOUNT_PROG $SCRATCH_DEV
231 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $* $TEST_DEV $TEST_DIR
234 _scratch_mkfs_options()
236 _scratch_options mkfs
237 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
242 # extra mkfs options can be added by tests
243 local extra_mkfs_options=$*
247 _scratch_options mkfs
249 # save mkfs output in case conflict means we need to run again.
250 # only the output for the mkfs that applies should be shown
251 $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
252 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
255 # a mkfs failure may be caused by conflicts between
256 # $MKFS_OPTIONS and $extra_mkfs_options
258 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
259 echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
261 echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
263 # running mkfs again. overwrite previous mkfs output files
264 $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
265 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
269 # output stored mkfs output
270 cat $tmp_dir.mkfserr >&2
272 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
274 if [ "$USE_BIG_LOOPFS" = yes ]; then
275 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
276 ./tools/ag-wipe -q -r $RETAIN_AG_BYTES $SCRATCH_DEV
292 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
295 /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
300 _scratch_xfs_db_options()
303 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
304 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
305 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
308 _scratch_xfs_logprint()
311 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
312 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
313 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
319 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
320 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
321 $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
324 _scratch_xfs_repair()
327 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
328 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
329 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
330 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
331 [ "$USE_BIG_LOOPFS" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
332 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
339 echo "Usage: _get_pids_by_name process-name" 1>&2
343 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
344 # HH:MM:SS before the psargs field, use this as the search anchor.
346 # Matches with $1 (process-name) occur if the first psarg is $1
347 # or ends in /$1 ... the matching uses sed's regular expressions,
348 # so passing a regex into $1 will work.
356 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
357 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
360 # fix malloc libs output
364 # filter out the Electric Fence notice
367 if (defined $o && /^\s+Electric Fence/) {
373 print $o if (defined $o);
377 print $o if (defined $o);
381 # check if run as root
385 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
388 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
395 # _df_device : get an IRIX style df line for a given device
397 # - returns "" if not mounted
398 # - returns fs type in field two (ala IRIX)
399 # - joins line together if split by fancy df formatting
400 # - strips header etc
407 echo "Usage: _df_device device" 1>&2
411 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
412 match($1,what) && NF==1 {
426 # _df_dir : get an IRIX style df line for device where a directory resides
428 # - returns fs type in field two (ala IRIX)
429 # - joins line together if split by fancy df formatting
430 # - strips header etc
437 echo "Usage: _df_dir device" 1>&2
441 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
457 # return percentage used disk space for mounted device
463 echo "Usage: _used device" 1>&2
467 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
470 # return the FS type of a mounted device
476 echo "Usage: _fs_type device" 1>&2
480 _df_device $1 | $AWK_PROG '{ print $2 }'
483 # return the FS mount options of a mounted device
485 # should write a version which just parses the output of mount for IRIX
486 # compatibility, but since this isn't used at all, at the moment I'll leave
493 echo "Usage: _fs_options device" 1>&2
497 $AWK_PROG -v dev=$1 '
498 match($1,dev) { print $4 }
502 # returns device number if a file is a block device
508 echo "Usage: _is_block_dev dev" 1>&2
512 [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
515 # Do a command, log it to $seq.full, optionally test return status
516 # and die if command fails. If called with one argument _do executes the
517 # command, logs it, and returns its exit status. With two arguments _do
518 # first prints the message passed in the first argument, and then "done"
519 # or "fail" depending on the return status of the command passed in the
520 # second argument. If the command fails and the variable _do_die_on_error
521 # is set to "always" or the two argument form is used and _do_die_on_error
522 # is set to "message_only" _do will print an error message to
527 if [ $# -eq 1 ]; then
529 elif [ $# -eq 2 ]; then
534 echo "Usage: _do [note] cmd" 1>&2
538 (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
539 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
540 cat $tmp._out | _fix_malloc >>$here/$seq.full
541 if [ $# -eq 2 ]; then
542 if [ $ret -eq 0 ]; then
549 && [ "$_do_die_on_error" = "always" \
550 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
553 eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
560 # bail out, setting up .notrun file
564 echo "$*" >$seq.notrun
565 echo "$seq not run: $*"
570 # just plain bail out
574 echo "$*" | tee -a $here/$seq.full
575 echo "(see $seq.full for details)"
580 # tests whether $FSTYP is one of the supported filesystems for a test
586 if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
592 _notrun "not suitable for this filesystem type: $FSTYP"
595 # tests whether $FSTYP is one of the supported OSes for a test
601 if [ "$h" = "$HOSTOS" ]
607 _notrun "not suitable for this OS: $HOSTOS"
610 # this test needs a scratch partition - check we're ok & unmount it
616 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
617 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
619 _notrun "this test requires a valid \$SCRATCH_DEV"
623 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
625 _notrun "this test requires a valid \$SCRATCH_DEV"
627 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
629 _notrun "this test requires a valid \$SCRATCH_DEV"
635 if _mount | grep -q $SCRATCH_DEV
637 # if it's mounted, make sure its on $SCRATCH_MNT
638 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
640 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
643 # and then unmount it
644 if ! $UMOUNT_PROG $SCRATCH_DEV
646 echo "failed to unmount $SCRATCH_DEV"
652 # this test needs a logdev
656 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
657 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
658 [ "$USE_EXTERNAL" != yes ] && \
659 _notrun "This test requires USE_EXTERNAL to be enabled"
661 # ensure its not mounted
662 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
665 # this test requires loopback device support
669 if [ "$HOSTOS" != "Linux" ]
671 _notrun "This test requires linux for loopback device support"
674 modprobe loop >/dev/null 2>&1
675 if grep loop /proc/devices >/dev/null 2>&1
679 _notrun "This test requires loopback device support"
683 # this test requires that (large) loopback device files are not in use
685 _require_nobigloopfs()
687 [ "$USE_BIG_LOOPFS" = yes ] && \
688 _notrun "Large filesystem testing in progress, skipped this test"
691 # this test requires that a realtime subvolume is in use, and
692 # that the kernel supports realtime as well.
696 [ "$USE_EXTERNAL" = yes ] || \
697 _notrun "External volumes not in use, skipped this test"
698 [ "$SCRATCH_RTDEV" = "" ] && \
699 _notrun "Realtime device required, skipped this test"
702 # this test requires that a specified command (executable) exists
706 [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
709 # this test requires that external log/realtime devices are not in use
711 _require_nonexternal()
713 [ "$USE_EXTERNAL" = yes ] && \
714 _notrun "External device testing in progress, skipped this test"
717 # check for the fsgqa user on the machine
722 cat /etc/passwd | grep -q $qa_user
723 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
726 # check that xfs_io, glibc, kernel, and filesystem all (!) support
729 _require_xfs_io_falloc() {
730 testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $TEST_DIR/$tmp.io 2>&1`
731 rm -f $TEST_DIR/$tmp.io 2>&1 > /dev/null
732 echo $testio | grep -q "not found" && \
733 _notrun "xfs_io fallocate support is missing"
734 echo $testio | grep -q "Operation not supported" && \
735 _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
738 # check that a FS on a device is mounted
739 # if so, return mount point
745 echo "Usage: _is_mounted device" 1>&2
751 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
752 pattern { print $3 ; exit 0 }
756 echo "_is_mounted: $device is not a mounted $FSTYP FS"
761 # remount a FS to a new mode (ro or rw)
767 echo "Usage: _remount device ro/rw" 1>&2
773 if ! mount -o remount,$mode $device
775 echo "_remount: failed to remount filesystem on $device as $mode"
780 # Run the appropriate repair/check on a filesystem
782 # if the filesystem is mounted, it's either remounted ro before being
783 # checked or it's unmounted and then remounted
786 # If set, we remount ro instead of unmounting for fsck
789 _umount_or_remount_ro()
793 echo "Usage: _umount_or_remount_ro <device>" 1>&2
798 mountpoint=`_is_mounted $device`
800 if [ $USE_REMOUNT -eq 0 ]; then
808 _mount_or_remount_rw()
812 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
819 if [ $USE_REMOUNT -eq 0 ]
821 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
823 echo "!!! failed to remount $device on $mountpoint"
833 # Check a generic filesystem in no-op mode; this assumes that the
834 # underlying fsck program accepts "-n" for a no-op (check-only) run,
835 # and that it will still return an errno for corruption in this mode.
837 # Filesystems which don't support this will need to define their
840 _check_generic_filesystem()
844 # If type is set, we're mounted
845 type=`_fs_type $device`
848 if [ "$type" = "$FSTYP" ]
851 mountpoint=`_umount_or_remount_ro $device`
854 fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
857 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seq.full)"
859 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
860 echo "*** fsck.$FSTYP output ***" >>$here/$seq.full
861 cat $tmp.fsck >>$here/$seq.full
862 echo "*** end fsck.$FSTYP output" >>$here/$seq.full
870 echo "*** mount output ***" >>$here/$seq.full
871 _mount >>$here/$seq.full
872 echo "*** end mount output" >>$here/$seq.full
873 elif [ "$type" = "$FSTYP" ]
876 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
880 [ $ok -eq 0 ] && exit 1
884 # run xfs_check and friends on a FS.
886 _check_xfs_filesystem()
890 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
894 extra_mount_options=""
896 if [ "$2" != "none" ]; then
897 extra_log_options="-l$2"
898 extra_mount_options="-ologdev=$2"
901 if [ "$3" != "none" ]; then
902 extra_rt_options="-r$3"
903 extra_mount_options=$extra_mount_options" -ortdev=$3"
905 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
907 [ "$FSTYP" != xfs ] && return 0
909 [ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
911 type=`_fs_type $device`
914 if [ "$type" = "xfs" ]
917 mountpoint=`_umount_or_remount_ro $device`
920 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
921 | tee $tmp.logprint | grep -q "<CLEAN>"
922 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
924 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seq.full)"
926 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$here/$seq.full
927 echo "*** xfs_logprint -t output ***" >>$here/$seq.full
928 cat $tmp.logprint >>$here/$seq.full
929 echo "*** end xfs_logprint output" >>$here/$seq.full
934 $XFS_CHECK_PROG $testoption $extra_log_options $device 2>&1 |\
935 _fix_malloc >$tmp.fs_check
936 if [ -s $tmp.fs_check ]
938 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seq.full)"
940 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
941 echo "*** xfs_check output ***" >>$here/$seq.full
942 cat $tmp.fs_check >>$here/$seq.full
943 echo "*** end xfs_check output" >>$here/$seq.full
947 # repair doesn't scale massively at this stage, optionally skip it for now
948 [ "$USE_BIG_LOOPFS" = yes ] || \
949 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
952 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seq.full)"
954 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
955 echo "*** xfs_repair -n output ***" >>$here/$seq.full
956 cat $tmp.repair | _fix_malloc >>$here/$seq.full
957 echo "*** end xfs_repair output" >>$here/$seq.full
961 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
965 echo "*** mount output ***" >>$here/$seq.full
966 _mount >>$here/$seq.full
967 echo "*** end mount output" >>$here/$seq.full
968 elif [ "$type" = "xfs" ]
970 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
973 [ $ok -eq 0 ] && exit 1
977 # Filter the knowen errors the UDF Verifier reports.
978 _udf_test_known_error_filter()
980 egrep -v "PVD 60 Error: Interchange Level: 1, Maximum Interchange Level: 0|FSD 28 Error: Interchange Level: 1, Maximum Interchange Level: 1,|PVD 72 Warning: Volume Set Identifier: \"\*IRIX UDF\",|Warning: [0-9]+ unused blocks NOT marked as unallocated."
984 _check_udf_filesystem()
986 [ "$DISABLE_UDF_TEST" == "1" ] && return
988 if [ $# -ne 1 -a $# -ne 2 ]
990 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
994 if [ ! -x $here/src/udf_test ]
996 echo "udf_test not installed, please download and build the Philips"
997 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
998 echo "Then copy the udf_test binary to $here/src/."
999 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
1007 LAST_BLOCK=`expr \( $2 - 1 \)`
1008 OPT_ARG="-lastvalidblock $LAST_BLOCK"
1012 sleep 1 # Due to a problem with time stamps in udf_test
1013 $here/src/udf_test $OPT_ARG $device | tee $here/$seq.checkfs | egrep "Error|Warning" | \
1014 _udf_test_known_error_filter | \
1015 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
1016 sed "s/^.*$/Warning UDF Verifier reported errors see $seq.checkfs./g"
1020 _check_xfs_test_fs()
1024 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
1025 TEST_LOG="$TEST_LOGDEV"
1027 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1028 TEST_RT="$TEST_RTDEV"
1030 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1032 # check for ipath consistency
1033 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1034 # errors go to stderr
1035 xfs_check_ipaths $TEST_DIR >/dev/null
1036 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1047 # no way to check consistency for nfs
1050 # do nothing for now
1053 _check_generic_filesystem $TEST_DEV
1064 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
1065 SCRATCH_LOG="$SCRATCH_LOGDEV"
1067 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
1068 SCRATCH_RT="$SCRATCH_RTDEV"
1070 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
1073 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
1076 # Don't know how to check an NFS filesystem, yet.
1079 _check_generic_filesystem $SCRATCH_DEV
1084 _full_fstyp_details()
1086 [ -z "$FSTYP" ] && FSTYP=xfs
1087 if [ $FSTYP = xfs ]; then
1088 if [ -d /proc/fs/xfs ]; then
1089 if grep -q 'debug 0' /proc/fs/xfs/stat; then
1090 FSTYP="$FSTYP (non-debug)"
1091 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
1092 FSTYP="$FSTYP (debug)"
1095 if uname -a | grep -qi 'debug'; then
1096 FSTYP="$FSTYP (debug)"
1098 FSTYP="$FSTYP (non-debug)"
1105 _full_platform_details()
1111 echo "$os/$platform $host $kernel"
1114 _setup_udf_scratchdir()
1116 [ "$FSTYP" != "udf" ] \
1117 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1118 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1119 && _notrun "this test requires a valid \$SCRATCH_DEV"
1120 [ -z "$SCRATCH_MNT" ] \
1121 && _notrun "this test requires a valid \$SCRATCH_MNT"
1124 if _mount | grep -q $SCRATCH_DEV
1126 # if it's mounted, make sure its on $TEST_RW_DIR
1127 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1129 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1131 $UMOUNT_PROG $SCRATCH_DEV
1137 testdir=$SCRATCH_MNT
1140 _setup_nfs_scratchdir()
1142 [ "$FSTYP" != "nfs" ] \
1143 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1144 [ -z "$SCRATCH_DEV" ] \
1145 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1146 [ -z "$SCRATCH_MNT" ] \
1147 && _notrun "this test requires a valid \$SCRATCH_MNT"
1150 if _mount | grep -q $SCRATCH_DEV
1152 # if it's mounted, make sure its on $SCRATCH_MNT
1153 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1155 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1157 $UMOUNT_PROG $SCRATCH_DEV
1163 testdir=$SCRATCH_MNT
1167 # Warning for UDF and NFS:
1168 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
1169 # which actually uses the scratch dir for the test dir.
1171 # This was done because testdir was intended to be a persistent
1172 # XFS only partition. This should eventually change, and treat
1173 # at least local filesystems all the same.
1179 _setup_udf_scratchdir
1182 _setup_nfs_scratchdir
1194 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1195 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1198 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1199 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1202 # do nothing, testdir is $TEST_DIR
1210 if [ -z "$1" ]; then
1211 echo Error must pass \$seq.
1215 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1217 elif [ "`uname`" == "Linux" ]; then
1220 echo Error test $seq does not run on the operating system: `uname`
1238 if [ $size -gt 0 ]; then
1239 dd if=/dev/zero of=$file bs=1024 count=$size
1245 # takes dirname, depth
1248 dirname=$1; depth=$2
1249 mkdir $dirname || die "mkdir $dirname failed"
1252 _nfiles $files # files for this dir
1254 [ $depth -eq 0 ] && return
1255 let deep=$depth-1 # go 1 down
1257 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1260 while [ $d -lt $dirs ]
1262 _descend d$d $deep &
1268 # Populate a filesystem with inodes for performance experiments
1270 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
1275 dirs=5 # ndirs in each subdir till leaves
1276 size=0 # sizeof files in K
1277 files=100 # num files in _each_ subdir
1278 depth=2 # depth of tree from root to leaves
1280 root=root # path of initial root of directory tree
1282 while getopts "d:f:n:r:s:v" c
1294 _descend $root $depth
1299 [ $verbose = true ] && echo done
1302 # query whether the given file has the given inode flag set
1309 if which $XFS_IO_PROG >/dev/null; then
1310 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1317 # query the given files extsize allocator hint in bytes (if any)
1324 if which $XFS_IO_PROG >/dev/null; then
1325 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1326 awk '/^xattr.extsize =/ { print $3 }'`
1328 [ -z "$blocks" ] && blocks="0"
1333 ################################################################################
1335 if [ "$iam" != new -a "$iam" != bench ]
1337 # make some further configuration checks here
1339 if [ "$TEST_DEV" = "" ]
1341 echo "common.rc: Error: \$TEST_DEV is not set"
1345 # if $TEST_DEV is not mounted, mount it now as XFS
1346 if [ -z "`_fs_type $TEST_DEV`" ]
1348 # $TEST_DEV is not mounted
1351 echo "common.rc: retrying test device mount with external set"
1352 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
1355 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
1361 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
1363 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
1369 # make sure this script returns success