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 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
599 _notrun "this test requires a valid \$SCRATCH_DEV"
601 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
603 _notrun "this test requires a valid \$SCRATCH_DEV"
606 nfs*|ext2|ext3|ext4|reiserfs|gfs2|btrfs)
607 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
608 if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]
610 _notrun "this test requires a valid \$SCRATCH_DEV"
614 _notrun "\$FSTYP ($FSTYP) unknown or not specified"
619 if _mount | grep -q $SCRATCH_DEV
621 # if it's mounted, make sure its on $SCRATCH_MNT
622 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
624 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
627 # and then unmount it
628 if ! $UMOUNT_PROG $SCRATCH_DEV
630 echo "failed to unmount $SCRATCH_DEV"
636 # this test needs a logdev
640 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
641 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
642 [ "$USE_EXTERNAL" != yes ] && \
643 _notrun "This test requires USE_EXTERNAL to be enabled"
645 # ensure its not mounted
646 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
649 # this test requires loopback device support
653 if [ "$HOSTOS" != "Linux" ]
655 _notrun "This test requires linux for loopback device support"
658 modprobe loop >/dev/null 2>&1
659 if grep loop /proc/devices >/dev/null 2>&1
663 _notrun "This test requires loopback device support"
667 # this test requires that (large) loopback device files are not in use
669 _require_nobigloopfs()
671 [ "$USE_BIG_LOOPFS" = yes ] && \
672 _notrun "Large filesystem testing in progress, skipped this test"
675 # this test requires that a realtime subvolume is in use, and
676 # that the kernel supports realtime as well.
680 [ "$USE_EXTERNAL" = yes ] || \
681 _notrun "External volumes not in use, skipped this test"
682 [ "$SCRATCH_RTDEV" = "" ] && \
683 _notrun "Realtime device required, skipped this test"
686 # this test requires that a specified command (executable) exists
690 [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
693 # this test requires that external log/realtime devices are not in use
695 _require_nonexternal()
697 [ "$USE_EXTERNAL" = yes ] && \
698 _notrun "External device testing in progress, skipped this test"
701 # check for the fsgqa user on the machine
706 cat /etc/passwd | grep -q $qa_user
707 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
710 # check that a FS on a device is mounted
711 # if so, return mount point
717 echo "Usage: _is_mounted device" 1>&2
723 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
724 pattern { print $3 ; exit 0 }
728 echo "_is_mounted: $device is not a mounted $FSTYP FS"
733 # remount a FS to a new mode (ro or rw)
739 echo "Usage: _remount device ro/rw" 1>&2
745 if ! mount -o remount,$mode $device
747 echo "_remount: failed to remount filesystem on $device as $mode"
752 # Run the appropriate repair/check on a filesystem
754 # if the filesystem is mounted, it's either remounted ro before being
755 # checked or it's unmounted and then remounted
758 # If set, we remount ro instead of unmounting for fsck
761 _umount_or_remount_ro()
765 echo "Usage: _umount_or_remount_ro <device>" 1>&2
770 mountpoint=`_is_mounted $device`
772 if [ $USE_REMOUNT -eq 0 ]; then
780 _mount_or_remount_rw()
784 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
791 if [ $USE_REMOUNT -eq 0 ]
793 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
795 echo "!!! failed to remount $device on $mountpoint"
805 # Check a generic filesystem in no-op mode; this assumes that the
806 # underlying fsck program accepts "-n" for a no-op (check-only) run,
807 # and that it will still return an errno for corruption in this mode.
809 # Filesystems which don't support this will need to define their
812 _check_generic_filesystem()
816 # If type is set, we're mounted
817 type=`_fs_type $device`
820 if [ "$type" = "$FSTYP" ]
823 mountpoint=`_umount_or_remount_ro $device`
826 fsck -t $FSTYP -n $device >$tmp.fsck 2>&1
829 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seq.full)"
831 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
832 echo "*** fsck.$FSTYP output ***" >>$here/$seq.full
833 cat $tmp.fsck >>$here/$seq.full
834 echo "*** end fsck.$FSTYP output" >>$here/$seq.full
842 echo "*** mount output ***" >>$here/$seq.full
843 _mount >>$here/$seq.full
844 echo "*** end mount output" >>$here/$seq.full
845 elif [ "$type" = "$FSTYP" ]
848 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
852 [ $ok -eq 0 ] && exit 1
856 # run xfs_check and friends on a FS.
858 _check_xfs_filesystem()
862 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
866 extra_mount_options=""
868 if [ "$2" != "none" ]; then
869 extra_log_options="-l$2"
870 extra_mount_options="-ologdev=$2"
873 if [ "$3" != "none" ]; then
874 extra_rt_options="-r$3"
875 extra_mount_options=$extra_mount_options" -ortdev=$3"
877 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
879 [ "$FSTYP" != xfs ] && return 0
881 [ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
883 type=`_fs_type $device`
886 if [ "$type" = "xfs" ]
889 mountpoint=`_umount_or_remount_ro $device`
892 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
893 | tee $tmp.logprint | grep -q "<CLEAN>"
894 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
896 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seq.full)"
898 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$here/$seq.full
899 echo "*** xfs_logprint -t output ***" >>$here/$seq.full
900 cat $tmp.logprint >>$here/$seq.full
901 echo "*** end xfs_logprint output" >>$here/$seq.full
906 $XFS_CHECK_PROG $testoption $extra_log_options $device 2>&1 |\
907 _fix_malloc >$tmp.fs_check
908 if [ -s $tmp.fs_check ]
910 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seq.full)"
912 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
913 echo "*** xfs_check output ***" >>$here/$seq.full
914 cat $tmp.fs_check >>$here/$seq.full
915 echo "*** end xfs_check output" >>$here/$seq.full
919 # repair doesn't scale massively at this stage, optionally skip it for now
920 [ "$USE_BIG_LOOPFS" = yes ] || \
921 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
924 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seq.full)"
926 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
927 echo "*** xfs_repair -n output ***" >>$here/$seq.full
928 cat $tmp.repair | _fix_malloc >>$here/$seq.full
929 echo "*** end xfs_repair output" >>$here/$seq.full
933 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
937 echo "*** mount output ***" >>$here/$seq.full
938 _mount >>$here/$seq.full
939 echo "*** end mount output" >>$here/$seq.full
940 elif [ "$type" = "xfs" ]
942 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
945 [ $ok -eq 0 ] && exit 1
949 # Filter the knowen errors the UDF Verifier reports.
950 _udf_test_known_error_filter()
952 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."
956 _check_udf_filesystem()
958 [ "$DISABLE_UDF_TEST" == "1" ] && return
960 if [ $# -ne 1 -a $# -ne 2 ]
962 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
966 if [ ! -x $here/src/udf_test ]
968 echo "udf_test not installed, please download and build the Philips"
969 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
970 echo "Then copy the udf_test binary to $here/src/."
971 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
979 LAST_BLOCK=`expr \( $2 - 1 \)`
980 OPT_ARG="-lastvalidblock $LAST_BLOCK"
984 sleep 1 # Due to a problem with time stamps in udf_test
985 $here/src/udf_test $OPT_ARG $device | tee $here/$seq.checkfs | egrep "Error|Warning" | \
986 _udf_test_known_error_filter | \
987 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
988 sed "s/^.*$/Warning UDF Verifier reported errors see $seq.checkfs./g"
996 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
997 TEST_LOG="$TEST_LOGDEV"
999 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1000 TEST_RT="$TEST_RTDEV"
1002 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1004 # check for ipath consistency
1005 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1006 # errors go to stderr
1007 xfs_check_ipaths $TEST_DIR >/dev/null
1008 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1019 # no way to check consistency for nfs
1022 # do nothing for now
1025 _check_generic_filesystem $TEST_DEV
1036 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
1037 SCRATCH_LOG="$SCRATCH_LOGDEV"
1039 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
1040 SCRATCH_RT="$SCRATCH_RTDEV"
1042 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
1045 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
1048 # Don't know how to check an NFS filesystem, yet.
1051 _check_generic_filesystem $SCRATCH_DEV
1056 _full_fstyp_details()
1058 [ -z "$FSTYP" ] && FSTYP=xfs
1059 if [ $FSTYP = xfs ]; then
1060 if [ -d /proc/fs/xfs ]; then
1061 if grep -q 'debug 0' /proc/fs/xfs/stat; then
1062 FSTYP="$FSTYP (non-debug)"
1063 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
1064 FSTYP="$FSTYP (debug)"
1067 if uname -a | grep -qi 'debug'; then
1068 FSTYP="$FSTYP (debug)"
1070 FSTYP="$FSTYP (non-debug)"
1077 _full_platform_details()
1083 echo "$os/$platform $host $kernel"
1086 _setup_udf_scratchdir()
1088 [ "$FSTYP" != "udf" ] \
1089 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1090 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1091 && _notrun "this test requires a valid \$SCRATCH_DEV"
1092 [ -z "$SCRATCH_MNT" ] \
1093 && _notrun "this test requires a valid \$SCRATCH_MNT"
1096 if _mount | grep -q $SCRATCH_DEV
1098 # if it's mounted, make sure its on $TEST_RW_DIR
1099 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1101 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1103 $UMOUNT_PROG $SCRATCH_DEV
1109 testdir=$SCRATCH_MNT
1112 _setup_nfs_scratchdir()
1114 [ "$FSTYP" != "nfs" ] \
1115 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1116 [ -z "$SCRATCH_DEV" ] \
1117 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1118 [ -z "$SCRATCH_MNT" ] \
1119 && _notrun "this test requires a valid \$SCRATCH_MNT"
1122 if _mount | grep -q $SCRATCH_DEV
1124 # if it's mounted, make sure its on $SCRATCH_MNT
1125 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1127 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1129 $UMOUNT_PROG $SCRATCH_DEV
1135 testdir=$SCRATCH_MNT
1139 # Warning for UDF and NFS:
1140 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
1141 # which actually uses the scratch dir for the test dir.
1143 # This was done because testdir was intended to be a persistent
1144 # XFS only partition. This should eventually change, and treat
1145 # at least local filesystems all the same.
1151 _setup_udf_scratchdir
1154 _setup_nfs_scratchdir
1166 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1167 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1170 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1171 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1174 # do nothing, testdir is $TEST_DIR
1182 if [ -z "$1" ]; then
1183 echo Error must pass \$seq.
1187 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1189 elif [ "`uname`" == "Linux" ]; then
1192 echo Error test $seq does not run on the operating system: `uname`
1210 if [ $size -gt 0 ]; then
1211 dd if=/dev/zero of=$file bs=1024 count=$size
1217 # takes dirname, depth
1220 dirname=$1; depth=$2
1221 mkdir $dirname || die "mkdir $dirname failed"
1224 _nfiles $files # files for this dir
1226 [ $depth -eq 0 ] && return
1227 let deep=$depth-1 # go 1 down
1229 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1232 while [ $d -lt $dirs ]
1234 _descend d$d $deep &
1240 # Populate a filesystem with inodes for performance experiments
1242 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
1247 dirs=5 # ndirs in each subdir till leaves
1248 size=0 # sizeof files in K
1249 files=100 # num files in _each_ subdir
1250 depth=2 # depth of tree from root to leaves
1252 root=root # path of initial root of directory tree
1254 while getopts "d:f:n:r:s:v" c
1266 _descend $root $depth
1271 [ $verbose = true ] && echo done
1274 # query whether the given file has the given inode flag set
1281 if which $XFS_IO_PROG >/dev/null; then
1282 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1289 # query the given files extsize allocator hint in bytes (if any)
1296 if which $XFS_IO_PROG >/dev/null; then
1297 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1298 awk '/^xattr.extsize =/ { print $3 }'`
1300 [ -z "$blocks" ] && blocks="0"
1305 ################################################################################
1307 if [ "$iam" != new -a "$iam" != bench ]
1309 # make some further configuration checks here
1311 if [ "$TEST_DEV" = "" ]
1313 echo "common.rc: Error: \$TEST_DEV is not set"
1317 # if $TEST_DEV is not mounted, mount it now as XFS
1318 if [ -z "`_fs_type $TEST_DEV`" ]
1320 # $TEST_DEV is not mounted
1323 echo "common.rc: retrying test device mount with external set"
1324 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
1327 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
1333 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
1335 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
1341 # make sure this script returns success