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 $@
40 # ls -l w/ selinux sometimes puts a dot at the end:
41 # -rwxrw-r--. id1 id2 file1
45 ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /"
50 # SELinux adds extra xattrs which can mess up our expected output.
51 # So, mount with a context, and they won't be created
52 # nfs_t is a "liberal" context so we can use it.
53 if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
54 SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
59 export SELINUX_MOUNT_OPTIONS
60 export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
63 export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
66 export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
69 # acls & xattrs aren't turned on by default on ext$FOO
70 export MOUNT_OPTIONS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
73 # acls & xattrs aren't turned on by default on reiserfs
74 export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
77 # acls aren't turned on by default on gfs2
78 export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
89 export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
92 [ ! -z "$udf_fsize" ] && \
93 UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
94 export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
97 export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
100 export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
103 export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
114 export FSCK_OPTIONS="-nf"
117 export FSCK_OPTIONS="--yes"
120 export FSCK_OPTIONS="-n"
125 [ -z "$FSTYP" ] && FSTYP=xfs
126 [ -z "$MOUNT_OPTIONS" ] && _mount_opts
127 [ -z "$MKFS_OPTIONS" ] && _mkfs_opts
128 [ -z "$FSCK_OPTIONS" ] && _fsck_opts
131 # we need common.config
132 if [ "$iam" != "check" ]
134 if ! . ./common.config
136 echo "$iam: failed to source common.config"
141 # make sure we have a standard umask
146 $MOUNT_PROG `_mount_ops_filter $*`
154 if [ "$FSTYP" != "xfs" ]; then
160 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
169 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
170 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
171 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
172 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
180 if [ "$FSTYP" != "xfs" ]; then
194 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
195 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
196 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
197 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
204 #get mount point to handle dmapi mtpt option correctly
206 [ $last_index -gt 0 ] && shift $last_index
209 # irix is fussy about how it is fed its mount options
210 # - multiple -o's are not allowed
211 # - no spaces between comma delimitered options
212 # the sed script replaces all -o's (except the first) with a comma
213 # not required for linux, but won't hurt
215 echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
216 | sed -e 's/dmapi/dmi/' \
217 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
221 _scratch_mount_options()
223 _scratch_options mount
225 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
230 _mount -t $FSTYP `_scratch_mount_options $*`
235 $UMOUNT_PROG $SCRATCH_DEV
247 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
250 _scratch_mkfs_options()
252 _scratch_options mkfs
253 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
258 # extra mkfs options can be added by tests
259 local extra_mkfs_options=$*
263 _scratch_options mkfs
265 # save mkfs output in case conflict means we need to run again.
266 # only the output for the mkfs that applies should be shown
267 $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
268 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
271 # a mkfs failure may be caused by conflicts between
272 # $MKFS_OPTIONS and $extra_mkfs_options
274 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
275 echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
277 echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
279 # running mkfs again. overwrite previous mkfs output files
280 $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
281 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
285 # output stored mkfs output
286 cat $tmp_dir.mkfserr >&2
288 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
290 if [ "$USE_BIG_LOOPFS" = yes ]; then
291 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
292 ./tools/ag-wipe -q -r $RETAIN_AG_BYTES $SCRATCH_DEV
308 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
311 /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
316 # Create fs of certain size on scratch device
317 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
318 _scratch_mkfs_sized()
322 [ -z "$blocksize" ] && blocksize=4096
323 blocks=`expr $fssize / $blocksize`
327 _scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
330 /sbin/mkfs.$FSTYP -b $blocksize $SCRATCH_DEV $blocks
333 _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
338 # Emulate an N-data-disk stripe w/ various stripe units
339 # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
345 [ -z "$blocksize" ] && blocksize=4096
347 let sunit_blocks=$sunit_bytes/$blocksize
348 let swidth_blocks=$sunit_blocks*$swidth_mult
352 MKFS_OPTIONS="-b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
355 MKFS_OPTIONS="-b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
358 _notrun "can't mkfs $FSTYP with geometry"
368 xfs_io -x -c "resblks $1" $SCRATCH_MNT
375 _scratch_xfs_db_options()
378 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
379 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
380 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
383 _scratch_xfs_logprint()
386 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
387 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
388 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
394 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
395 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
396 $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
399 _scratch_xfs_repair()
402 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
403 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
404 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
405 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
406 [ "$USE_BIG_LOOPFS" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
407 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
414 echo "Usage: _get_pids_by_name process-name" 1>&2
418 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
419 # HH:MM:SS before the psargs field, use this as the search anchor.
421 # Matches with $1 (process-name) occur if the first psarg is $1
422 # or ends in /$1 ... the matching uses sed's regular expressions,
423 # so passing a regex into $1 will work.
431 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
432 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
435 # fix malloc libs output
439 # filter out the Electric Fence notice
442 if (defined $o && /^\s+Electric Fence/) {
448 print $o if (defined $o);
452 print $o if (defined $o);
456 # check if run as root
460 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
463 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
470 # _df_device : get an IRIX style df line for a given device
472 # - returns "" if not mounted
473 # - returns fs type in field two (ala IRIX)
474 # - joins line together if split by fancy df formatting
475 # - strips header etc
482 echo "Usage: _df_device device" 1>&2
486 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
487 match($1,what) && NF==1 {
501 # _df_dir : get an IRIX style df line for device where a directory resides
503 # - returns fs type in field two (ala IRIX)
504 # - joins line together if split by fancy df formatting
505 # - strips header etc
512 echo "Usage: _df_dir device" 1>&2
516 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
532 # return percentage used disk space for mounted device
538 echo "Usage: _used device" 1>&2
542 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
545 # return the FS type of a mounted device
551 echo "Usage: _fs_type device" 1>&2
555 _df_device $1 | $AWK_PROG '{ print $2 }'
558 # return the FS mount options of a mounted device
560 # should write a version which just parses the output of mount for IRIX
561 # compatibility, but since this isn't used at all, at the moment I'll leave
568 echo "Usage: _fs_options device" 1>&2
572 $AWK_PROG -v dev=$1 '
573 match($1,dev) { print $4 }
577 # returns device number if a file is a block device
583 echo "Usage: _is_block_dev dev" 1>&2
587 [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
590 # Do a command, log it to $seq.full, optionally test return status
591 # and die if command fails. If called with one argument _do executes the
592 # command, logs it, and returns its exit status. With two arguments _do
593 # first prints the message passed in the first argument, and then "done"
594 # or "fail" depending on the return status of the command passed in the
595 # second argument. If the command fails and the variable _do_die_on_error
596 # is set to "always" or the two argument form is used and _do_die_on_error
597 # is set to "message_only" _do will print an error message to
602 if [ $# -eq 1 ]; then
604 elif [ $# -eq 2 ]; then
609 echo "Usage: _do [note] cmd" 1>&2
613 (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
614 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
615 cat $tmp._out | _fix_malloc >>$here/$seq.full
616 if [ $# -eq 2 ]; then
617 if [ $ret -eq 0 ]; then
624 && [ "$_do_die_on_error" = "always" \
625 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
628 eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
635 # bail out, setting up .notrun file
639 echo "$*" >$seq.notrun
640 echo "$seq not run: $*"
645 # just plain bail out
649 echo "$*" | tee -a $here/$seq.full
650 echo "(see $seq.full for details)"
655 # tests whether $FSTYP is one of the supported filesystems for a test
661 if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
667 _notrun "not suitable for this filesystem type: $FSTYP"
670 # tests whether $FSTYP is one of the supported OSes for a test
676 if [ "$h" = "$HOSTOS" ]
682 _notrun "not suitable for this OS: $HOSTOS"
685 # this test needs a scratch partition - check we're ok & unmount it
691 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
692 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
694 _notrun "this test requires a valid \$SCRATCH_DEV"
698 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
700 _notrun "this test requires a valid \$SCRATCH_DEV"
702 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
704 _notrun "this test requires a valid \$SCRATCH_DEV"
706 if [ ! -d "$SCRATCH_MNT" ]
708 _notrun "this test requires a valid \$SCRATCH_MNT"
714 if _mount | grep -q $SCRATCH_DEV
716 # if it's mounted, make sure its on $SCRATCH_MNT
717 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
719 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
722 # and then unmount it
723 if ! $UMOUNT_PROG $SCRATCH_DEV
725 echo "failed to unmount $SCRATCH_DEV"
731 # this test needs a logdev
735 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
736 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
737 [ "$USE_EXTERNAL" != yes ] && \
738 _notrun "This test requires USE_EXTERNAL to be enabled"
740 # ensure its not mounted
741 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
744 # this test requires loopback device support
748 if [ "$HOSTOS" != "Linux" ]
750 _notrun "This test requires linux for loopback device support"
753 modprobe loop >/dev/null 2>&1
754 if grep loop /proc/devices >/dev/null 2>&1
758 _notrun "This test requires loopback device support"
762 # this test requires that (large) loopback device files are not in use
764 _require_nobigloopfs()
766 [ "$USE_BIG_LOOPFS" = yes ] && \
767 _notrun "Large filesystem testing in progress, skipped this test"
770 # this test requires that a realtime subvolume is in use, and
771 # that the kernel supports realtime as well.
775 [ "$USE_EXTERNAL" = yes ] || \
776 _notrun "External volumes not in use, skipped this test"
777 [ "$SCRATCH_RTDEV" = "" ] && \
778 _notrun "Realtime device required, skipped this test"
781 # this test requires that a specified command (executable) exists
785 [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
788 # this test requires that external log/realtime devices are not in use
790 _require_nonexternal()
792 [ "$USE_EXTERNAL" = yes ] && \
793 _notrun "External device testing in progress, skipped this test"
796 # indicate whether YP/NIS is active or not
801 dn=$(domainname 2>/dev/null)
802 test -n "${dn}" -a "${dn}" != "(none)"
805 # cat the password file
809 [ _yp_active ] && ypcat passwd
817 [ _yp_active ] && ypcat group
820 export -f _yp_active _cat_passwd _cat_group
822 # check for the fsgqa user on the machine
827 _cat_passwd | grep -q $qa_user
828 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
831 # check that xfs_io, glibc, kernel, and filesystem all (!) support
834 _require_xfs_io_falloc()
836 testfile=$TEST_DIR/$$.falloc
837 testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
838 rm -f $testfile 2>&1 > /dev/null
839 echo $testio | grep -q "not found" && \
840 _notrun "xfs_io fallocate support is missing"
841 echo $testio | grep -q "Operation not supported" && \
842 _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
845 # Check that a fs has enough free space (in 1024b blocks)
850 BLOCKS=$2 # in units of 1024
851 let GB=$BLOCKS/1024/1024
853 FREE_BLOCKS=`df -klP $MNT | grep -v Filesystem | awk '{print $4}'`
854 [ $FREE_BLOCKS -lt $BLOCKS ] && \
855 _notrun "This test requires at least ${GB}GB free on $MNT to run"
858 # check that a FS on a device is mounted
859 # if so, return mount point
865 echo "Usage: _is_mounted device" 1>&2
871 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
872 pattern { print $3 ; exit 0 }
876 echo "_is_mounted: $device is not a mounted $FSTYP FS"
881 # remount a FS to a new mode (ro or rw)
887 echo "Usage: _remount device ro/rw" 1>&2
893 if ! mount -o remount,$mode $device
895 echo "_remount: failed to remount filesystem on $device as $mode"
900 # Run the appropriate repair/check on a filesystem
902 # if the filesystem is mounted, it's either remounted ro before being
903 # checked or it's unmounted and then remounted
906 # If set, we remount ro instead of unmounting for fsck
909 _umount_or_remount_ro()
913 echo "Usage: _umount_or_remount_ro <device>" 1>&2
918 mountpoint=`_is_mounted $device`
920 if [ $USE_REMOUNT -eq 0 ]; then
928 _mount_or_remount_rw()
932 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
939 if [ $USE_REMOUNT -eq 0 ]
941 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
943 echo "!!! failed to remount $device on $mountpoint"
953 # Check a generic filesystem in no-op mode; this assumes that the
954 # underlying fsck program accepts "-n" for a no-op (check-only) run,
955 # and that it will still return an errno for corruption in this mode.
957 # Filesystems which don't support this will need to define their
960 _check_generic_filesystem()
964 # If type is set, we're mounted
965 type=`_fs_type $device`
968 if [ "$type" = "$FSTYP" ]
971 mountpoint=`_umount_or_remount_ro $device`
974 fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
977 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seq.full)"
979 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
980 echo "*** fsck.$FSTYP output ***" >>$here/$seq.full
981 cat $tmp.fsck >>$here/$seq.full
982 echo "*** end fsck.$FSTYP output" >>$here/$seq.full
990 echo "*** mount output ***" >>$here/$seq.full
991 _mount >>$here/$seq.full
992 echo "*** end mount output" >>$here/$seq.full
993 elif [ "$type" = "$FSTYP" ]
996 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
1000 if [ $ok -eq 0 ]; then
1008 # run xfs_check and friends on a FS.
1010 _check_xfs_filesystem()
1014 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
1018 extra_mount_options=""
1020 if [ "$2" != "none" ]; then
1021 extra_log_options="-l$2"
1022 extra_mount_options="-ologdev=$2"
1025 if [ "$3" != "none" ]; then
1026 extra_rt_options="-r$3"
1027 extra_mount_options=$extra_mount_options" -ortdev=$3"
1029 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
1031 [ "$FSTYP" != xfs ] && return 0
1033 [ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
1035 type=`_fs_type $device`
1038 if [ "$type" = "xfs" ]
1041 mountpoint=`_umount_or_remount_ro $device`
1044 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
1045 | tee $tmp.logprint | grep -q "<CLEAN>"
1046 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
1048 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seq.full)"
1050 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$here/$seq.full
1051 echo "*** xfs_logprint -t output ***" >>$here/$seq.full
1052 cat $tmp.logprint >>$here/$seq.full
1053 echo "*** end xfs_logprint output" >>$here/$seq.full
1058 $XFS_CHECK_PROG $testoption $extra_log_options $device 2>&1 |\
1059 _fix_malloc >$tmp.fs_check
1060 if [ -s $tmp.fs_check ]
1062 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seq.full)"
1064 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
1065 echo "*** xfs_check output ***" >>$here/$seq.full
1066 cat $tmp.fs_check >>$here/$seq.full
1067 echo "*** end xfs_check output" >>$here/$seq.full
1071 # repair doesn't scale massively at this stage, optionally skip it for now
1072 [ "$USE_BIG_LOOPFS" = yes ] || \
1073 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
1076 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seq.full)"
1078 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
1079 echo "*** xfs_repair -n output ***" >>$here/$seq.full
1080 cat $tmp.repair | _fix_malloc >>$here/$seq.full
1081 echo "*** end xfs_repair output" >>$here/$seq.full
1085 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
1089 echo "*** mount output ***" >>$here/$seq.full
1090 _mount >>$here/$seq.full
1091 echo "*** end mount output" >>$here/$seq.full
1092 elif [ "$type" = "xfs" ]
1094 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
1097 if [ $ok -eq 0 ]; then
1105 # Filter the knowen errors the UDF Verifier reports.
1106 _udf_test_known_error_filter()
1108 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."
1112 _check_udf_filesystem()
1114 [ "$DISABLE_UDF_TEST" == "1" ] && return
1116 if [ $# -ne 1 -a $# -ne 2 ]
1118 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
1122 if [ ! -x $here/src/udf_test ]
1124 echo "udf_test not installed, please download and build the Philips"
1125 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
1126 echo "Then copy the udf_test binary to $here/src/."
1127 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
1135 LAST_BLOCK=`expr \( $2 - 1 \)`
1136 OPT_ARG="-lastvalidblock $LAST_BLOCK"
1140 sleep 1 # Due to a problem with time stamps in udf_test
1141 $here/src/udf_test $OPT_ARG $device | tee $here/$seq.checkfs | egrep "Error|Warning" | \
1142 _udf_test_known_error_filter | \
1143 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
1144 sed "s/^.*$/Warning UDF Verifier reported errors see $seq.checkfs./g"
1148 _check_xfs_test_fs()
1152 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
1153 TEST_LOG="$TEST_LOGDEV"
1155 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1156 TEST_RT="$TEST_RTDEV"
1158 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1160 # check for ipath consistency
1161 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1162 # errors go to stderr
1163 xfs_check_ipaths $TEST_DIR >/dev/null
1164 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1175 # no way to check consistency for nfs
1178 # do nothing for now
1181 _check_generic_filesystem $TEST_DEV
1192 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
1193 SCRATCH_LOG="$SCRATCH_LOGDEV"
1195 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
1196 SCRATCH_RT="$SCRATCH_RTDEV"
1198 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
1201 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
1204 # Don't know how to check an NFS filesystem, yet.
1207 _check_generic_filesystem $SCRATCH_DEV
1212 _full_fstyp_details()
1214 [ -z "$FSTYP" ] && FSTYP=xfs
1215 if [ $FSTYP = xfs ]; then
1216 if [ -d /proc/fs/xfs ]; then
1217 if grep -q 'debug 0' /proc/fs/xfs/stat; then
1218 FSTYP="$FSTYP (non-debug)"
1219 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
1220 FSTYP="$FSTYP (debug)"
1223 if uname -a | grep -qi 'debug'; then
1224 FSTYP="$FSTYP (debug)"
1226 FSTYP="$FSTYP (non-debug)"
1233 _full_platform_details()
1239 echo "$os/$platform $host $kernel"
1242 _setup_udf_scratchdir()
1244 [ "$FSTYP" != "udf" ] \
1245 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1246 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1247 && _notrun "this test requires a valid \$SCRATCH_DEV"
1248 [ -z "$SCRATCH_MNT" ] \
1249 && _notrun "this test requires a valid \$SCRATCH_MNT"
1252 if _mount | grep -q $SCRATCH_DEV
1254 # if it's mounted, make sure its on $TEST_RW_DIR
1255 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1257 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1259 $UMOUNT_PROG $SCRATCH_DEV
1265 testdir=$SCRATCH_MNT
1268 _setup_nfs_scratchdir()
1270 [ "$FSTYP" != "nfs" ] \
1271 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1272 [ -z "$SCRATCH_DEV" ] \
1273 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1274 [ -z "$SCRATCH_MNT" ] \
1275 && _notrun "this test requires a valid \$SCRATCH_MNT"
1278 if _mount | grep -q $SCRATCH_DEV
1280 # if it's mounted, make sure its on $SCRATCH_MNT
1281 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1283 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1285 $UMOUNT_PROG $SCRATCH_DEV
1291 testdir=$SCRATCH_MNT
1295 # Warning for UDF and NFS:
1296 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
1297 # which actually uses the scratch dir for the test dir.
1299 # This was done because testdir was intended to be a persistent
1300 # XFS only partition. This should eventually change, and treat
1301 # at least local filesystems all the same.
1307 _setup_udf_scratchdir
1310 _setup_nfs_scratchdir
1322 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1323 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1326 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1327 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1330 # do nothing, testdir is $TEST_DIR
1338 if [ -z "$1" ]; then
1339 echo Error must pass \$seq.
1343 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1345 elif [ "`uname`" == "Linux" ]; then
1348 echo Error test $seq does not run on the operating system: `uname`
1366 if [ $size -gt 0 ]; then
1367 dd if=/dev/zero of=$file bs=1024 count=$size
1373 # takes dirname, depth
1376 dirname=$1; depth=$2
1377 mkdir $dirname || die "mkdir $dirname failed"
1380 _nfiles $files # files for this dir
1382 [ $depth -eq 0 ] && return
1383 let deep=$depth-1 # go 1 down
1385 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1388 while [ $d -lt $dirs ]
1390 _descend d$d $deep &
1396 # Populate a filesystem with inodes for performance experiments
1398 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
1403 dirs=5 # ndirs in each subdir till leaves
1404 size=0 # sizeof files in K
1405 files=100 # num files in _each_ subdir
1406 depth=2 # depth of tree from root to leaves
1408 root=root # path of initial root of directory tree
1410 while getopts "d:f:n:r:s:v" c
1422 _descend $root $depth
1427 [ $verbose = true ] && echo done
1430 # query whether the given file has the given inode flag set
1437 if which $XFS_IO_PROG >/dev/null; then
1438 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1445 # query the given files extsize allocator hint in bytes (if any)
1452 if which $XFS_IO_PROG >/dev/null; then
1453 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1454 awk '/^xattr.extsize =/ { print $3 }'`
1456 [ -z "$blocks" ] && blocks="0"
1461 ################################################################################
1463 if [ "$iam" != new -a "$iam" != bench ]
1465 # make some further configuration checks here
1467 if [ "$TEST_DEV" = "" ]
1469 echo "common.rc: Error: \$TEST_DEV is not set"
1473 # if $TEST_DEV is not mounted, mount it now as XFS
1474 if [ -z "`_fs_type $TEST_DEV`" ]
1476 # $TEST_DEV is not mounted
1479 echo "common.rc: retrying test device mount with external set"
1480 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
1483 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
1489 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
1491 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
1497 # make sure this script returns success