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 #-----------------------------------------------------------------------
23 BC=$(which bc 2> /dev/null) || BC=
28 _notrun "this test requires 'bc' tool for doing math operations"
34 [ $# -le 0 ] && return
36 result=$(LANG=C echo "scale=0; $@" | "$BC" -q 2> /dev/null)
38 _notrun "this test requires 'bc' tool for doing math operations"
45 if [ "$HOSTOS" == "Linux" ]
47 command dd --help | grep noxfer > /dev/null 2>&1
51 command dd status=noxfer $@
60 # ls -l w/ selinux sometimes puts a dot at the end:
61 # -rwxrw-r--. id1 id2 file1
65 ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /"
70 # SELinux adds extra xattrs which can mess up our expected output.
71 # So, mount with a context, and they won't be created
72 # nfs_t is a "liberal" context so we can use it.
73 if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
74 SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
75 export SELINUX_MOUNT_OPTIONS
80 export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
83 export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
86 export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
88 ext2|ext3|ext4|ext4dev)
89 # acls & xattrs aren't turned on by default on ext$FOO
90 export MOUNT_OPTIONS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
93 # acls & xattrs aren't turned on by default on reiserfs
94 export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
97 # acls aren't turned on by default on gfs2
98 export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
109 export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
112 [ ! -z "$udf_fsize" ] && \
113 UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
114 export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
117 export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
120 export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
123 export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
126 export MKFS_OPTIONS="$JFS_MKFS_OPTIONS -q"
136 ext2|ext3|ext4|ext4dev)
137 export FSCK_OPTIONS="-nf"
140 export FSCK_OPTIONS="--yes"
143 export FSCK_OPTIONS="-n"
148 [ -z "$FSTYP" ] && FSTYP=xfs
149 [ -z "$MOUNT_OPTIONS" ] && _mount_opts
150 [ -z "$MKFS_OPTIONS" ] && _mkfs_opts
151 [ -z "$FSCK_OPTIONS" ] && _fsck_opts
154 # we need common.config
155 if [ "$iam" != "check" ]
157 if ! . ./common/config
159 echo "$iam: failed to source common.config"
164 # check for correct setup
167 [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
168 [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
169 [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
170 [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
171 [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
174 [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
177 [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
183 # make sure we have a standard umask
188 $MOUNT_PROG `_mount_ops_filter $*`
196 if [ "$FSTYP" != "xfs" ]; then
202 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
211 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
212 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
213 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
214 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
222 if [ "$FSTYP" != "xfs" ]; then
236 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
237 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
238 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
239 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
246 #get mount point to handle dmapi mtpt option correctly
248 [ $last_index -gt 0 ] && shift $last_index
251 # irix is fussy about how it is fed its mount options
252 # - multiple -o's are not allowed
253 # - no spaces between comma delimitered options
254 # the sed script replaces all -o's (except the first) with a comma
255 # not required for linux, but won't hurt
257 echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
258 | sed -e 's/dmapi/dmi/' \
259 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
263 _scratch_mount_options()
265 _scratch_options mount
267 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
272 _mount -t $FSTYP `_scratch_mount_options $*`
277 $UMOUNT_PROG $SCRATCH_DEV
289 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
292 _scratch_mkfs_options()
294 _scratch_options mkfs
295 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
299 _setup_large_xfs_fs()
304 [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
305 [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
306 [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
308 # calculate the size of the file we need to allocate.
309 # Default free space in the FS is 50GB, but you can specify more via
310 # SCRATCH_DEV_EMPTY_SPACE
311 file_size=$(($fs_size - 50*1024*1024*1024))
312 file_size=$(($file_size - $SCRATCH_DEV_EMPTY_SPACE))
314 # mount the filesystem, create the file, unmount it
315 _scratch_mount 2>&1 >$tmp_dir/mnt.err
317 if [ $status -ne 0 ]; then
319 cat $tmp_dir/mnt.err >&2
320 rm -f $tmp_dir/mnt.err
323 rm -f $tmp_dir/mnt.err
326 -c "truncate $file_size" \
327 -c "falloc -k 0 $file_size" \
329 $SCRATCH_MNT/.use_space 2>&1 > /dev/null
330 export NUM_SPACE_FILES=1
333 if [ $status -ne 0 ]; then
334 echo "large file prealloc failed"
335 cat $tmp_dir/mnt.err >&2
343 # extra mkfs options can be added by tests
344 local extra_mkfs_options=$*
348 _scratch_options mkfs
350 # save mkfs output in case conflict means we need to run again.
351 # only the output for the mkfs that applies should be shown
352 $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
353 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
356 # a mkfs failure may be caused by conflicts between
357 # $MKFS_OPTIONS and $extra_mkfs_options
359 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
360 echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
362 echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
364 # running mkfs again. overwrite previous mkfs output files
365 $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
366 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
370 if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
371 # manually parse the mkfs output to get the fs size in bytes
373 fs_size=`cat $tmp_dir.mkfsstd | perl -ne '
374 if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+)/) {
376 print STDOUT "$size\n";
378 _setup_large_xfs_fs $fs_size
382 # output stored mkfs output
383 cat $tmp_dir.mkfserr >&2
385 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
390 _setup_large_ext4_fs()
395 [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
396 [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
397 [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
399 # Default free space in the FS is 50GB, but you can specify more via
400 # SCRATCH_DEV_EMPTY_SPACE
401 space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE))
403 # mount the filesystem and create 16TB - 4KB files until we consume
404 # all the necessary space.
405 _scratch_mount 2>&1 >$tmp_dir/mnt.err
407 if [ $status -ne 0 ]; then
409 cat $tmp_dir/mnt.err >&2
410 rm -f $tmp_dir/mnt.err
413 rm -f $tmp_dir/mnt.err
415 file_size=$((16*1024*1024*1024*1024 - 4096))
417 while [ $space_to_consume -gt $file_size ]; do
420 -c "truncate $file_size" \
421 -c "falloc -k 0 $file_size" \
422 $SCRATCH_MNT/.use_space.$nfiles 2>&1
424 if [ $status -ne 0 ]; then
428 space_to_consume=$(( $space_to_consume - $file_size ))
429 nfiles=$(($nfiles + 1))
432 # consume the remaining space.
433 if [ $space_to_consume -gt 0 ]; then
435 -c "truncate $space_to_consume" \
436 -c "falloc -k 0 $space_to_consume" \
437 $SCRATCH_MNT/.use_space.$nfiles 2>&1
440 export NUM_SPACE_FILES=$nfiles
443 if [ $status -ne 0 ]; then
444 echo "large file prealloc failed"
445 cat $tmp_dir/mnt.err >&2
454 /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV \
455 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
458 if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
459 # manually parse the mkfs output to get the fs size in bytes
460 fs_size=`cat $tmp_dir.mkfsstd | awk ' \
461 /^Block size/ { split($2, a, "="); bs = a[2] ; } \
462 / inodes, / { blks = $3 } \
463 /reserved for the super user/ { resv = $1 } \
464 END { fssize = bs * blks - resv; print fssize }'`
466 _setup_large_ext4_fs $fs_size
470 # output stored mkfs output
471 cat $tmp_dir.mkfserr >&2
473 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
488 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
491 $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
494 _scratch_mkfs_ext4 $*
497 yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
502 # Create fs of certain size on scratch device
503 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
504 _scratch_mkfs_sized()
508 [ -z "$blocksize" ] && blocksize=4096
509 blocks=`expr $fssize / $blocksize`
511 if [ "$HOSTOS" == "Linux" ]; then
512 devsize=`blockdev --getsize64 $SCRATCH_DEV`
513 [ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
518 _scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
520 ext2|ext3|ext4|ext4dev)
521 yes | ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
524 $MKFS_BTRFS_PROG $MKFS_OPTIONS -b $fssize $SCRATCH_DEV
527 _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
532 # Emulate an N-data-disk stripe w/ various stripe units
533 # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
539 [ -z "$blocksize" ] && blocksize=4096
541 let sunit_blocks=$sunit_bytes/$blocksize
542 let swidth_blocks=$sunit_blocks*$swidth_mult
546 MKFS_OPTIONS+=" -b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
549 MKFS_OPTIONS+=" -b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
552 _notrun "can't mkfs $FSTYP with geometry"
562 xfs_io -x -c "resblks $1" $SCRATCH_MNT
569 _scratch_xfs_db_options()
572 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
573 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
574 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
577 _scratch_xfs_logprint()
580 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
581 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
582 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
588 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
589 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
590 [ "$LARGE_SCRATCH_DEV" = yes ] && \
591 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
592 $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
595 _scratch_xfs_repair()
598 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
599 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
600 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
601 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
602 [ "$LARGE_SCRATCH_DEV" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
603 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
610 echo "Usage: _get_pids_by_name process-name" 1>&2
614 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
615 # HH:MM:SS before the psargs field, use this as the search anchor.
617 # Matches with $1 (process-name) occur if the first psarg is $1
618 # or ends in /$1 ... the matching uses sed's regular expressions,
619 # so passing a regex into $1 will work.
627 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
628 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
631 # fix malloc libs output
635 # filter out the Electric Fence notice
638 if (defined $o && /^\s+Electric Fence/) {
644 print $o if (defined $o);
648 print $o if (defined $o);
652 # check if run as root
656 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
659 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
666 # _df_device : get an IRIX style df line for a given device
668 # - returns "" if not mounted
669 # - returns fs type in field two (ala IRIX)
670 # - joins line together if split by fancy df formatting
671 # - strips header etc
678 echo "Usage: _df_device device" 1>&2
682 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
683 match($1,what) && NF==1 {
697 # _df_dir : get an IRIX style df line for device where a directory resides
699 # - returns fs type in field two (ala IRIX)
700 # - joins line together if split by fancy df formatting
701 # - strips header etc
708 echo "Usage: _df_dir device" 1>&2
712 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
728 # return percentage used disk space for mounted device
734 echo "Usage: _used device" 1>&2
738 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
741 # return the FS type of a mounted device
747 echo "Usage: _fs_type device" 1>&2
752 # The Linux kernel shows NFSv4 filesystems in df output as
753 # filesystem type nfs4, although we mounted it as nfs earlier.
754 # Fix the filesystem type up here so that the callers don't
755 # have to bother with this quirk.
757 _df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'
760 # return the FS mount options of a mounted device
762 # should write a version which just parses the output of mount for IRIX
763 # compatibility, but since this isn't used at all, at the moment I'll leave
770 echo "Usage: _fs_options device" 1>&2
774 $AWK_PROG -v dev=$1 '
775 match($1,dev) { print $4 }
779 # returns device number if a file is a block device
785 echo "Usage: _is_block_dev dev" 1>&2
790 if [ -L "${_dev}" ]; then
791 _dev=`readlink -f ${_dev}`
794 if [ -b "${_dev}" ]; then
795 src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }'
799 # Do a command, log it to $seqres.full, optionally test return status
800 # and die if command fails. If called with one argument _do executes the
801 # command, logs it, and returns its exit status. With two arguments _do
802 # first prints the message passed in the first argument, and then "done"
803 # or "fail" depending on the return status of the command passed in the
804 # second argument. If the command fails and the variable _do_die_on_error
805 # is set to "always" or the two argument form is used and _do_die_on_error
806 # is set to "message_only" _do will print an error message to
807 # $seqres.out and exit.
811 if [ $# -eq 1 ]; then
813 elif [ $# -eq 2 ]; then
818 echo "Usage: _do [note] cmd" 1>&2
822 (eval "echo '---' \"$_cmd\"") >>$seqres.full
823 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
824 cat $tmp._out | _fix_malloc >>$seqres.full
825 if [ $# -eq 2 ]; then
826 if [ $ret -eq 0 ]; then
833 && [ "$_do_die_on_error" = "always" \
834 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
837 eval "echo \"$_cmd\" failed \(returned $ret\): see $seqres.full"
844 # bail out, setting up .notrun file
848 echo "$*" > $seqres.notrun
849 echo "$seq not run: $*"
854 # just plain bail out
858 echo "$*" | tee -a $seqres.full
859 echo "(see $seqres.full for details)"
864 # tests whether $FSTYP is one of the supported filesystems for a test
870 if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
876 _notrun "not suitable for this filesystem type: $FSTYP"
879 # tests whether $FSTYP is one of the supported OSes for a test
885 if [ "$h" = "$HOSTOS" ]
891 _notrun "not suitable for this OS: $HOSTOS"
894 # this test needs a scratch partition - check we're ok & unmount it
900 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
901 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
903 _notrun "this test requires a valid \$SCRATCH_DEV"
907 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
909 _notrun "this test requires a valid \$SCRATCH_DEV"
911 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
913 _notrun "this test requires a valid \$SCRATCH_DEV"
915 if [ ! -d "$SCRATCH_MNT" ]
917 _notrun "this test requires a valid \$SCRATCH_MNT"
923 if _mount | grep -q $SCRATCH_DEV
925 # if it's mounted, make sure its on $SCRATCH_MNT
926 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
928 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
931 # and then unmount it
932 if ! $UMOUNT_PROG $SCRATCH_DEV
934 echo "failed to unmount $SCRATCH_DEV"
940 # this test needs a logdev
944 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
945 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
946 [ "$USE_EXTERNAL" != yes ] && \
947 _notrun "This test requires USE_EXTERNAL to be enabled"
949 # ensure its not mounted
950 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
953 # this test requires loopback device support
957 if [ "$HOSTOS" != "Linux" ]
959 _notrun "This test requires linux for loopback device support"
962 modprobe loop >/dev/null 2>&1
963 if grep loop /proc/devices >/dev/null 2>&1
967 _notrun "This test requires loopback device support"
971 # this test requires ext2 filesystem support
975 if [ "$HOSTOS" != "Linux" ]
977 _notrun "This test requires linux for ext2 filesystem support"
980 modprobe ext2 >/dev/null 2>&1
981 if grep ext2 /proc/filesystems >/dev/null 2>&1
985 _notrun "This test requires ext2 filesystem support"
989 # this test requires that (large) loopback device files are not in use
991 _require_no_large_scratch_dev()
993 [ "$LARGE_SCRATCH_DEV" = yes ] && \
994 _notrun "Large filesystem testing in progress, skipped this test"
997 # this test requires that a realtime subvolume is in use, and
998 # that the kernel supports realtime as well.
1002 [ "$USE_EXTERNAL" = yes ] || \
1003 _notrun "External volumes not in use, skipped this test"
1004 [ "$SCRATCH_RTDEV" = "" ] && \
1005 _notrun "Realtime device required, skipped this test"
1008 # this test requires that a specified command (executable) exists
1009 # $1 - command, $2 - name for error message
1013 [ -n "$1" ] && _cmd="$1" || _cmd="$2"
1014 [ -n "$1" -a -x "$1" ] || _notrun "$_cmd utility required, skipped this test"
1017 # this test requires the projid32bit feature to be available in
1020 _require_projid32bit()
1022 _scratch_mkfs_xfs -f -i projid32bit=0 2>&1 >/dev/null \
1023 || _notrun "mkfs.xfs doesn't have projid32bit feature"
1026 # this test requires that external log/realtime devices are not in use
1028 _require_nonexternal()
1030 [ "$USE_EXTERNAL" = yes ] && \
1031 _notrun "External device testing in progress, skipped this test"
1034 # this test requires that a (specified) aio-dio executable exists
1035 # $1 - command (optional)
1041 AIO_TEST=src/aio-dio-regress/aiodio_sparse2
1042 [ -x $AIO_TEST ] || _notrun "aio-dio utilities required"
1044 AIO_TEST=src/aio-dio-regress/$1
1045 [ -x $AIO_TEST ] || _notrun "$AIO_TEST not built"
1049 # run an aio-dio program
1055 echo "usage: _run_aiodio command_name" 2>&1
1061 local testtemp=$TEST_DIR/aio-testfile
1063 $AIO_TEST $testtemp 2>&1
1070 # indicate whether YP/NIS is active or not
1075 dn=$(domainname 2>/dev/null)
1076 test -n "${dn}" -a "${dn}" != "(none)"
1080 # cat the password file
1084 [ $(_yp_active) -eq 0 ] && ypcat passwd
1088 # cat the group file
1092 [ $(_yp_active) -eq 0 ] && ypcat group
1096 # check for the fsgqa user on the machine
1101 _cat_passwd | grep -q $qa_user
1102 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
1103 echo /bin/true | su $qa_user
1104 [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
1107 # check for the fsgqa group on the machine
1112 _cat_group | grep -q $qa_group
1113 [ "$?" == "0" ] || _notrun "$qa_group user not defined."
1119 s,.*Permission\sdenied.*,Permission denied,;
1120 s,.*no\saccess\sto\stty.*,,;
1121 s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
1128 if [ "$HOSTOS" == "IRIX" ]
1130 echo $1 | /bin/bash "su $qa_user 2>&1" | _filter_user_do
1132 echo $1 | su $qa_user 2>&1 | _filter_user_do
1136 # check that xfs_io, kernel, and filesystem all support zero
1137 _require_xfs_io_zero()
1139 testio=`$XFS_IO_PROG -c "zero help" 2>&1`
1140 echo $testio | grep -q 'command "zero" not found' && \
1141 _notrun "zero command not supported"
1144 # check that xfs_io, glibc, kernel, and filesystem all (!) support
1147 _require_xfs_io_falloc()
1149 testfile=$TEST_DIR/$$.falloc
1150 testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
1151 rm -f $testfile 2>&1 > /dev/null
1152 echo $testio | grep -q "not found" && \
1153 _notrun "xfs_io fallocate support is missing"
1154 echo $testio | grep -q "Operation not supported" && \
1155 _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
1158 # check that xfs_io, kernel and filesystem all support fallocate with hole
1160 _require_xfs_io_falloc_punch()
1162 testfile=$TEST_DIR/$$.falloc
1163 testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
1164 -c "fpunch 4k 8k" $testfile 2>&1`
1165 rm -f $testfile 2>&1 > /dev/null
1166 echo $testio | grep -q "not found" && \
1167 _notrun "xfs_io fallocate punch support is missing"
1168 echo $testio | grep -q "Operation not supported" && \
1169 _notrun "xfs_io fallocate punch command failed (no fs support?)"
1172 # check that xfs_io, kernel and filesystem support fiemap
1173 _require_xfs_io_fiemap()
1175 testfile=$TEST_DIR/$$.fiemap
1176 testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
1177 -c "fiemap -v" $testfile 2>&1`
1178 rm -f $testfile 2>&1 > /dev/null
1179 echo $testio | grep -q "not found" && \
1180 _notrun "xfs_io fiemap support is missing"
1181 echo $testio | grep -q "Operation not supported" && \
1182 _notrun "xfs_io fiemap command failed (no fs support?)"
1185 # Check that a fs has enough free space (in 1024b blocks)
1190 BLOCKS=$2 # in units of 1024
1191 let GB=$BLOCKS/1024/1024
1193 FREE_BLOCKS=`df -klP $MNT | grep -v Filesystem | awk '{print $4}'`
1194 [ $FREE_BLOCKS -lt $BLOCKS ] && \
1195 _notrun "This test requires at least ${GB}GB free on $MNT to run"
1199 # Check if the filesystem supports sparse files.
1201 # Unfortunately there is no better way to do this than a manual black list.
1203 _require_sparse_files()
1207 _notrun "Sparse files not supported by this filesystem type: $FSTYP"
1216 #boot_params always present in debugfs
1217 [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
1220 _require_fail_make_request()
1222 [ -f "$DEBUGFS_MNT/fail_make_request/probability" ] \
1223 || _notrun "$DEBUGFS_MNT/fail_make_request \
1224 not found. Seems that CONFIG_FAIL_MAKE_REQUEST kernel config option not enabled"
1227 # check that a FS on a device is mounted
1228 # if so, return mount point
1234 echo "Usage: _is_mounted device" 1>&2
1240 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
1241 pattern { print $3 ; exit 0 }
1245 echo "_is_mounted: $device is not a mounted $FSTYP FS"
1250 # remount a FS to a new mode (ro or rw)
1256 echo "Usage: _remount device ro/rw" 1>&2
1262 if ! mount -o remount,$mode $device
1264 echo "_remount: failed to remount filesystem on $device as $mode"
1269 # Run the appropriate repair/check on a filesystem
1271 # if the filesystem is mounted, it's either remounted ro before being
1272 # checked or it's unmounted and then remounted
1275 # If set, we remount ro instead of unmounting for fsck
1278 _umount_or_remount_ro()
1282 echo "Usage: _umount_or_remount_ro <device>" 1>&2
1287 mountpoint=`_is_mounted $device`
1289 if [ $USE_REMOUNT -eq 0 ]; then
1290 $UMOUNT_PROG $device
1297 _mount_or_remount_rw()
1301 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
1308 if [ $USE_REMOUNT -eq 0 ]
1310 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
1312 echo "!!! failed to remount $device on $mountpoint"
1322 # Check a generic filesystem in no-op mode; this assumes that the
1323 # underlying fsck program accepts "-n" for a no-op (check-only) run,
1324 # and that it will still return an errno for corruption in this mode.
1326 # Filesystems which don't support this will need to define their
1327 # own check routine.
1329 _check_generic_filesystem()
1333 # If type is set, we're mounted
1334 type=`_fs_type $device`
1337 if [ "$type" = "$FSTYP" ]
1340 mountpoint=`_umount_or_remount_ro $device`
1343 fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
1346 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seqres.full)"
1348 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$seqres.full
1349 echo "*** fsck.$FSTYP output ***" >>$seqres.full
1350 cat $tmp.fsck >>$seqres.full
1351 echo "*** end fsck.$FSTYP output" >>$seqres.full
1359 echo "*** mount output ***" >>$seqres.full
1360 _mount >>$seqres.full
1361 echo "*** end mount output" >>$seqres.full
1362 elif [ "$type" = "$FSTYP" ]
1365 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
1369 if [ $ok -eq 0 ]; then
1377 # run xfs_check and friends on a FS.
1379 _check_xfs_filesystem()
1383 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
1387 extra_mount_options=""
1389 if [ "$2" != "none" ]; then
1390 extra_log_options="-l$2"
1391 extra_mount_options="-ologdev=$2"
1394 if [ "$3" != "none" ]; then
1395 extra_rt_options="-r$3"
1396 extra_mount_options=$extra_mount_options" -ortdev=$3"
1398 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
1400 [ "$FSTYP" != xfs ] && return 0
1402 type=`_fs_type $device`
1405 if [ "$type" = "xfs" ]
1408 mountpoint=`_umount_or_remount_ro $device`
1411 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
1412 | tee $tmp.logprint | grep -q "<CLEAN>"
1413 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
1415 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seqres.full)"
1417 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$seqres.full
1418 echo "*** xfs_logprint -t output ***" >>$seqres.full
1419 cat $tmp.logprint >>$seqres.full
1420 echo "*** end xfs_logprint output" >>$seqres.full
1425 # xfs_check runs out of memory on large files, so even providing the test
1426 # option (-t) to avoid indexing the free space trees doesn't make it pass on
1427 # large filesystems. Avoid it.
1428 if [ "$LARGE_SCRATCH_DEV" != yes ]; then
1429 $XFS_CHECK_PROG $extra_log_options $device 2>&1 |\
1430 _fix_malloc >$tmp.fs_check
1432 if [ -s $tmp.fs_check ]
1434 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seqres.full)"
1436 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$seqres.full
1437 echo "*** xfs_check output ***" >>$seqres.full
1438 cat $tmp.fs_check >>$seqres.full
1439 echo "*** end xfs_check output" >>$seqres.full
1444 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
1447 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seqres.full)"
1449 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$seqres.full
1450 echo "*** xfs_repair -n output ***" >>$seqres.full
1451 cat $tmp.repair | _fix_malloc >>$seqres.full
1452 echo "*** end xfs_repair output" >>$seqres.full
1456 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
1460 echo "*** mount output ***" >>$seqres.full
1461 _mount >>$seqres.full
1462 echo "*** end mount output" >>$seqres.full
1463 elif [ "$type" = "xfs" ]
1465 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
1468 if [ $ok -eq 0 ]; then
1476 # Filter the knowen errors the UDF Verifier reports.
1477 _udf_test_known_error_filter()
1479 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."
1483 _check_udf_filesystem()
1485 [ "$DISABLE_UDF_TEST" == "1" ] && return
1487 if [ $# -ne 1 -a $# -ne 2 ]
1489 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
1493 if [ ! -x $here/src/udf_test ]
1495 echo "udf_test not installed, please download and build the Philips"
1496 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
1497 echo "Then copy the udf_test binary to $here/src/."
1498 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
1506 LAST_BLOCK=`expr \( $2 - 1 \)`
1507 OPT_ARG="-lastvalidblock $LAST_BLOCK"
1510 rm -f $seqres.checkfs
1511 sleep 1 # Due to a problem with time stamps in udf_test
1512 $here/src/udf_test $OPT_ARG $device | tee $seqres.checkfs | egrep "Error|Warning" | \
1513 _udf_test_known_error_filter | \
1514 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
1515 sed "s/^.*$/Warning UDF Verifier reported errors see $seqres.checkfs./g"
1519 _check_xfs_test_fs()
1523 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
1524 TEST_LOG="$TEST_LOGDEV"
1526 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1527 TEST_RT="$TEST_RTDEV"
1529 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1531 # check for ipath consistency
1532 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1533 # errors go to stderr
1534 xfs_check_ipaths $TEST_DIR >/dev/null
1535 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1539 _check_btrfs_filesystem()
1543 # If type is set, we're mounted
1544 type=`_fs_type $device`
1547 if [ "$type" = "$FSTYP" ]
1550 mountpoint=`_umount_or_remount_ro $device`
1553 btrfsck $device >$tmp.fsck 2>&1
1556 echo "_check_btrfs_filesystem: filesystem on $device is inconsistent (see $seqres.full)"
1558 echo "_check_btrfs_filesystem: filesystem on $device is inconsistent" >>$seqres.full
1559 echo "*** fsck.$FSTYP output ***" >>$seqres.full
1560 cat $tmp.fsck >>$seqres.full
1561 echo "*** end fsck.$FSTYP output" >>$seqres.full
1569 echo "*** mount output ***" >>$seqres.full
1570 _mount >>$seqres.full
1571 echo "*** end mount output" >>$seqres.full
1572 elif [ "$type" = "$FSTYP" ]
1575 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
1579 if [ $ok -eq 0 ]; then
1594 # no way to check consistency for nfs
1597 # do nothing for now
1600 _check_btrfs_filesystem $TEST_DEV
1603 _check_generic_filesystem $TEST_DEV
1614 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
1615 SCRATCH_LOG="$SCRATCH_LOGDEV"
1617 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
1618 SCRATCH_RT="$SCRATCH_RTDEV"
1620 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
1623 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
1626 # Don't know how to check an NFS filesystem, yet.
1629 _check_btrfs_filesystem $SCRATCH_DEV
1632 _check_generic_filesystem $SCRATCH_DEV
1637 _full_fstyp_details()
1639 [ -z "$FSTYP" ] && FSTYP=xfs
1640 if [ $FSTYP = xfs ]; then
1641 if [ -d /proc/fs/xfs ]; then
1642 if grep -q 'debug 0' /proc/fs/xfs/stat; then
1643 FSTYP="$FSTYP (non-debug)"
1644 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
1645 FSTYP="$FSTYP (debug)"
1648 if uname -a | grep -qi 'debug'; then
1649 FSTYP="$FSTYP (debug)"
1651 FSTYP="$FSTYP (non-debug)"
1658 _full_platform_details()
1664 echo "$os/$platform $host $kernel"
1667 _setup_udf_scratchdir()
1669 [ "$FSTYP" != "udf" ] \
1670 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1671 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1672 && _notrun "this test requires a valid \$SCRATCH_DEV"
1673 [ -z "$SCRATCH_MNT" ] \
1674 && _notrun "this test requires a valid \$SCRATCH_MNT"
1677 if _mount | grep -q $SCRATCH_DEV
1679 # if it's mounted, make sure its on $TEST_RW_DIR
1680 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1682 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1684 $UMOUNT_PROG $SCRATCH_DEV
1690 testdir=$SCRATCH_MNT
1693 _setup_nfs_scratchdir()
1695 [ "$FSTYP" != "nfs" ] \
1696 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1697 [ -z "$SCRATCH_DEV" ] \
1698 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1699 [ -z "$SCRATCH_MNT" ] \
1700 && _notrun "this test requires a valid \$SCRATCH_MNT"
1703 if _mount | grep -q $SCRATCH_DEV
1705 # if it's mounted, make sure its on $SCRATCH_MNT
1706 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1708 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1710 $UMOUNT_PROG $SCRATCH_DEV
1716 testdir=$SCRATCH_MNT
1720 # Warning for UDF and NFS:
1721 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
1722 # which actually uses the scratch dir for the test dir.
1724 # This was done because testdir was intended to be a persistent
1725 # XFS only partition. This should eventually change, and treat
1726 # at least local filesystems all the same.
1732 _setup_udf_scratchdir
1735 _setup_nfs_scratchdir
1747 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1748 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1751 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1752 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1755 # do nothing, testdir is $TEST_DIR
1763 if [ -z "$1" -o -z "$2" ]; then
1764 echo Error must pass src and dst.
1768 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1770 elif [ "`uname`" == "Linux" ]; then
1773 echo Error test $seq does not run on the operating system: `uname`
1784 #takes files, randomdata
1792 if [ $size -gt 0 ]; then
1793 if [ "$2" == "false" ]; then
1794 dd if=/dev/zero of=$file bs=1024 count=$size 2>&1 | _filter_dd
1796 dd if=/dev/urandom of=$file bs=1024 count=$size 2>&1 | _filter_dd
1803 # takes dirname, depth, randomdata
1806 dirname=$1; depth=$2; randomdata=$3
1807 mkdir $dirname || die "mkdir $dirname failed"
1810 _nfiles $files $randomdata # files for this dir and data type
1812 [ $depth -eq 0 ] && return
1813 let deep=$depth-1 # go 1 down
1815 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1818 while [ $d -lt $dirs ]
1820 _descend d$d $deep &
1826 # Populate a filesystem with inodes for performance experiments
1828 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size] [-x]
1833 dirs=5 # ndirs in each subdir till leaves
1834 size=0 # sizeof files in K
1835 files=100 # num files in _each_ subdir
1836 depth=2 # depth of tree from root to leaves
1838 root=root # path of initial root of directory tree
1839 randomdata=false # -x data type urandom or zero
1842 while getopts "d:f:n:r:s:v:x" c
1851 x) randomdata=true;;
1855 _descend $root $depth $randomdata
1860 [ $verbose = true ] && echo done
1863 # query whether the given file has the given inode flag set
1870 if which $XFS_IO_PROG >/dev/null; then
1871 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1878 # query the given files extsize allocator hint in bytes (if any)
1885 if which $XFS_IO_PROG >/dev/null; then
1886 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1887 awk '/^xattr.extsize =/ { print $3 }'`
1889 [ -z "$blocks" ] && blocks="0"
1893 # scratch_dev_pool should contain the disks pool for the btrfs raid
1894 _require_scratch_dev_pool()
1897 if [ -z "$SCRATCH_DEV_POOL" ]; then
1898 _notrun "this test requires a valid \$SCRATCH_DEV_POOL"
1901 # btrfs test case needs 2 or more scratch_dev_pool; other FS not sure
1905 if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]; then
1906 _notrun "btrfs and this test needs 2 or more disks in SCRATCH_DEV_POOL"
1910 _notrun "dev_pool is not supported by fstype \"$FSTYP\""
1914 for i in $SCRATCH_DEV_POOL; do
1915 if [ "`_is_block_dev $i`" = "" ]; then
1916 _notrun "this test requires valid block disk $i"
1918 if [ "`_is_block_dev $i`" = "`_is_block_dev $TEST_DEV`" ]; then
1919 _notrun "$i is part of TEST_DEV, this test requires unique disks"
1921 if _mount | grep -q $i; then
1922 if ! $UMOUNT_PROG $i; then
1923 echo "failed to unmount $i - aborting"
1927 # to help better debug when something fails, we remove
1928 # traces of previous btrfs FS on the dev.
1929 dd if=/dev/zero of=$i bs=4096 count=100 > /dev/null 2>&1
1933 # We will check if the device is virtual (eg: loop device) since it does not
1934 # have the delete entry-point. Otherwise SCSI and USB devices are fine.
1935 _require_deletable_scratch_dev_pool()
1939 for i in $SCRATCH_DEV_POOL; do
1940 x=`echo $i | cut -d"/" -f 3`
1941 ls -l /sys/class/block/${x} | grep -q "virtual"
1942 if [ $? == "0" ]; then
1943 _notrun "$i is a virtual device which is not deletable"
1948 # We check for btrfs and (optionally) features of the btrfs command
1952 _require_command $BTRFS_UTIL_PROG btrfs
1953 if [ -z "$1" ]; then
1956 $BTRFS_UTIL_PROG $cmd --help >/dev/null 2>&1
1957 [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support $cmd)"
1960 # Check that fio is present, and it is able to execute given jobfile
1965 _require_command $FIO_PROG
1966 if [ -z "$1" ]; then
1970 $FIO_PROG --warnings-fatal --showcmd $job >/dev/null 2>&1
1971 [ $? -eq 0 ] || _notrun "$FIO_PROG too old"
1974 # Does freeze work on this fs?
1977 xfs_freeze -f "$TEST_DIR" >/dev/null 2>&1
1979 xfs_freeze -u "$TEST_DIR" >/dev/null 2>&1
1980 [ $result -eq 0 ] || _notrun "$FSTYP does not support freezing"
1983 # arg 1 is dev to remove and is output of the below eg.
1984 # ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
1987 echo 1 > /sys/class/scsi_device/${1}/device/delete || _fail "Remove disk failed"
1990 # arg 1 is dev to add and is output of the below eg.
1991 # ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
1996 # arg 1 will be in h:t:d:l format now in the h and "t d l" format
1997 h=`echo ${1} | cut -d":" -f 1`
1998 tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
2000 echo ${tdl} > /sys/class/scsi_host/host${h}/scan || _fail "Add disk failed"
2005 if [ -z "$FSTRIM_PROG" ]; then
2006 _notrun "This test requires fstrim utility."
2010 _test_batched_discard()
2012 if [ $# -ne 1 ]; then
2013 echo "Usage: _test_batched_discard mnt_point" 1>&2
2017 $FSTRIM_PROG ${1} &>/dev/null
2022 if [ -z "$DUMPE2FS_PROG" ]; then
2023 _notrun "This test requires dumpe2fs utility."
2027 _create_loop_device()
2030 dev=`losetup -f --show $file` || _fail "Cannot assign $file to a loop device"
2034 _destroy_loop_device()
2037 losetup -d $dev || _fail "Cannot destroy loop device $dev"
2040 _scale_fsstress_args()
2043 while [ $# -gt 0 ]; do
2045 -n) args="$args $1 $(($2 * $TIME_FACTOR))"; shift ;;
2046 -p) args="$args $1 $(($2 * $LOAD_FACTOR))"; shift ;;
2047 *) args="$args $1" ;;
2056 echo "# $@" >> $seqres.full 2>&1
2057 "$@" >> $seqres.full 2>&1 || _fail "failed: '$@'"
2060 ################################################################################
2062 if [ "$iam" != new ]
2064 # make some further configuration checks here
2066 if [ "$TEST_DEV" = "" ]
2068 echo "common.rc: Error: \$TEST_DEV is not set"
2072 # if $TEST_DEV is not mounted, mount it now as XFS
2073 if [ -z "`_fs_type $TEST_DEV`" ]
2075 # $TEST_DEV is not mounted
2078 echo "common.rc: retrying test device mount with external set"
2079 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
2082 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
2088 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
2090 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
2096 # make sure this script returns success