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"
94 [ -z "$FSTYP" ] && FSTYP=xfs
95 [ -z "$MOUNT_OPTIONS" ] && _mount_opts
96 [ -z "$MKFS_OPTIONS" ] && _mkfs_opts
99 # we need common.config
100 if [ "$iam" != "check" ]
102 if ! . ./common.config
104 echo "$iam: failed to source common.config"
109 # make sure we have a standard umask
114 $MOUNT_PROG `_mount_ops_filter $*`
122 if [ "$FSTYP" != "xfs" ]; then
128 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
137 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
138 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
139 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
140 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
148 if [ "$FSTYP" != "xfs" ]; then
162 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
163 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
164 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
165 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
172 #get mount point to handle dmapi mtpt option correctly
174 [ $last_index -gt 0 ] && shift $last_index
177 # irix is fussy about how it is fed its mount options
178 # - multiple -o's are not allowed
179 # - no spaces between comma delimitered options
180 # the sed script replaces all -o's (except the first) with a comma
181 # not required for linux, but won't hurt
183 echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
184 | sed -e 's/dmapi/dmi/' \
185 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
189 _scratch_mount_options()
191 _scratch_options mount
193 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
198 _mount -t $FSTYP `_scratch_mount_options $*`
204 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $* $TEST_DEV $TEST_DIR
207 _scratch_mkfs_options()
209 _scratch_options mkfs
210 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
215 # extra mkfs options can be added by tests
216 local extra_mkfs_options=$*
220 _scratch_options mkfs
222 # save mkfs output in case conflict means we need to run again.
223 # only the output for the mkfs that applies should be shown
224 $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
225 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
228 # a mkfs failure may be caused by conflicts between
229 # $MKFS_OPTIONS and $extra_mkfs_options
231 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
232 echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
234 echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
236 # running mkfs again. overwrite previous mkfs output files
237 $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
238 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
242 # output stored mkfs output
243 cat $tmp_dir.mkfserr >&2
245 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
247 if [ "$USE_BIG_LOOPFS" = yes ]; then
248 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
249 ./tools/ag-wipe -q -r $RETAIN_AG_BYTES $SCRATCH_DEV
265 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
268 /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
273 _scratch_xfs_db_options()
276 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
277 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
278 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
281 _scratch_xfs_logprint()
284 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
285 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
286 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
292 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
293 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
294 $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
297 _scratch_xfs_repair()
300 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
301 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
302 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
303 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
304 [ "$USE_BIG_LOOPFS" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
305 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
312 echo "Usage: _get_pids_by_name process-name" 1>&2
316 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
317 # HH:MM:SS before the psargs field, use this as the search anchor.
319 # Matches with $1 (process-name) occur if the first psarg is $1
320 # or ends in /$1 ... the matching uses sed's regular expressions,
321 # so passing a regex into $1 will work.
329 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
330 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
338 $NSLOOKUP_PROG $host | $AWK_PROG '{ if ($1 == "Name:") print $2 }'
341 # fix malloc libs output
345 # filter out the Electric Fence notice
348 if (defined $o && /^\s+Electric Fence/) {
354 print $o if (defined $o);
358 print $o if (defined $o);
362 # check if run as root
366 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
369 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
376 # _df_device : get an IRIX style df line for a given device
378 # - returns "" if not mounted
379 # - returns fs type in field two (ala IRIX)
380 # - joins line together if split by fancy df formatting
381 # - strips header etc
388 echo "Usage: _df_device device" 1>&2
392 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
393 match($1,what) && NF==1 {
407 # _df_dir : get an IRIX style df line for device where a directory resides
409 # - returns fs type in field two (ala IRIX)
410 # - joins line together if split by fancy df formatting
411 # - strips header etc
418 echo "Usage: _df_dir device" 1>&2
422 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
438 # return percentage used disk space for mounted device
444 echo "Usage: _used device" 1>&2
448 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
451 # return the FS type of a mounted device
457 echo "Usage: _fs_type device" 1>&2
461 _df_device $1 | $AWK_PROG '{ print $2 }'
464 # return the FS mount options of a mounted device
466 # should write a version which just parses the output of mount for IRIX
467 # compatibility, but since this isn't used at all, at the moment I'll leave
474 echo "Usage: _fs_options device" 1>&2
478 $AWK_PROG -v dev=$1 '
479 match($1,dev) { print $4 }
483 # returns device number if a file is a block device
489 echo "Usage: _is_block_dev dev" 1>&2
493 [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
496 # Do a command, log it to $seq.full, optionally test return status
497 # and die if command fails. If called with one argument _do executes the
498 # command, logs it, and returns its exit status. With two arguments _do
499 # first prints the message passed in the first argument, and then "done"
500 # or "fail" depending on the return status of the command passed in the
501 # second argument. If the command fails and the variable _do_die_on_error
502 # is set to "always" or the two argument form is used and _do_die_on_error
503 # is set to "message_only" _do will print an error message to
508 if [ $# -eq 1 ]; then
510 elif [ $# -eq 2 ]; then
515 echo "Usage: _do [note] cmd" 1>&2
519 (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
520 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
521 cat $tmp._out | _fix_malloc >>$here/$seq.full
522 if [ $# -eq 2 ]; then
523 if [ $ret -eq 0 ]; then
530 && [ "$_do_die_on_error" = "always" \
531 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
534 eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
541 # bail out, setting up .notrun file
545 echo "$*" >$seq.notrun
546 echo "$seq not run: $*"
551 # just plain bail out
555 echo "$*" | tee -a $here/$seq.full
556 echo "(see $seq.full for details)"
561 # tests whether $FSTYP is one of the supported filesystems for a test
567 if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
573 _notrun "not suitable for this filesystem type: $FSTYP"
576 # tests whether $FSTYP is one of the supported OSes for a test
582 if [ "$h" = "$HOSTOS" ]
588 _notrun "not suitable for this OS: $HOSTOS"
591 # this test needs a scratch partition - check we're ok & unmount it
597 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
598 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
600 _notrun "this test requires a valid \$SCRATCH_DEV"
604 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
606 _notrun "this test requires a valid \$SCRATCH_DEV"
608 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
610 _notrun "this test requires a valid \$SCRATCH_DEV"
616 if _mount | grep -q $SCRATCH_DEV
618 # if it's mounted, make sure its on $SCRATCH_MNT
619 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
621 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
624 # and then unmount it
625 if ! $UMOUNT_PROG $SCRATCH_DEV
627 echo "failed to unmount $SCRATCH_DEV"
633 # this test needs a logdev
637 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
638 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
639 [ "$USE_EXTERNAL" != yes ] && \
640 _notrun "This test requires USE_EXTERNAL to be enabled"
642 # ensure its not mounted
643 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
646 # this test requires loopback device support
650 if [ "$HOSTOS" != "Linux" ]
652 _notrun "This test requires linux for loopback device support"
655 modprobe loop >/dev/null 2>&1
656 if grep loop /proc/devices >/dev/null 2>&1
660 _notrun "This test requires loopback device support"
664 # this test requires that (large) loopback device files are not in use
666 _require_nobigloopfs()
668 [ "$USE_BIG_LOOPFS" = yes ] && \
669 _notrun "Large filesystem testing in progress, skipped this test"
672 # this test requires that a realtime subvolume is in use, and
673 # that the kernel supports realtime as well.
677 [ "$USE_EXTERNAL" = yes ] || \
678 _notrun "External volumes not in use, skipped this test"
679 [ "$SCRATCH_RTDEV" = "" ] && \
680 _notrun "Realtime device required, skipped this test"
683 # this test requires that a specified command (executable) exists
687 [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
690 # this test requires that external log/realtime devices are not in use
692 _require_nonexternal()
694 [ "$USE_EXTERNAL" = yes ] && \
695 _notrun "External device testing in progress, skipped this test"
698 # check for the fsgqa user on the machine
703 cat /etc/passwd | grep -q $qa_user
704 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
707 # check that xfs_io, glibc, kernel, and filesystem all (!) support
710 _require_xfs_io_falloc()
711 testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $TEST_DIR/$tmp.io 2>&1`
712 rm -f $TEST_DIR/$tmp.io 2>&1 > /dev/null
713 echo $testio | grep -q "not found" && \
714 _notrun "xfs_io fallocate support is missing"
715 echo $testio | grep -q "Operation not supported" && \
716 _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
719 # check that a FS on a device is mounted
720 # if so, return mount point
726 echo "Usage: _is_mounted device" 1>&2
732 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
733 pattern { print $3 ; exit 0 }
737 echo "_is_mounted: $device is not a mounted $FSTYP FS"
742 # remount a FS to a new mode (ro or rw)
748 echo "Usage: _remount device ro/rw" 1>&2
754 if ! mount -o remount,$mode $device
756 echo "_remount: failed to remount filesystem on $device as $mode"
761 # Run the appropriate repair/check on a filesystem
763 # if the filesystem is mounted, it's either remounted ro before being
764 # checked or it's unmounted and then remounted
767 # If set, we remount ro instead of unmounting for fsck
770 _umount_or_remount_ro()
774 echo "Usage: _umount_or_remount_ro <device>" 1>&2
779 mountpoint=`_is_mounted $device`
781 if [ $USE_REMOUNT -eq 0 ]; then
789 _mount_or_remount_rw()
793 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
800 if [ $USE_REMOUNT -eq 0 ]
802 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
804 echo "!!! failed to remount $device on $mountpoint"
814 # Check a generic filesystem in no-op mode; this assumes that the
815 # underlying fsck program accepts "-n" for a no-op (check-only) run,
816 # and that it will still return an errno for corruption in this mode.
818 # Filesystems which don't support this will need to define their
821 _check_generic_filesystem()
825 # If type is set, we're mounted
826 type=`_fs_type $device`
829 if [ "$type" = "$FSTYP" ]
832 mountpoint=`_umount_or_remount_ro $device`
835 fsck -t $FSTYP -n $device >$tmp.fsck 2>&1
838 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seq.full)"
840 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
841 echo "*** fsck.$FSTYP output ***" >>$here/$seq.full
842 cat $tmp.fsck >>$here/$seq.full
843 echo "*** end fsck.$FSTYP output" >>$here/$seq.full
851 echo "*** mount output ***" >>$here/$seq.full
852 _mount >>$here/$seq.full
853 echo "*** end mount output" >>$here/$seq.full
854 elif [ "$type" = "$FSTYP" ]
857 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
861 [ $ok -eq 0 ] && exit 1
865 # run xfs_check and friends on a FS.
867 _check_xfs_filesystem()
871 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
875 extra_mount_options=""
877 if [ "$2" != "none" ]; then
878 extra_log_options="-l$2"
879 extra_mount_options="-ologdev=$2"
882 if [ "$3" != "none" ]; then
883 extra_rt_options="-r$3"
884 extra_mount_options=$extra_mount_options" -ortdev=$3"
886 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
888 [ "$FSTYP" != xfs ] && return 0
890 [ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
892 type=`_fs_type $device`
895 if [ "$type" = "xfs" ]
898 mountpoint=`_umount_or_remount_ro $device`
901 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
902 | tee $tmp.logprint | grep -q "<CLEAN>"
903 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
905 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seq.full)"
907 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$here/$seq.full
908 echo "*** xfs_logprint -t output ***" >>$here/$seq.full
909 cat $tmp.logprint >>$here/$seq.full
910 echo "*** end xfs_logprint output" >>$here/$seq.full
915 $XFS_CHECK_PROG $testoption $extra_log_options $device 2>&1 |\
916 _fix_malloc >$tmp.fs_check
917 if [ -s $tmp.fs_check ]
919 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seq.full)"
921 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
922 echo "*** xfs_check output ***" >>$here/$seq.full
923 cat $tmp.fs_check >>$here/$seq.full
924 echo "*** end xfs_check output" >>$here/$seq.full
928 # repair doesn't scale massively at this stage, optionally skip it for now
929 [ "$USE_BIG_LOOPFS" = yes ] || \
930 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
933 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seq.full)"
935 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
936 echo "*** xfs_repair -n output ***" >>$here/$seq.full
937 cat $tmp.repair | _fix_malloc >>$here/$seq.full
938 echo "*** end xfs_repair output" >>$here/$seq.full
942 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
946 echo "*** mount output ***" >>$here/$seq.full
947 _mount >>$here/$seq.full
948 echo "*** end mount output" >>$here/$seq.full
949 elif [ "$type" = "xfs" ]
951 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
954 [ $ok -eq 0 ] && exit 1
958 # Filter the knowen errors the UDF Verifier reports.
959 _udf_test_known_error_filter()
961 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."
965 _check_udf_filesystem()
967 [ "$DISABLE_UDF_TEST" == "1" ] && return
969 if [ $# -ne 1 -a $# -ne 2 ]
971 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
975 if [ ! -x $here/src/udf_test ]
977 echo "udf_test not installed, please download and build the Philips"
978 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
979 echo "Then copy the udf_test binary to $here/src/."
980 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
988 LAST_BLOCK=`expr \( $2 - 1 \)`
989 OPT_ARG="-lastvalidblock $LAST_BLOCK"
993 sleep 1 # Due to a problem with time stamps in udf_test
994 $here/src/udf_test $OPT_ARG $device | tee $here/$seq.checkfs | egrep "Error|Warning" | \
995 _udf_test_known_error_filter | \
996 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
997 sed "s/^.*$/Warning UDF Verifier reported errors see $seq.checkfs./g"
1001 _check_xfs_test_fs()
1005 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
1006 TEST_LOG="$TEST_LOGDEV"
1008 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1009 TEST_RT="$TEST_RTDEV"
1011 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1013 # check for ipath consistency
1014 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1015 # errors go to stderr
1016 xfs_check_ipaths $TEST_DIR >/dev/null
1017 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1028 # no way to check consistency for nfs
1031 # do nothing for now
1034 _check_generic_filesystem $TEST_DEV
1045 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
1046 SCRATCH_LOG="$SCRATCH_LOGDEV"
1048 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
1049 SCRATCH_RT="$SCRATCH_RTDEV"
1051 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
1054 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
1057 # Don't know how to check an NFS filesystem, yet.
1060 _check_generic_filesystem $SCRATCH_DEV
1065 _full_fstyp_details()
1067 [ -z "$FSTYP" ] && FSTYP=xfs
1068 if [ $FSTYP = xfs ]; then
1069 if [ -d /proc/fs/xfs ]; then
1070 if grep -q 'debug 0' /proc/fs/xfs/stat; then
1071 FSTYP="$FSTYP (non-debug)"
1072 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
1073 FSTYP="$FSTYP (debug)"
1076 if uname -a | grep -qi 'debug'; then
1077 FSTYP="$FSTYP (debug)"
1079 FSTYP="$FSTYP (non-debug)"
1086 _full_platform_details()
1092 echo "$os/$platform $host $kernel"
1095 _setup_udf_scratchdir()
1097 [ "$FSTYP" != "udf" ] \
1098 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1099 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1100 && _notrun "this test requires a valid \$SCRATCH_DEV"
1101 [ -z "$SCRATCH_MNT" ] \
1102 && _notrun "this test requires a valid \$SCRATCH_MNT"
1105 if _mount | grep -q $SCRATCH_DEV
1107 # if it's mounted, make sure its on $TEST_RW_DIR
1108 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1110 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1112 $UMOUNT_PROG $SCRATCH_DEV
1118 testdir=$SCRATCH_MNT
1121 _setup_nfs_scratchdir()
1123 [ "$FSTYP" != "nfs" ] \
1124 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1125 [ -z "$SCRATCH_DEV" ] \
1126 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1127 [ -z "$SCRATCH_MNT" ] \
1128 && _notrun "this test requires a valid \$SCRATCH_MNT"
1131 if _mount | grep -q $SCRATCH_DEV
1133 # if it's mounted, make sure its on $SCRATCH_MNT
1134 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1136 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1138 $UMOUNT_PROG $SCRATCH_DEV
1144 testdir=$SCRATCH_MNT
1148 # Warning for UDF and NFS:
1149 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
1150 # which actually uses the scratch dir for the test dir.
1152 # This was done because testdir was intended to be a persistent
1153 # XFS only partition. This should eventually change, and treat
1154 # at least local filesystems all the same.
1160 _setup_udf_scratchdir
1163 _setup_nfs_scratchdir
1175 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1176 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1179 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1180 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1183 # do nothing, testdir is $TEST_DIR
1191 if [ -z "$1" ]; then
1192 echo Error must pass \$seq.
1196 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1198 elif [ "`uname`" == "Linux" ]; then
1201 echo Error test $seq does not run on the operating system: `uname`
1219 if [ $size -gt 0 ]; then
1220 dd if=/dev/zero of=$file bs=1024 count=$size
1226 # takes dirname, depth
1229 dirname=$1; depth=$2
1230 mkdir $dirname || die "mkdir $dirname failed"
1233 _nfiles $files # files for this dir
1235 [ $depth -eq 0 ] && return
1236 let deep=$depth-1 # go 1 down
1238 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1241 while [ $d -lt $dirs ]
1243 _descend d$d $deep &
1249 # Populate a filesystem with inodes for performance experiments
1251 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
1256 dirs=5 # ndirs in each subdir till leaves
1257 size=0 # sizeof files in K
1258 files=100 # num files in _each_ subdir
1259 depth=2 # depth of tree from root to leaves
1261 root=root # path of initial root of directory tree
1263 while getopts "d:f:n:r:s:v" c
1275 _descend $root $depth
1280 [ $verbose = true ] && echo done
1283 # query whether the given file has the given inode flag set
1290 if which $XFS_IO_PROG >/dev/null; then
1291 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1298 # query the given files extsize allocator hint in bytes (if any)
1305 if which $XFS_IO_PROG >/dev/null; then
1306 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1307 awk '/^xattr.extsize =/ { print $3 }'`
1309 [ -z "$blocks" ] && blocks="0"
1314 ################################################################################
1316 if [ "$iam" != new -a "$iam" != bench ]
1318 # make some further configuration checks here
1320 if [ "$TEST_DEV" = "" ]
1322 echo "common.rc: Error: \$TEST_DEV is not set"
1326 # if $TEST_DEV is not mounted, mount it now as XFS
1327 if [ -z "`_fs_type $TEST_DEV`" ]
1329 # $TEST_DEV is not mounted
1332 echo "common.rc: retrying test device mount with external set"
1333 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
1336 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
1342 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
1344 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
1350 # make sure this script returns success