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 2>&1 | grep noxfer >/dev/null
51 command dd status=noxfer $@
65 $BTRFS_UTIL_PROG sub list $mnt | grep $name | awk '{ print $2 }'
68 # Prints the md5 checksum of a given file
71 md5sum $1 | cut -d ' ' -f1
75 # ls -l w/ selinux sometimes puts a dot at the end:
76 # -rwxrw-r--. id1 id2 file1
77 # Also filter out lost+found directory on extN file system if present
81 ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /" | grep -v 'lost+found'
84 # we need common/config
85 if [ "$iam" != "check" ]
87 if ! . ./common/config
89 echo "$iam: failed to source common/config"
94 # check for correct setup
97 [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
98 [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
99 [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
100 [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
103 [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
106 [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
109 [ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found"
112 [ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found"
119 [ "$MKFS_REISER4_PROG" = "" ] && _fatal "mkfs.reiser4 not found"
123 # make sure we have a standard umask
128 $MOUNT_PROG `_mount_ops_filter $*`
136 if [ "$FSTYP" != "xfs" ]; then
142 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
151 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
152 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
153 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
154 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
162 if [ "$FSTYP" != "xfs" ]; then
176 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
177 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
178 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
179 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
186 #get mount point to handle dmapi mtpt option correctly
188 [ $last_index -gt 0 ] && shift $last_index
191 # irix is fussy about how it is fed its mount options
192 # - multiple -o's are not allowed
193 # - no spaces between comma delimitered options
194 # the sed script replaces all -o's (except the first) with a comma
195 # not required for linux, but won't hurt
197 echo $params | sed -e 's/[[:space:]]\+-o[[:space:]]*/UnIqUe/1; s/[[:space:]]\+-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
198 | sed -e 's/dmapi/dmi/' \
199 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
203 _scratch_mount_options()
205 _scratch_options mount
207 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
212 _mount -t $FSTYP `_scratch_mount_options $*`
217 $UMOUNT_PROG $SCRATCH_DEV
229 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
234 $UMOUNT_PROG $TEST_DEV
238 _scratch_mkfs_options()
240 _scratch_options mkfs
241 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
249 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
250 options="-l $SCRATCH_LOGDEV"
252 xfs_metadump $options $SCRATCH_DEV $dumpfile
255 _setup_large_xfs_fs()
260 [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
261 [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
262 [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
264 # calculate the size of the file we need to allocate.
265 # Default free space in the FS is 50GB, but you can specify more via
266 # SCRATCH_DEV_EMPTY_SPACE
267 file_size=$(($fs_size - 50*1024*1024*1024))
268 file_size=$(($file_size - $SCRATCH_DEV_EMPTY_SPACE))
270 # mount the filesystem, create the file, unmount it
271 _scratch_mount 2>&1 >$tmp_dir/mnt.err
273 if [ $status -ne 0 ]; then
275 cat $tmp_dir/mnt.err >&2
276 rm -f $tmp_dir/mnt.err
279 rm -f $tmp_dir/mnt.err
282 -c "truncate $file_size" \
283 -c "falloc -k 0 $file_size" \
285 $SCRATCH_MNT/.use_space 2>&1 > /dev/null
286 export NUM_SPACE_FILES=1
289 if [ $status -ne 0 ]; then
290 echo "large file prealloc failed"
291 cat $tmp_dir/mnt.err >&2
297 _scratch_mkfs_xfs_opts()
301 _scratch_options mkfs
303 $MKFS_XFS_PROG $SCRATCH_OPTIONS $mkfs_opts $SCRATCH_DEV
307 _scratch_mkfs_xfs_supported()
311 _scratch_options mkfs
313 $MKFS_XFS_PROG -N $MKFS_OPTIONS $SCRATCH_OPTIONS $mkfs_opts $SCRATCH_DEV
318 # extra mkfs options can be added by tests
319 local extra_mkfs_options=$*
323 # save mkfs output in case conflict means we need to run again.
324 # only the output for the mkfs that applies should be shown
325 _scratch_mkfs_xfs_opts $MKFS_OPTIONS $extra_mkfs_options \
326 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
330 # a mkfs failure may be caused by conflicts between
331 # $MKFS_OPTIONS and $extra_mkfs_options
332 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
334 echo -n "** mkfs failed with extra mkfs options "
335 echo "added to \"$MKFS_OPTIONS\" by test $seq **"
336 echo -n "** attempting to mkfs using only test $seq "
337 echo "options: $extra_mkfs_options **"
340 # running mkfs again. overwrite previous mkfs output files
341 _scratch_mkfs_xfs_opts $extra_mkfs_options \
342 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
346 if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
347 # manually parse the mkfs output to get the fs size in bytes
349 fs_size=`cat $tmp_dir.mkfsstd | perl -ne '
350 if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+)/) {
352 print STDOUT "$size\n";
354 _setup_large_xfs_fs $fs_size
358 # output stored mkfs output
359 cat $tmp_dir.mkfserr >&2
361 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
366 # xfs_check script is planned to be deprecated. But, we want to
367 # be able to invoke "xfs_check" behavior in xfstests in order to
368 # maintain the current verification levels.
373 USAGE="Usage: xfs_check [-fsvV] [-l logdev] [-i ino]... [-b bno]... special"
375 while getopts "b:fi:l:stvV" c
381 i) OPTS=$OPTS"-i "$OPTARG" ";;
382 b) OPTS=$OPTS"-b "$OPTARG" ";;
383 f) DBOPTS=$DBOPTS" -f";;
384 l) DBOPTS=$DBOPTS" -l "$OPTARG" ";;
385 V) $XFS_DB_PROG -p xfs_check -V
393 1) ${XFS_DB_PROG}${DBOPTS} -F -i -p xfs_check -c "check$OPTS" $1
403 _setup_large_ext4_fs()
408 [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
409 [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
410 [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
412 # Default free space in the FS is 50GB, but you can specify more via
413 # SCRATCH_DEV_EMPTY_SPACE
414 space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE))
416 # mount the filesystem and create 16TB - 4KB files until we consume
417 # all the necessary space.
418 _scratch_mount 2>&1 >$tmp_dir/mnt.err
420 if [ $status -ne 0 ]; then
422 cat $tmp_dir/mnt.err >&2
423 rm -f $tmp_dir/mnt.err
426 rm -f $tmp_dir/mnt.err
428 file_size=$((16*1024*1024*1024*1024 - 4096))
430 while [ $space_to_consume -gt $file_size ]; do
433 -c "truncate $file_size" \
434 -c "falloc -k 0 $file_size" \
435 $SCRATCH_MNT/.use_space.$nfiles 2>&1
437 if [ $status -ne 0 ]; then
441 space_to_consume=$(( $space_to_consume - $file_size ))
442 nfiles=$(($nfiles + 1))
445 # consume the remaining space.
446 if [ $space_to_consume -gt 0 ]; then
448 -c "truncate $space_to_consume" \
449 -c "falloc -k 0 $space_to_consume" \
450 $SCRATCH_MNT/.use_space.$nfiles 2>&1
453 export NUM_SPACE_FILES=$nfiles
456 if [ $status -ne 0 ]; then
457 echo "large file prealloc failed"
458 cat $tmp_dir/mnt.err >&2
466 # extra mkfs options can be added by tests
467 local extra_mkfs_options=$*
471 $MKFS_EXT4_PROG -F $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
472 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
475 # a mkfs failure may be caused by conflicts between
476 # $MKFS_OPTIONS and $extra_mkfs_options
477 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
479 echo -n "** mkfs failed with extra mkfs options "
480 echo "added to \"$MKFS_OPTIONS\" by test $seq **"
481 echo -n "** attempting to mkfs using only test $seq "
482 echo "options: $extra_mkfs_options **"
485 # running mkfs again. overwrite previous mkfs output files
486 $MKFS_EXT4_PROG -F $extra_mkfs_options $SCRATCH_DEV \
487 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
491 if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
492 # manually parse the mkfs output to get the fs size in bytes
493 fs_size=`cat $tmp_dir.mkfsstd | awk ' \
494 /^Block size/ { split($2, a, "="); bs = a[2] ; } \
495 / inodes, / { blks = $3 } \
496 /reserved for the super user/ { resv = $1 } \
497 END { fssize = bs * blks - resv; print fssize }'`
499 _setup_large_ext4_fs $fs_size
503 # output stored mkfs output
504 cat $tmp_dir.mkfserr >&2
506 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
518 # do nothing for cifs
521 $MKFS_UDF_PROG $MKFS_OPTIONS $* $TEST_DEV > /dev/null
524 $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $TEST_DEV > /dev/null
527 $MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* $TEST_DEV
530 yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $TEST_DEV
542 $MKFS_UDF_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
545 $MKFS_BTRFS_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
548 $MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* \
549 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
553 yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* \
554 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
558 if [ $? -ne 0 ]; then
559 # output stored mkfs output
560 cat $tmp_dir.mkfserr >&2
565 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
568 # remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS
569 _scratch_cleanup_files()
572 rm -rf $SCRATCH_MNT/*
583 # unable to re-create NFS, just remove all files in $SCRATCH_MNT to
584 # avoid EEXIST caused by the leftover files created in previous runs
585 _scratch_cleanup_files
588 # unable to re-create CIFS, just remove all files in $SCRATCH_MNT to
589 # avoid EEXIST caused by the leftover files created in previous runs
590 _scratch_cleanup_files
593 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
596 $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
599 $MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* $SCRATCH_DEV
602 _scratch_mkfs_ext4 $*
605 # do nothing for tmpfs
608 $MKFS_F2FS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
611 yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
620 # if dup profile is in mkfs options call _scratch_mkfs instead
621 # because dup profile only works with single device
622 if [[ "$*" =~ dup ]]; then
625 $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
629 echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
634 # Create fs of certain size on scratch device
635 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
636 _scratch_mkfs_sized()
643 def_blksz=`echo $MKFS_OPTIONS|sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
645 ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4)
646 def_blksz=`echo $MKFS_OPTIONS| sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
650 [ -n "$def_blksz" ] && blocksize=$def_blksz
651 [ -z "$blocksize" ] && blocksize=4096
655 if ! [[ $fssize =~ $re ]] ; then
656 _notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an integer."
658 if ! [[ $blocksize =~ $re ]] ; then
659 _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
662 blocks=`expr $fssize / $blocksize`
664 if [ "$HOSTOS" == "Linux" ]; then
665 devsize=`blockdev --getsize64 $SCRATCH_DEV`
666 [ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
671 # don't override MKFS_OPTIONS that set a block size.
672 echo $MKFS_OPTIONS |egrep -q "b?size="
673 if [ $? -eq 0 ]; then
674 _scratch_mkfs_xfs -d size=$fssize
676 _scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
679 ext2|ext3|ext4|ext4dev)
680 ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
683 $MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
686 $MKFS_BTRFS_PROG $MKFS_OPTIONS -b $fssize $SCRATCH_DEV
689 # mkfs.resier4 requires size in KB as input for creating filesystem
690 $MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
691 `expr $fssize / 1024`
694 _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
699 # Emulate an N-data-disk stripe w/ various stripe units
700 # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
706 [ -z "$blocksize" ] && blocksize=4096
708 let sunit_blocks=$sunit_bytes/$blocksize
709 let swidth_blocks=$sunit_blocks*$swidth_mult
713 MKFS_OPTIONS+=" -b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
716 MKFS_OPTIONS+=" -b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
719 _notrun "can't mkfs $FSTYP with geometry"
729 xfs_io -x -c "resblks $1" $SCRATCH_MNT
736 _scratch_xfs_db_options()
739 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
740 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
741 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
744 _scratch_xfs_logprint()
747 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
748 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
749 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
755 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
756 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
757 [ "$LARGE_SCRATCH_DEV" = yes ] && \
758 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
759 _xfs_check $SCRATCH_OPTIONS $* $SCRATCH_DEV
762 _scratch_xfs_repair()
765 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
766 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
767 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
768 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
769 [ "$LARGE_SCRATCH_DEV" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
770 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
777 echo "Usage: _get_pids_by_name process-name" 1>&2
781 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
782 # HH:MM:SS before the psargs field, use this as the search anchor.
784 # Matches with $1 (process-name) occur if the first psarg is $1
785 # or ends in /$1 ... the matching uses sed's regular expressions,
786 # so passing a regex into $1 will work.
794 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
795 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
798 # fix malloc libs output
802 # filter out the Electric Fence notice
805 if (defined $o && /^\s+Electric Fence/) {
811 print $o if (defined $o);
815 print $o if (defined $o);
819 # check if run as root
823 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
826 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
833 # _df_device : get an IRIX style df line for a given device
835 # - returns "" if not mounted
836 # - returns fs type in field two (ala IRIX)
837 # - joins line together if split by fancy df formatting
838 # - strips header etc
845 echo "Usage: _df_device device" 1>&2
849 # Note that we use "==" here so awk doesn't try to interpret an NFS over
850 # IPv6 server as a regular expression.
851 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
852 ($1==what) && (NF==1) {
866 # _df_dir : get an IRIX style df line for device where a directory resides
868 # - returns fs type in field two (ala IRIX)
869 # - joins line together if split by fancy df formatting
870 # - strips header etc
877 echo "Usage: _df_dir device" 1>&2
881 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
897 # return percentage used disk space for mounted device
903 echo "Usage: _used device" 1>&2
907 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
910 # return the FS type of a mounted device
916 echo "Usage: _fs_type device" 1>&2
921 # The Linux kernel shows NFSv4 filesystems in df output as
922 # filesystem type nfs4, although we mounted it as nfs earlier.
923 # Fix the filesystem type up here so that the callers don't
924 # have to bother with this quirk.
926 _df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'
929 # return the FS mount options of a mounted device
931 # should write a version which just parses the output of mount for IRIX
932 # compatibility, but since this isn't used at all, at the moment I'll leave
939 echo "Usage: _fs_options device" 1>&2
943 $AWK_PROG -v dev=$1 '
944 match($1,dev) { print $4 }
948 # returns device number if a file is a block device
954 echo "Usage: _is_block_dev dev" 1>&2
959 if [ -L "${_dev}" ]; then
960 _dev=`readlink -f ${_dev}`
963 if [ -b "${_dev}" ]; then
964 src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }'
968 # Do a command, log it to $seqres.full, optionally test return status
969 # and die if command fails. If called with one argument _do executes the
970 # command, logs it, and returns its exit status. With two arguments _do
971 # first prints the message passed in the first argument, and then "done"
972 # or "fail" depending on the return status of the command passed in the
973 # second argument. If the command fails and the variable _do_die_on_error
974 # is set to "always" or the two argument form is used and _do_die_on_error
975 # is set to "message_only" _do will print an error message to
976 # $seqres.out and exit.
980 if [ $# -eq 1 ]; then
982 elif [ $# -eq 2 ]; then
987 echo "Usage: _do [note] cmd" 1>&2
991 (eval "echo '---' \"$_cmd\"") >>$seqres.full
992 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
993 cat $tmp._out | _fix_malloc >>$seqres.full
994 if [ $# -eq 2 ]; then
995 if [ $ret -eq 0 ]; then
1002 && [ "$_do_die_on_error" = "always" \
1003 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
1005 [ $# -ne 2 ] && echo
1006 eval "echo \"$_cmd\" failed \(returned $ret\): see $seqres.full"
1013 # bail out, setting up .notrun file. Need to kill the filesystem check files
1014 # here, otherwise they are set incorrectly for the next test.
1018 echo "$*" > $seqres.notrun
1019 echo "$seq not run: $*"
1020 rm -f ${RESULT_DIR}/require_test
1021 rm -f ${RESULT_DIR}/require_scratch
1026 # just plain bail out
1030 echo "$*" | tee -a $seqres.full
1031 echo "(see $seqres.full for details)"
1036 # tests whether $FSTYP is one of the supported filesystems for a test
1042 if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
1048 _notrun "not suitable for this filesystem type: $FSTYP"
1052 # tests whether $FSTYP is one of the supported OSes for a test
1058 if [ "$h" = "$HOSTOS" ]
1064 _notrun "not suitable for this OS: $HOSTOS"
1067 # this test needs a scratch partition - check we're ok & unmount it
1068 # No post-test check of the device is required. e.g. the test intentionally
1069 # finishes the test with the filesystem in a corrupt state
1070 _require_scratch_nocheck()
1074 echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
1075 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
1076 _notrun "this test requires a valid \$SCRATCH_DEV"
1078 if [ ! -d "$SCRATCH_MNT" ]; then
1079 _notrun "this test requires a valid \$SCRATCH_MNT"
1083 echo $SCRATCH_DEV | grep -q "//" > /dev/null 2>&1
1084 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
1085 _notrun "this test requires a valid \$SCRATCH_DEV"
1087 if [ ! -d "$SCRATCH_MNT" ]; then
1088 _notrun "this test requires a valid \$SCRATCH_MNT"
1092 if [ -z "$SCRATCH_DEV" -o ! -d "$SCRATCH_MNT" ];
1094 _notrun "this test requires a valid \$SCRATCH_MNT and unique $SCRATCH_DEV"
1098 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
1100 _notrun "this test requires a valid \$SCRATCH_DEV"
1102 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
1104 _notrun "this test requires a valid \$SCRATCH_DEV"
1106 if [ ! -d "$SCRATCH_MNT" ]
1108 _notrun "this test requires a valid \$SCRATCH_MNT"
1114 if _mount | grep -q $SCRATCH_DEV
1116 # if it's mounted, make sure its on $SCRATCH_MNT
1117 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1119 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1122 # and then unmount it
1123 if ! $UMOUNT_PROG $SCRATCH_DEV
1125 echo "failed to unmount $SCRATCH_DEV"
1129 rm -f ${RESULT_DIR}/require_scratch
1132 # we need the scratch device and it should be checked post test.
1135 _require_scratch_nocheck
1136 touch ${RESULT_DIR}/require_scratch
1140 # this test needs a test partition - check we're ok & mount it
1146 echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
1147 if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
1148 _notrun "this test requires a valid \$TEST_DIR"
1150 if [ ! -d "$TEST_DIR" ]; then
1151 _notrun "this test requires a valid \$TEST_DIR"
1155 echo $TEST_DEV | grep -q "//" > /dev/null 2>&1
1156 if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
1157 _notrun "this test requires a valid \$TEST_DEV"
1159 if [ ! -d "$TEST_DIR" ]; then
1160 _notrun "this test requires a valid \$TEST_DIR"
1164 if [ -z "$TEST_DEV" -o ! -d "$TEST_DIR" ];
1166 _notrun "this test requires a valid \$TEST_DIR and unique $TEST_DEV"
1170 if [ -z "$TEST_DEV" -o "`_is_block_dev $TEST_DEV`" = "" ]
1172 _notrun "this test requires a valid \$TEST_DEV"
1174 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
1176 _notrun "this test requires a valid \$TEST_DEV"
1178 if [ ! -d "$TEST_DIR" ]
1180 _notrun "this test requires a valid \$TEST_DIR"
1186 # Note that we use -F here so grep doesn't try to interpret an NFS over
1187 # IPv6 server as a regular expression.
1188 if _mount | grep -F -q $TEST_DEV
1190 # if it's mounted, make sure its on $TEST_DIR
1191 if ! _mount | grep -F $TEST_DEV | grep -q $TEST_DIR
1193 echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting"
1197 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
1198 if [ $? -ne 1 ]; then
1203 touch ${RESULT_DIR}/require_test
1206 # this test needs a logdev
1210 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
1211 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
1212 [ "$USE_EXTERNAL" != yes ] && \
1213 _notrun "This test requires USE_EXTERNAL to be enabled"
1215 # ensure its not mounted
1216 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
1219 # this test requires loopback device support
1223 if [ "$HOSTOS" != "Linux" ]
1225 _notrun "This test requires linux for loopback device support"
1228 modprobe loop >/dev/null 2>&1
1229 if grep loop /proc/devices >/dev/null 2>&1
1233 _notrun "This test requires loopback device support"
1237 # this test requires ext2 filesystem support
1241 if [ "$HOSTOS" != "Linux" ]
1243 _notrun "This test requires linux for ext2 filesystem support"
1246 modprobe ext2 >/dev/null 2>&1
1247 if grep ext2 /proc/filesystems >/dev/null 2>&1
1251 _notrun "This test requires ext2 filesystem support"
1255 # this test requires that (large) loopback device files are not in use
1257 _require_no_large_scratch_dev()
1259 [ "$LARGE_SCRATCH_DEV" = yes ] && \
1260 _notrun "Large filesystem testing in progress, skipped this test"
1263 # this test requires that a realtime subvolume is in use, and
1264 # that the kernel supports realtime as well.
1268 [ "$USE_EXTERNAL" = yes ] || \
1269 _notrun "External volumes not in use, skipped this test"
1270 [ "$SCRATCH_RTDEV" = "" ] && \
1271 _notrun "Realtime device required, skipped this test"
1274 # this test requires that a specified command (executable) exists
1275 # $1 - command, $2 - name for error message
1279 [ -n "$1" ] && _cmd="$1" || _cmd="$2"
1280 [ -n "$1" -a -x "$1" ] || _notrun "$_cmd utility required, skipped this test"
1283 # this test requires the device to be valid block device
1285 _require_block_device()
1287 if [ -z "$1" ]; then
1288 echo "Usage: _require_block_device <dev>" 1>&2
1291 if [ "`_is_block_dev "$1"`" == "" ]; then
1292 _notrun "require $1 to be valid block disk"
1296 # this test requires the device mapper flakey target
1298 _require_dm_flakey()
1300 # require SCRATCH_DEV to be a valid block device
1301 _require_block_device $SCRATCH_DEV
1302 _require_command "$DMSETUP_PROG" dmsetup
1304 modprobe dm-flakey >/dev/null 2>&1
1305 $DMSETUP_PROG targets | grep flakey >/dev/null 2>&1
1310 _notrun "This test requires dm flakey support"
1314 # this test requires the projid32bit feature to be available in mkfs.xfs.
1316 _require_projid32bit()
1318 _scratch_mkfs_xfs_supported -i projid32bit=1 >/dev/null 2>&1 \
1319 || _notrun "mkfs.xfs doesn't have projid32bit feature"
1322 _require_projid16bit()
1324 _scratch_mkfs_xfs_supported -i projid32bit=0 >/dev/null 2>&1 \
1325 || _notrun "16 bit project IDs not supported on $SCRATCH_DEV"
1328 # this test requires the crc feature to be available in mkfs.xfs
1330 _require_xfs_mkfs_crc()
1332 _scratch_mkfs_xfs_supported -m crc=1 >/dev/null 2>&1 \
1333 || _notrun "mkfs.xfs doesn't have crc feature"
1336 # this test requires the xfs kernel support crc feature
1340 _scratch_mkfs_xfs -m crc=1 >/dev/null 2>&1
1341 _scratch_mount >/dev/null 2>&1 \
1342 || _notrun "Kernel doesn't support crc feature"
1346 # this test requires the bigalloc feature to be available in mkfs.ext4
1348 _require_ext4_mkfs_bigalloc()
1350 $MKFS_EXT4_PROG -F -O bigalloc -n $SCRATCH_DEV 512m >/dev/null 2>&1 \
1351 || _notrun "mkfs.ext4 doesn't have bigalloc feature"
1354 # this test requires the ext4 kernel support bigalloc feature
1356 _require_ext4_bigalloc()
1358 $MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 512m >/dev/null 2>&1
1359 _scratch_mount >/dev/null 2>&1 \
1360 || _notrun "Ext4 kernel doesn't support bigalloc feature"
1364 # this test requires the finobt feature to be available in mkfs.xfs
1366 _require_xfs_mkfs_finobt()
1368 _scratch_mkfs_xfs_supported -m crc=1,finobt=1 >/dev/null 2>&1 \
1369 || _notrun "mkfs.xfs doesn't have finobt feature"
1372 # this test requires the xfs kernel support finobt feature
1374 _require_xfs_finobt()
1376 _scratch_mkfs_xfs -m crc=1,finobt=1 >/dev/null 2>&1
1377 _scratch_mount >/dev/null 2>&1 \
1378 || _notrun "Kernel doesn't support finobt feature"
1382 # this test requires xfs sysfs attribute support
1384 _require_xfs_sysfs()
1387 sysfsdir=/sys/fs/xfs
1389 if [ ! -e $sysfsdir ]; then
1390 _notrun "no kernel support for XFS sysfs attributes"
1393 if [ ! -z $1 ] && [ ! -e $sysfsdir/$attr ]; then
1394 _notrun "sysfs attribute '$attr' is not supported"
1398 # this test requires that external log/realtime devices are not in use
1400 _require_nonexternal()
1402 [ "$USE_EXTERNAL" = yes ] && \
1403 _notrun "External device testing in progress, skipped this test"
1406 # this test requires that a (specified) aio-dio executable exists
1407 # $1 - command (optional)
1413 AIO_TEST=src/aio-dio-regress/aiodio_sparse2
1414 [ -x $AIO_TEST ] || _notrun "aio-dio utilities required"
1416 AIO_TEST=src/aio-dio-regress/$1
1417 [ -x $AIO_TEST ] || _notrun "$AIO_TEST not built"
1422 # run an aio-dio program
1428 echo "usage: _run_aiodio command_name" 2>&1
1434 local testtemp=$TEST_DIR/aio-testfile
1436 $AIO_TEST $testtemp 2>&1
1443 # indicate whether YP/NIS is active or not
1448 dn=$(domainname 2>/dev/null)
1449 test -n "${dn}" -a "${dn}" != "(none)"
1453 # cat the password file
1457 [ $(_yp_active) -eq 0 ] && ypcat passwd
1461 # cat the group file
1465 [ $(_yp_active) -eq 0 ] && ypcat group
1469 # check for the fsgqa user on the machine
1474 _cat_passwd | grep -q $qa_user
1475 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
1476 echo /bin/true | su $qa_user
1477 [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
1480 # check for the fsgqa group on the machine
1485 _cat_group | grep -q $qa_group
1486 [ "$?" == "0" ] || _notrun "$qa_group user not defined."
1492 s,.*Permission\sdenied.*,Permission denied,;
1493 s,.*no\saccess\sto\stty.*,,;
1494 s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
1501 if [ "$HOSTOS" == "IRIX" ]
1503 echo $1 | /bin/bash "su $qa_user 2>&1" | _filter_user_do
1505 echo $1 | su $qa_user 2>&1 | _filter_user_do
1509 _require_xfs_io_command()
1513 echo "Usage: _require_xfs_io_command command" 1>&2
1518 testfile=$TEST_DIR/$$.xfs_io
1521 testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
1523 "fpunch" | "fcollapse" | "zero" | "fzero" | "finsert" )
1524 testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
1525 -c "$command 4k 8k" $testfile 2>&1`
1528 testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
1529 -c "fiemap -v" $testfile 2>&1`
1532 testio=`$XFS_IO_PROG -T -F -c "flink $testfile" \
1534 echo $testio | egrep -q "invalid option|Is a directory" && \
1535 _notrun "xfs_io $command support is missing"
1538 testio=`$XFS_IO_PROG -c "$command help" 2>&1`
1541 rm -f $testfile 2>&1 > /dev/null
1542 echo $testio | grep -q "not found" && \
1543 _notrun "xfs_io $command support is missing"
1544 echo $testio | grep -q "Operation not supported" && \
1545 _notrun "xfs_io $command failed (old kernel/wrong fs?)"
1548 # check that kernel and filesystem support direct I/O
1551 testfile=$TEST_DIR/$$.direct
1552 $XFS_IO_PROG -F -f -d -c "pwrite 0 20k" $testfile > /dev/null 2>&1
1553 if [ $? -ne 0 ]; then
1554 _notrun "O_DIRECT is not supported"
1556 rm -f $testfile 2>&1 > /dev/null
1559 # Check that a fs has enough free space (in 1024b blocks)
1564 BLOCKS=$2 # in units of 1024
1565 let GB=$BLOCKS/1024/1024
1567 FREE_BLOCKS=`df -klP $MNT | grep -v Filesystem | awk '{print $4}'`
1568 [ $FREE_BLOCKS -lt $BLOCKS ] && \
1569 _notrun "This test requires at least ${GB}GB free on $MNT to run"
1573 # Check if the filesystem supports sparse files.
1575 # Unfortunately there is no better way to do this than a manual black list.
1577 _require_sparse_files()
1581 _notrun "Sparse files not supported by this filesystem type: $FSTYP"
1590 #boot_params always present in debugfs
1591 [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
1594 _require_fail_make_request()
1596 [ -f "$DEBUGFS_MNT/fail_make_request/probability" ] \
1597 || _notrun "$DEBUGFS_MNT/fail_make_request \
1598 not found. Seems that CONFIG_FAIL_MAKE_REQUEST kernel config option not enabled"
1602 # Check if the file system supports seek_data/hole
1604 _require_seek_data_hole()
1606 testfile=$TEST_DIR/$$.seek
1607 testseek=`$here/src/seek_sanity_test -t $testfile 2>&1`
1608 rm -f $testfile &>/dev/null
1609 echo $testseek | grep -q "Kernel does not support" && \
1610 _notrun "File system does not support llseek(2) SEEK_DATA/HOLE"
1613 # check that a FS on a device is mounted
1614 # if so, return mount point
1620 echo "Usage: _is_mounted device" 1>&2
1626 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
1627 pattern { print $3 ; exit 0 }
1631 echo "_is_mounted: $device is not a mounted $FSTYP FS"
1636 # remount a FS to a new mode (ro or rw)
1642 echo "Usage: _remount device ro/rw" 1>&2
1648 if ! mount -o remount,$mode $device
1650 echo "_remount: failed to remount filesystem on $device as $mode"
1655 # Run the appropriate repair/check on a filesystem
1657 # if the filesystem is mounted, it's either remounted ro before being
1658 # checked or it's unmounted and then remounted
1661 # If set, we remount ro instead of unmounting for fsck
1664 _umount_or_remount_ro()
1668 echo "Usage: _umount_or_remount_ro <device>" 1>&2
1673 mountpoint=`_is_mounted $device`
1675 if [ $USE_REMOUNT -eq 0 ]; then
1676 $UMOUNT_PROG $device
1683 _mount_or_remount_rw()
1687 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
1694 if [ $USE_REMOUNT -eq 0 ]
1696 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
1698 echo "!!! failed to remount $device on $mountpoint"
1708 # Check a generic filesystem in no-op mode; this assumes that the
1709 # underlying fsck program accepts "-n" for a no-op (check-only) run,
1710 # and that it will still return an errno for corruption in this mode.
1712 # Filesystems which don't support this will need to define their
1713 # own check routine.
1715 _check_generic_filesystem()
1719 # If type is set, we're mounted
1720 type=`_fs_type $device`
1723 if [ "$type" = "$FSTYP" ]
1726 mountpoint=`_umount_or_remount_ro $device`
1729 fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
1732 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seqres.full)"
1734 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$seqres.full
1735 echo "*** fsck.$FSTYP output ***" >>$seqres.full
1736 cat $tmp.fsck >>$seqres.full
1737 echo "*** end fsck.$FSTYP output" >>$seqres.full
1745 echo "*** mount output ***" >>$seqres.full
1746 _mount >>$seqres.full
1747 echo "*** end mount output" >>$seqres.full
1748 elif [ "$type" = "$FSTYP" ]
1751 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
1755 if [ $ok -eq 0 ]; then
1757 if [ "$iam" != "check" ]; then
1766 # run xfs_check and friends on a FS.
1768 _check_xfs_filesystem()
1772 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
1776 extra_mount_options=""
1778 if [ "$2" != "none" ]; then
1779 extra_log_options="-l$2"
1780 extra_mount_options="-ologdev=$2"
1783 if [ "$3" != "none" ]; then
1784 extra_rt_options="-r$3"
1785 extra_mount_options=$extra_mount_options" -ortdev=$3"
1787 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
1789 [ "$FSTYP" != xfs ] && return 0
1791 type=`_fs_type $device`
1794 if [ "$type" = "xfs" ]
1797 mountpoint=`_umount_or_remount_ro $device`
1800 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
1801 | tee $tmp.logprint | grep -q "<CLEAN>"
1802 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
1804 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seqres.full)"
1806 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$seqres.full
1807 echo "*** xfs_logprint -t output ***" >>$seqres.full
1808 cat $tmp.logprint >>$seqres.full
1809 echo "*** end xfs_logprint output" >>$seqres.full
1814 # xfs_check runs out of memory on large files, so even providing the test
1815 # option (-t) to avoid indexing the free space trees doesn't make it pass on
1816 # large filesystems. Avoid it.
1817 if [ "$LARGE_SCRATCH_DEV" != yes ]; then
1818 _xfs_check $extra_log_options $device 2>&1 |\
1819 _fix_malloc >$tmp.fs_check
1821 if [ -s $tmp.fs_check ]
1823 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seqres.full)"
1825 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$seqres.full
1826 echo "*** xfs_check output ***" >>$seqres.full
1827 cat $tmp.fs_check >>$seqres.full
1828 echo "*** end xfs_check output" >>$seqres.full
1833 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
1836 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seqres.full)"
1838 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$seqres.full
1839 echo "*** xfs_repair -n output ***" >>$seqres.full
1840 cat $tmp.repair | _fix_malloc >>$seqres.full
1841 echo "*** end xfs_repair output" >>$seqres.full
1845 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
1849 echo "*** mount output ***" >>$seqres.full
1850 _mount >>$seqres.full
1851 echo "*** end mount output" >>$seqres.full
1852 elif [ "$type" = "xfs" ]
1854 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
1857 if [ $ok -eq 0 ]; then
1859 if [ "$iam" != "check" ]; then
1868 # Filter the knowen errors the UDF Verifier reports.
1869 _udf_test_known_error_filter()
1871 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."
1875 _check_udf_filesystem()
1877 [ "$DISABLE_UDF_TEST" == "1" ] && return
1879 if [ $# -ne 1 -a $# -ne 2 ]
1881 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
1885 if [ ! -x $here/src/udf_test ]
1887 echo "udf_test not installed, please download and build the Philips"
1888 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
1889 echo "Then copy the udf_test binary to $here/src/."
1890 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
1898 LAST_BLOCK=`expr \( $2 - 1 \)`
1899 OPT_ARG="-lastvalidblock $LAST_BLOCK"
1902 rm -f $seqres.checkfs
1903 sleep 1 # Due to a problem with time stamps in udf_test
1904 $here/src/udf_test $OPT_ARG $device | tee $seqres.checkfs | egrep "Error|Warning" | \
1905 _udf_test_known_error_filter | \
1906 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" && \
1907 echo "Warning UDF Verifier reported errors see $seqres.checkfs." && return 1
1911 _check_xfs_test_fs()
1915 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
1916 TEST_LOG="$TEST_LOGDEV"
1918 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1919 TEST_RT="$TEST_RTDEV"
1921 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1923 # check for ipath consistency
1924 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1925 # errors go to stderr
1926 xfs_check_ipaths $TEST_DIR >/dev/null
1927 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1931 _check_btrfs_filesystem()
1935 # If type is set, we're mounted
1936 type=`_fs_type $device`
1939 if [ "$type" = "$FSTYP" ]
1942 mountpoint=`_umount_or_remount_ro $device`
1945 btrfsck $device >$tmp.fsck 2>&1
1948 echo "_check_btrfs_filesystem: filesystem on $device is inconsistent (see $seqres.full)"
1950 echo "_check_btrfs_filesystem: filesystem on $device is inconsistent" >>$seqres.full
1951 echo "*** fsck.$FSTYP output ***" >>$seqres.full
1952 cat $tmp.fsck >>$seqres.full
1953 echo "*** end fsck.$FSTYP output" >>$seqres.full
1961 echo "*** mount output ***" >>$seqres.full
1962 _mount >>$seqres.full
1963 echo "*** end mount output" >>$seqres.full
1964 elif [ "$type" = "$FSTYP" ]
1967 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
1971 if [ $ok -eq 0 ]; then
1973 if [ "$iam" != "check" ]; then
1989 # no way to check consistency for nfs
1992 # no way to check consistency for cifs
1995 # do nothing for now
1998 _check_btrfs_filesystem $TEST_DEV
2001 # no way to check consistency for tmpfs
2004 _check_generic_filesystem $TEST_DEV
2012 [ $# -eq 1 ] && device=$1
2018 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
2019 SCRATCH_LOG="$SCRATCH_LOGDEV"
2021 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
2022 SCRATCH_RT="$SCRATCH_RTDEV"
2024 _check_xfs_filesystem $device $SCRATCH_LOG $SCRATCH_RT
2027 _check_udf_filesystem $device $udf_fsize
2030 # Don't know how to check an NFS filesystem, yet.
2033 # Don't know how to check a CIFS filesystem, yet.
2036 _check_btrfs_filesystem $device
2039 # no way to check consistency for tmpfs
2042 _check_generic_filesystem $device
2047 _full_fstyp_details()
2049 [ -z "$FSTYP" ] && FSTYP=xfs
2050 if [ $FSTYP = xfs ]; then
2051 if [ -d /proc/fs/xfs ]; then
2052 if grep -q 'debug 0' /proc/fs/xfs/stat; then
2053 FSTYP="$FSTYP (non-debug)"
2054 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
2055 FSTYP="$FSTYP (debug)"
2058 if uname -a | grep -qi 'debug'; then
2059 FSTYP="$FSTYP (debug)"
2061 FSTYP="$FSTYP (non-debug)"
2068 _full_platform_details()
2074 echo "$os/$platform $host $kernel"
2079 if [ -z "$1" -o -z "$2" ]; then
2080 echo Error must pass src and dst.
2084 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
2086 elif [ "`uname`" == "Linux" ]; then
2089 echo Error test $seq does not run on the operating system: `uname`
2100 #takes files, randomdata
2108 if [ $size -gt 0 ]; then
2109 if [ "$2" == "false" ]; then
2110 dd if=/dev/zero of=$file bs=1024 count=$size 2>&1 | _filter_dd
2112 dd if=/dev/urandom of=$file bs=1024 count=$size 2>&1 | _filter_dd
2119 # takes dirname, depth, randomdata
2122 dirname=$1; depth=$2; randomdata=$3
2123 mkdir $dirname || die "mkdir $dirname failed"
2126 _nfiles $files $randomdata # files for this dir and data type
2128 [ $depth -eq 0 ] && return
2129 let deep=$depth-1 # go 1 down
2131 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
2134 while [ $d -lt $dirs ]
2136 _descend d$d $deep &
2142 # Populate a filesystem with inodes for performance experiments
2144 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size] [-x]
2149 dirs=5 # ndirs in each subdir till leaves
2150 size=0 # sizeof files in K
2151 files=100 # num files in _each_ subdir
2152 depth=2 # depth of tree from root to leaves
2154 root=root # path of initial root of directory tree
2155 randomdata=false # -x data type urandom or zero
2158 while getopts "d:f:n:r:s:v:x" c
2167 x) randomdata=true;;
2171 _descend $root $depth $randomdata
2176 [ $verbose = true ] && echo done
2179 # query whether the given file has the given inode flag set
2186 if which $XFS_IO_PROG >/dev/null; then
2187 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
2194 # query the given files extsize allocator hint in bytes (if any)
2201 if which $XFS_IO_PROG >/dev/null; then
2202 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
2203 awk '/^xattr.extsize =/ { print $3 }'`
2205 [ -z "$blocks" ] && blocks="0"
2209 # scratch_dev_pool should contain the disks pool for the btrfs raid
2210 _require_scratch_dev_pool()
2215 if [ -z "$SCRATCH_DEV_POOL" ]; then
2216 _notrun "this test requires a valid \$SCRATCH_DEV_POOL"
2219 if [ -z "$1" ]; then
2225 # btrfs test case needs ndevs or more scratch_dev_pool; other FS not sure
2229 if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt $ndevs ]; then
2230 _notrun "btrfs and this test needs $ndevs or more disks in SCRATCH_DEV_POOL"
2234 _notrun "dev_pool is not supported by fstype \"$FSTYP\""
2238 for i in $SCRATCH_DEV_POOL; do
2239 if [ "`_is_block_dev $i`" = "" ]; then
2240 _notrun "this test requires valid block disk $i"
2242 if [ "`_is_block_dev $i`" = "`_is_block_dev $TEST_DEV`" ]; then
2243 _notrun "$i is part of TEST_DEV, this test requires unique disks"
2245 if _mount | grep -q $i; then
2246 if ! $UMOUNT_PROG $i; then
2247 echo "failed to unmount $i - aborting"
2251 # to help better debug when something fails, we remove
2252 # traces of previous btrfs FS on the dev.
2253 dd if=/dev/zero of=$i bs=4096 count=100 > /dev/null 2>&1
2257 # ensure devices in SCRATCH_DEV_POOL are of the same size
2258 # must be called after _require_scratch_dev_pool
2259 _require_scratch_dev_pool_equal_size()
2265 # SCRATCH_DEV has been set to the first device in SCRATCH_DEV_POOL
2266 _size=`_get_device_size $SCRATCH_DEV`
2267 for _dev in $SCRATCH_DEV_POOL; do
2268 _newsize=`_get_device_size $_dev`
2269 if [ $_size -ne $_newsize ]; then
2270 _notrun "This test requires devices in SCRATCH_DEV_POOL have the same size"
2275 # We will check if the device is deletable
2276 _require_deletable_scratch_dev_pool()
2280 for i in $SCRATCH_DEV_POOL; do
2281 x=`echo $i | cut -d"/" -f 3`
2282 if [ ! -f /sys/class/block/${x}/device/delete ]; then
2283 _notrun "$i is a device which is not deletable"
2288 # We check for btrfs and (optionally) features of the btrfs command
2292 _require_command "$BTRFS_UTIL_PROG" btrfs
2293 if [ -z "$1" ]; then
2296 $BTRFS_UTIL_PROG $cmd --help >/dev/null 2>&1
2297 [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support $cmd)"
2300 # Check that fio is present, and it is able to execute given jobfile
2305 _require_command "$FIO_PROG" fio
2306 if [ -z "$1" ]; then
2310 $FIO_PROG --warnings-fatal --showcmd $job >> $seqres.full 2>&1
2311 [ $? -eq 0 ] || _notrun "$FIO_PROG too old, see $seqres.full"
2314 # Does freeze work on this fs?
2317 xfs_freeze -f "$TEST_DIR" >/dev/null 2>&1
2319 xfs_freeze -u "$TEST_DIR" >/dev/null 2>&1
2320 [ $result -eq 0 ] || _notrun "$FSTYP does not support freezing"
2323 # Does shutdown work on this fs?
2324 _require_scratch_shutdown()
2326 [ -x src/godown ] || _notrun "src/godown executable not found"
2328 _scratch_mkfs > /dev/null 2>&1
2330 src/godown -f $SCRATCH_MNT 2>&1 \
2331 || _notrun "$FSTYP does not support shutdown"
2335 # Does norecovery support by this fs?
2336 _require_norecovery()
2338 _scratch_mount -o ro,norecovery || \
2339 _notrun "$FSTYP does not support norecovery"
2343 # Does this filesystem support metadata journaling?
2344 # We exclude ones here that don't; otherwise we assume that it does, so the
2345 # test will run, fail, and motivate someone to update this test for a new
2348 # It's possible that TEST_DEV and SCRATCH_DEV have different features (it'd be
2349 # odd, but possible) so check $TEST_DEV by default, but we can optionall pass
2351 _require_metadata_journaling()
2361 _notrun "$FSTYP does not support metadata journaling"
2364 # ext4 could be mkfs'd without a journal...
2366 $DUMPE2FS_PROG -h $DEV 2>&1 | grep -q has_journal || \
2367 _notrun "$FSTYP on $DEV not configured with metadata journaling"
2370 # by default we pass; if you need to, add your fs above!
2375 # Does fiemap support?
2378 _require_xfs_io_command "fiemap"
2383 res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
2384 echo $res | grep -v hole | wc -l | $AWK_PROG '{print $1}'
2389 res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
2390 echo $res | grep hole | wc -l | $AWK_PROG '{print $1}'
2393 # arg 1 is dev to remove and is output of the below eg.
2394 # ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
2400 echo 1 > /sys/class/scsi_device/${lun}/device/delete || _fail "Remove disk failed"
2402 stat $disk > /dev/null 2>&1
2403 while [ $? -eq 0 ]; do
2405 stat $disk > /dev/null 2>&1
2409 # arg 1 is dev to add and is output of the below eg.
2410 # ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
2415 # arg 1 will be in h:t:d:l format now in the h and "t d l" format
2416 h=`echo ${1} | cut -d":" -f 1`
2417 tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
2419 echo ${tdl} > /sys/class/scsi_host/host${h}/scan || _fail "Add disk failed"
2421 # ensure the device comes online
2423 for i in `seq 1 10`; do
2424 if [ -d /sys/class/scsi_device/${1}/device/block ]; then
2425 dev=`ls /sys/class/scsi_device/${1}/device/block`
2426 for j in `seq 1 10`;
2428 stat /dev/$dev > /dev/null 2>&1
2429 if [ $? -eq 0 ]; then
2440 if [ $dev_back_oneline -eq 0 ]; then
2441 echo "/dev/$dev online failed" >> $seqres.full
2443 echo "/dev/$dev is back online" >> $seqres.full
2449 if [ -z "$FSTRIM_PROG" ]; then
2450 _notrun "This test requires fstrim utility."
2454 _require_batched_discard()
2456 if [ $# -ne 1 ]; then
2457 echo "Usage: _require_batched_discard mnt_point" 1>&2
2461 $FSTRIM_PROG $1 > /dev/null 2>&1 || _notrun "FITRIM not supported on $1"
2466 if [ -z "$DUMPE2FS_PROG" ]; then
2467 _notrun "This test requires dumpe2fs utility."
2473 if [ ! -e /proc/self/uid_map ]; then
2474 _notrun "This test requires procfs uid_map support."
2476 if [ ! -e /proc/self/gid_map ]; then
2477 _notrun "This test requires procfs gid_map support."
2481 _require_cp_reflink()
2483 cp --help | grep -q reflink || \
2484 _notrun "This test requires a cp with --reflink support."
2489 FSSUM_PROG=$here/src/fssum
2490 [ -x $FSSUM_PROG ] || _notrun "fssum not built"
2495 CLONER_PROG=$here/src/cloner
2496 [ -x $CLONER_PROG ] || \
2497 _notrun "cloner binary not present at $CLONER_PROG"
2500 # Given 2 files, verify that they have the same mapping but different
2501 # inodes - i.e. an undisturbed reflink
2502 # Silent if so, make noise if not
2505 # not a hard link or symlink?
2506 cmp -s <(stat -c '%i' $1) <(stat -c '%i' $2) \
2507 && echo "$1 and $2 are not reflinks: same inode number"
2510 diff -u <($XFS_IO_PROG -c "fiemap" $1 | grep -v $1) \
2511 <($XFS_IO_PROG -c "fiemap" $2 | grep -v $2) \
2512 || echo "$1 and $2 are not reflinks: different extents"
2517 if [ "$FSTYP" == "nfs" ]; then
2518 _notrun "atime related mount options have no effect on NFS"
2524 _scratch_mkfs > /dev/null 2>&1
2525 _scratch_mount -o relatime || \
2526 _notrun "relatime not supported by the current kernel"
2532 [ -x src/nsexec ] || _notrun "src/nsexec executable not found"
2533 src/nsexec -U true 2>/dev/null || _notrun "userns not supported by this kernel"
2536 _create_loop_device()
2539 dev=`losetup -f --show $file` || _fail "Cannot assign $file to a loop device"
2543 _destroy_loop_device()
2546 losetup -d $dev || _fail "Cannot destroy loop device $dev"
2549 _scale_fsstress_args()
2552 while [ $# -gt 0 ]; do
2554 -n) args="$args $1 $(($2 * $TIME_FACTOR))"; shift ;;
2555 -p) args="$args $1 $(($2 * $LOAD_FACTOR))"; shift ;;
2556 *) args="$args $1" ;;
2564 # Return the logical block size if running on a block device,
2565 # else substitute the page size.
2567 _min_dio_alignment()
2571 if [ -b "$dev" ]; then
2572 blockdev --getss $dev
2574 $here/src/feature -s
2580 echo "# $@" >> $seqres.full 2>&1
2581 "$@" >> $seqres.full 2>&1 || _fail "failed: '$@'"
2584 _run_btrfs_util_prog()
2586 run_check $BTRFS_UTIL_PROG $*
2589 _require_btrfs_send_stream_version()
2591 $BTRFS_UTIL_PROG send 2>&1 | \
2592 grep '^[ \t]*\-\-stream\-version <version>' > /dev/null 2>&1
2593 if [ $? -ne 0 ]; then
2594 _notrun "Missing btrfs-progs send --stream-version command line option, skipped this test"
2597 # test if btrfs kernel supports send stream version 2
2598 if [ ! -f /sys/fs/btrfs/send/stream_version ]; then
2599 _notrun "Missing btrfs kernel patch for send stream version 2, skipped this test"
2603 _require_btrfs_mkfs_feature()
2606 echo "Missing feature name argument for _require_btrfs_mkfs_feature"
2610 $MKFS_BTRFS_PROG -O list-all 2>&1 | \
2611 grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
2613 _notrun "Feature $feat not supported in the available version of mkfs.btrfs"
2616 _require_btrfs_fs_feature()
2619 echo "Missing feature name argument for _require_btrfs_fs_feature"
2623 modprobe btrfs > /dev/null 2>&1
2624 [ -e /sys/fs/btrfs/features/$feat ] || \
2625 _notrun "Feature $feat not supported by the available btrfs version"
2628 _require_test_symlinks()
2630 # IRIX UDF does not support symlinks
2631 [ "$HOSTOS" = "IRIX" -a "$FSTYP" = 'udf' ] && \
2632 _notrun "Require symlinks support"
2633 target=`mktemp -p $TEST_DIR`
2634 link=`mktemp -p $TEST_DIR -u`
2635 ln -s `basename $target` $link
2636 if [ "$?" -ne 0 ]; then
2638 _notrun "Require symlinks support"
2643 _require_test_fcntl_advisory_locks()
2645 [ "$FSTYP" != "cifs" ] && return 0
2646 cat /proc/mounts | grep $TEST_DEV | grep cifs | grep -q "nobrl" && return 0
2647 cat /proc/mounts | grep $TEST_DEV | grep cifs | grep -qE "nounix|forcemand" && \
2648 _notrun "Require fcntl advisory locks support"
2653 if [ -z "$1" ]; then
2654 echo "Usage: _get_total_inode <mnt>"
2658 nr_inode=`$DF_PROG -i $1 | tail -1 | awk '{print $3}'`
2664 if [ -z "$1" ]; then
2665 echo "Usage: _get_used_inode <mnt>"
2669 nr_inode=`$DF_PROG -i $1 | tail -1 | awk '{print $4}'`
2675 if [ -z "$1" ]; then
2676 echo "Usage: _get_free_inode <mnt>"
2680 nr_inode=`$DF_PROG -i $1 | tail -1 | awk '{print $5}'`
2684 # get btrfs profile configs being tested
2686 # A set of pre-set profile configs are exported via _btrfs_profile_configs
2687 # array. Default configs can be overridden by setting BTRFS_PROFILE_CONFIGS
2688 # var in the format "metadata_profile:data_profile", multiple configs can be
2689 # seperated by space, e.g.
2690 # export BTRFS_PROFILE_CONFIGS="raid0:raid0 raid1:raid1 dup:single"
2691 _btrfs_get_profile_configs()
2693 if [ "$FSTYP" != "btrfs" ]; then
2697 # no user specified btrfs profile configs, export the default configs
2698 if [ -z "$BTRFS_PROFILE_CONFIGS" ]; then
2700 _btrfs_profile_configs=(
2701 "-m single -d single"
2706 "-m raid10 -d raid10"
2711 # remove dup/raid5/raid6 profiles if we're doing device replace
2712 # dup profile indicates only one device being used (SCRATCH_DEV),
2713 # but we don't want to replace SCRATCH_DEV, which will be used in
2714 # _scratch_mount/_check_scratch_fs etc.
2715 # and raid5/raid6 doesn't support replace yet
2716 if [ "$1" == "replace" ]; then
2717 _btrfs_profile_configs=(
2718 "-m single -d single"
2722 "-m raid10 -d raid10"
2723 # add these back when raid5/6 is working with replace
2724 #"-m raid5 -d raid5"
2725 #"-m raid6 -d raid6"
2728 export _btrfs_profile_configs
2732 # parse user specified btrfs profile configs
2735 for cfg in $BTRFS_PROFILE_CONFIGS; do
2736 # turn "metadata:data" format to "-m metadata -d data"
2737 # and assign it to _btrfs_profile_configs array
2738 cfg=`echo "$cfg" | sed -e 's/^/-m /' -e 's/:/ -d /'`
2739 _btrfs_profile_configs[$i]="$cfg"
2743 if [ "$1" == "replace" ]; then
2744 if echo ${_btrfs_profile_configs[*]} | grep -q raid[56]; then
2745 _notrun "RAID5/6 doesn't support btrfs device replace yet"
2747 if echo ${_btrfs_profile_configs[*]} | grep -q dup; then
2748 _notrun "Do not set dup profile in btrfs device replace test"
2751 export _btrfs_profile_configs
2754 # stress btrfs by running balance operation in a loop
2755 _btrfs_stress_balance()
2759 $BTRFS_UTIL_PROG balance start $btrfs_mnt
2763 # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop
2764 _btrfs_stress_subvolume()
2768 local subvol_name=$3
2771 mkdir -p $subvol_mnt
2773 $BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
2774 $MOUNT_PROG -o subvol=$subvol_name $btrfs_dev $subvol_mnt
2775 $UMOUNT_PROG $subvol_mnt
2776 $BTRFS_UTIL_PROG subvolume delete $btrfs_mnt/$subvol_name
2780 # stress btrfs by running scrub in a loop
2781 _btrfs_stress_scrub()
2785 $BTRFS_UTIL_PROG scrub start -B $btrfs_mnt
2789 # stress btrfs by defragmenting every file/dir in a loop and compress file
2790 # contents while defragmenting if second argument is not "nocompress"
2791 _btrfs_stress_defrag()
2797 if [ "$compress" == "nocompress" ]; then
2798 find $btrfs_mnt \( -type f -o -type d \) -exec \
2799 $BTRFS_UTIL_PROG filesystem defrag {} \;
2801 find $btrfs_mnt \( -type f -o -type d \) -exec \
2802 $BTRFS_UTIL_PROG filesystem defrag -clzo {} \;
2803 find $btrfs_mnt \( -type f -o -type d \) -exec \
2804 $BTRFS_UTIL_PROG filesystem defrag -czlib {} \;
2809 # stress btrfs by remounting it with different compression algorithms in a loop
2810 # run this with fsstress running at background could exercise the compression
2811 # code path and ensure no race when switching compression algorithm with constant
2813 _btrfs_stress_remount_compress()
2817 for algo in no zlib lzo; do
2818 $MOUNT_PROG -o remount,compress=$algo $btrfs_mnt
2823 # stress btrfs by replacing devices in a loop
2824 # Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last
2825 # device should be free(not used by btrfs)
2826 _btrfs_stress_replace()
2830 # The device number in SCRATCH_DEV_POOL should be at least 3,
2831 # one is SCRATCH_DEV, one is to be replaced, one is free device
2832 # we won't replace SCRATCH_DEV, see below for reason
2833 if [ "`echo $SCRATCH_DEV_POOL | wc -w`" -lt 3 ]; then
2834 echo "_btrfs_stress_replace requires at least 3 devices in SCRATCH_DEV_POOL"
2838 # take the last device as the first free_dev
2839 local free_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
2841 # free_dev should be really free
2842 if $BTRFS_UTIL_PROG filesystem show $btrfs_mnt | grep -q "$free_dev"; then
2843 echo "_btrfs_stress_replace: $free_dev is used by btrfs"
2847 # dev_pool is device list being currently used by btrfs (excluding SCRATCH_DEV)
2848 # and can be replaced. We don't replace SCRATCH_DEV because it will be used in
2849 # _scratch_mount and _check_scratch_fs etc.
2850 local dev_pool=`echo $SCRATCH_DEV_POOL | sed -e "s# *$SCRATCH_DEV *##" \
2851 -e "s# *$free_dev *##"`
2853 # set the first device in dev_pool as the first src_dev to be replaced
2854 local src_dev=`echo $dev_pool | $AWK_PROG '{print $1}'`
2856 echo "dev_pool=$dev_pool"
2857 echo "free_dev=$free_dev, src_dev=$src_dev"
2859 echo "Replacing $src_dev with $free_dev"
2860 $BTRFS_UTIL_PROG replace start -fB $src_dev $free_dev $btrfs_mnt
2861 if [ $? -ne 0 ]; then
2862 # don't update src_dev and free_dev if replace failed
2865 dev_pool="$dev_pool $free_dev"
2866 dev_pool=`echo $dev_pool | sed -e "s# *$src_dev *##"`
2868 src_dev=`echo $dev_pool | $AWK_PROG '{print $1}'`
2872 # find the right option to force output in bytes, older versions of btrfs-progs
2873 # print that by default, newer print human readable numbers with unit suffix
2874 _btrfs_qgroup_units()
2876 $BTRFS_UTIL_PROG qgroup show --help 2>&1 | grep -q -- --raw && echo "--raw"
2879 # return device size in kb
2882 grep `_short_dev $1` /proc/partitions | awk '{print $3}'
2885 # don't check dmesg log after test
2886 _disable_dmesg_check()
2888 rm -f ${RESULT_DIR}/check_dmesg
2893 if [ "$iam" == new ]
2897 # make some further configuration checks here
2898 if [ "$TEST_DEV" = "" ]
2900 echo "common/rc: Error: \$TEST_DEV is not set"
2904 # if $TEST_DEV is not mounted, mount it now as XFS
2905 if [ -z "`_fs_type $TEST_DEV`" ]
2907 # $TEST_DEV is not mounted
2910 echo "common/rc: retrying test device mount with external set"
2911 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
2914 echo "common/rc: could not mount $TEST_DEV on $TEST_DIR"
2920 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
2922 echo "common/rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
2926 # Figure out if we need to add -F ("foreign", deprecated) option to xfs_io
2927 xfs_io -c stat $TEST_DIR 2>&1 | grep -q "is not on an XFS filesystem" && \
2928 export XFS_IO_PROG="$XFS_IO_PROG -F"
2930 # xfs_copy doesn't work on v5 xfs yet without -d option
2931 if [ "$FSTYP" == "xfs" ] && [[ $MKFS_OPTIONS =~ crc=1 ]]; then
2932 export XFS_COPY_PROG="$XFS_COPY_PROG -d"
2936 # get real device path name by following link
2940 if [ -b "$_dev" ] && [ -L "$_dev" ]; then
2941 _dev=`readlink -f "$_dev"`
2946 # basename of a device
2949 echo `basename $(_real_dev $1)`
2954 if [ -z $1 ] || [ ! -d $1 ]; then
2955 echo "Missing mount point argument for get_block_size"
2958 echo `stat -f -c %S $1`
2963 ################################################################################
2964 # make sure this script returns success