[ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found"
;;
nfs)
+ . ./common/nfs
;;
cifs)
;;
ceph)
;;
+ glusterfs)
+ ;;
overlay)
+ . ./common/overlay
;;
reiser4)
[ "$MKFS_REISER4_PROG" = "" ] && _fatal "mkfs.reiser4 not found"
;;
+ pvfs2)
+ ;;
+ ubifs)
+ [ "$UBIUPDATEVOL_PROG" = "" ] && _fatal "ubiupdatevol not found"
+ ;;
esac
+if [ ! -z "$REPORT_LIST" ]; then
+ . ./common/report
+ _assert_report_list
+fi
+
_mount()
{
$MOUNT_PROG `_mount_ops_filter $*`
case $type in
mkfs)
- [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
+ SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
rt_opt="-r"
log_opt="-l"
;;
[ $last_index -gt 0 ] && shift $last_index
FS_ESCAPED=$1
- # irix is fussy about how it is fed its mount options
- # - multiple -o's are not allowed
- # - no spaces between comma delimitered options
- # the sed script replaces all -o's (except the first) with a comma
- # not required for linux, but won't hurt
-
- echo $params | sed -e 's/[[:space:]]\+-o[[:space:]]*/UnIqUe/1; s/[[:space:]]\+-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
- | sed -e 's/dmapi/dmi/' \
+ echo $params | sed -e 's/dmapi/dmi/' \
| $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
}
echo $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $*
}
-_overlay_basic_mount_options()
-{
- echo "-o lowerdir=$1/$OVL_LOWER,upperdir=$1/$OVL_UPPER,workdir=$1/$OVL_WORK"
-}
-
-_overlay_mount_options()
-{
- echo `_common_dev_mount_options` \
- `_overlay_basic_mount_options $1` \
- $OVERLAY_MOUNT_OPTIONS
-}
-
_scratch_mount_options()
{
_scratch_options mount
- if [ "$FSTYP" == "overlay" ]; then
- echo `_overlay_mount_options $OVL_BASE_SCRATCH_MNT`
- return 0
- fi
echo `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
$SCRATCH_DEV $SCRATCH_MNT
}
esac
}
-# helper function to do the actual overlayfs mount operation
-_overlay_mount_dirs()
-{
- local lowerdir=$1
- local upperdir=$2
- local workdir=$3
- shift 3
-
- $MOUNT_PROG -t overlay -o lowerdir=$lowerdir -o upperdir=$upperdir \
- -o workdir=$workdir $*
-}
-
-_overlay_mkdirs()
-{
- local dir=$1
-
- mkdir -p $dir/$OVL_UPPER
- mkdir -p $dir/$OVL_LOWER
- mkdir -p $dir/$OVL_WORK
- mkdir -p $dir/$OVL_MNT
-}
-
-# Given a base fs dir, set up overlay directories and mount on the given mnt.
-# The dir is used as the mount device so it can be seen from df or mount
-_overlay_mount()
-{
- local dir=$1
- local mnt=$2
- shift 2
-
- _supports_filetype $dir || _notrun "upper fs needs to support d_type"
-
- _overlay_mkdirs $dir
-
- _overlay_mount_dirs $dir/$OVL_LOWER $dir/$OVL_UPPER \
- $dir/$OVL_WORK $OVERLAY_MOUNT_OPTIONS \
- $SELINUX_MOUNT_OPTIONS $* $dir $mnt
-}
-
-_overlay_base_test_mount()
-{
- if [ -z "$OVL_BASE_TEST_DEV" -o -z "$OVL_BASE_TEST_DIR" ] || \
- _check_mounted_on OVL_BASE_TEST_DEV $OVL_BASE_TEST_DEV \
- OVL_BASE_TEST_DIR $OVL_BASE_TEST_DIR
- then
- # no base fs or already mounted
- return 0
- elif [ $? -ne 1 ]
- then
- # base fs mounted but not on mount point
- return 1
- fi
-
- _mount $TEST_FS_MOUNT_OPTS \
- $SELINUX_MOUNT_OPTIONS \
- $OVL_BASE_TEST_DEV $OVL_BASE_TEST_DIR
-}
-
-_overlay_test_mount()
-{
- _overlay_base_test_mount && \
- _overlay_mount $OVL_BASE_TEST_DIR $TEST_DIR $*
-}
-
-_overlay_base_scratch_mount()
-{
- if [ -z "$OVL_BASE_SCRATCH_DEV" -o -z "$OVL_BASE_SCRATCH_MNT" ] || \
- _check_mounted_on OVL_BASE_SCRATCH_DEV $OVL_BASE_SCRATCH_DEV \
- OVL_BASE_SCRATCH_MNT $OVL_BASE_SCRATCH_MNT
- then
- # no base fs or already mounted
- return 0
- elif [ $? -ne 1 ]
- then
- # base fs mounted but not on mount point
- return 1
- fi
-
- _mount $OVL_BASE_MOUNT_OPTIONS \
- $SELINUX_MOUNT_OPTIONS \
- $OVL_BASE_SCRATCH_DEV $OVL_BASE_SCRATCH_MNT
-}
-
-_overlay_base_scratch_unmount()
-{
- [ -n "$OVL_BASE_SCRATCH_DEV" -a -n "$OVL_BASE_SCRATCH_MNT" ] || return 0
-
- $UMOUNT_PROG $OVL_BASE_SCRATCH_MNT
-}
-
-_overlay_scratch_mount()
-{
- _overlay_base_scratch_mount && \
- _overlay_mount $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT $*
-}
-
-_overlay_base_test_unmount()
-{
- [ -n "$OVL_BASE_TEST_DEV" -a -n "$OVL_BASE_TEST_DIR" ] || return 0
-
- $UMOUNT_PROG $OVL_BASE_TEST_DIR
-}
-
-_overlay_test_unmount()
-{
- $UMOUNT_PROG $TEST_DIR
- _overlay_base_test_unmount
-}
-
-_overlay_scratch_unmount()
-{
- $UMOUNT_PROG $SCRATCH_MNT
- _overlay_base_scratch_unmount
-}
-
_scratch_mount()
{
if [ "$FSTYP" == "overlay" ]; then
shift 2
local extra_mkfs_options=$*
local mkfs_status
- local tmp=`mktemp`
+ local tmp=`mktemp -u`
# save mkfs output in case conflict means we need to run again.
# only the output for the mkfs that applies should be shown
cat $tmp.mkfsstd
eval "cat $tmp.mkfserr | $mkfs_filter" >&2
- rm -f $tmp*
+ rm -f $tmp.mkfserr $tmp.mkfsstd
return $mkfs_status
}
{
local mkfs_cmd="$MKFS_EXT4_PROG -F"
local mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \""
- local tmp=`mktemp`
+ local tmp=`mktemp -u`
local mkfs_status
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \
+ mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV"
_scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
mkfs_status=$?
# output mkfs stdout and stderr
cat $tmp.mkfsstd
cat $tmp.mkfserr >&2
+ rm -f $tmp.mkfserr $tmp.mkfsstd
return $mkfs_status
}
ceph)
# do nothing for ceph
;;
+ glusterfs)
+ # do nothing for glusterfs
+ ;;
overlay)
# do nothing for overlay
;;
+ pvfs2)
+ # do nothing for pvfs2
+ ;;
udf)
$MKFS_UDF_PROG $MKFS_OPTIONS $* $TEST_DEV > /dev/null
;;
_mkfs_dev()
{
+ local tmp=`mktemp -u`
case $FSTYP in
nfs*)
# do nothing for nfs
overlay)
# do nothing for overlay
;;
+ pvfs2)
+ # do nothing for pvfs2
+ ;;
udf)
- $MKFS_UDF_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ $MKFS_UDF_PROG $MKFS_OPTIONS $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
;;
btrfs)
- $MKFS_BTRFS_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ $MKFS_BTRFS_PROG $MKFS_OPTIONS $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
;;
ext2|ext3|ext4)
$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* \
- 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ 2>$tmp.mkfserr 1>$tmp.mkfsstd
+ ;;
+ xfs)
+ $MKFS_PROG -t $FSTYP -- -f $MKFS_OPTIONS $* \
+ 2>$tmp.mkfserr 1>$tmp.mkfsstd
;;
-
*)
yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* \
- 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ 2>$tmp.mkfserr 1>$tmp.mkfsstd
;;
esac
if [ $? -ne 0 ]; then
# output stored mkfs output
- cat $tmp_dir.mkfserr >&2
- cat $tmp_dir.mkfsstd
+ cat $tmp.mkfserr >&2
+ cat $tmp.mkfsstd
status=1
exit 1
fi
- rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
+ rm -f $tmp.mkfserr $tmp.mkfsstd
}
# remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS
local mkfs_status
case $FSTYP in
- nfs*|cifs|ceph|overlay)
+ nfs*|cifs|ceph|overlay|glusterfs|pvfs2)
# unable to re-create this fstyp, just remove all files in
# $SCRATCH_MNT to avoid EEXIST caused by the leftover files
# created in previous runs
# do nothing for tmpfs
return 0
;;
+ ubifs)
+ # erase the UBI volume; reformated automatically on next mount
+ $UBIUPDATEVOL_PROG ${SCRATCH_DEV} -t
+ return 0
+ ;;
ext4)
_scratch_mkfs_ext4 $*
return $?
mkfs_cmd="$MKFS_BTRFS_PROG"
mkfs_filter="cat"
;;
- ext2|ext3)
+ ext3)
+ mkfs_cmd="$MKFS_PROG -t $FSTYP -- -F"
+ mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \""
+
+ # put journal on separate device?
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \
+ mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV"
+ ;;
+ ext2)
mkfs_cmd="$MKFS_PROG -t $FSTYP -- -F"
mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \""
;;
_notrun "All devs used no spare"
fi
# Get a dev that is not used
- local devs[]="( $SCRATCH_DEV_POOL_SAVED )"
+ local -a devs="( $SCRATCH_DEV_POOL_SAVED )"
SPARE_DEV=${devs[@]:$ndevs:1}
export SPARE_DEV
}
local test_ndevs=$1
local config_ndevs=`echo $SCRATCH_DEV_POOL| wc -w`
- local devs[]="( $SCRATCH_DEV_POOL )"
+ local -a devs="( $SCRATCH_DEV_POOL )"
typeset -p config_ndevs >/dev/null 2>&1
if [ $? -ne 0 ]; then
xfs)
def_blksz=`echo $MKFS_OPTIONS|sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
;;
- ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2)
+ ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|reiserfs)
def_blksz=`echo $MKFS_OPTIONS| sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
;;
+ jfs)
+ def_blksz=4096
+ ;;
esac
[ -n "$def_blksz" ] && blocksize=$def_blksz
ext2|ext3|ext4|ext4dev)
${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
;;
+ gfs2)
+ # mkfs.gfs2 doesn't automatically shrink journal files on small
+ # filesystems, so the journal files may end up being bigger than the
+ # filesystem, which will cause mkfs.gfs2 to fail. Until that's fixed,
+ # shrink the journal size to at most one eigth of the filesystem and at
+ # least 8 MiB, the minimum size allowed.
+ MIN_JOURNAL_SIZE=8
+ DEFAULT_JOURNAL_SIZE=128
+ if (( fssize/8 / (1024*1024) < DEFAULT_JOURNAL_SIZE )); then
+ (( JOURNAL_SIZE = fssize/8 / (1024*1024) ))
+ (( JOURNAL_SIZE >= MIN_JOURNAL_SIZE )) || JOURNAL_SIZE=$MIN_JOURNAL_SIZE
+ MKFS_OPTIONS="-J $JOURNAL_SIZE $MKFS_OPTIONS"
+ fi
+ ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
+ ;;
ocfs2)
yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
;;
(( fssize <= 100 * 1024 * 1024 )) && mixed_opt='--mixed'
$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
;;
+ jfs)
+ ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
+ ;;
+ reiserfs)
+ ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+ ;;
reiser4)
# mkfs.resier4 requires size in KB as input for creating filesystem
$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
ext2|ext3|ext4)
${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
;;
+ gfs2)
+ ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV
+ ;;
ocfs2)
yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV
;;
# Fix the filesystem type up here so that the callers don't
# have to bother with this quirk.
#
- _df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'
+ _df_device $1 | $AWK_PROG '{ print $2 }' | \
+ sed -e 's/nfs4/nfs/' -e 's/fuse.glusterfs/glusterfs/'
}
# return the FS mount options of a mounted device
fi
}
+# returns device number if a file is a character device
+#
+_is_char_dev()
+{
+ if [ $# -ne 1 ]; then
+ echo "Usage: _is_char_dev dev" 1>&2
+ exit 1
+ fi
+
+ _dev=$1
+ if [ -L "${_dev}" ]; then
+ _dev=`readlink -f "${_dev}"`
+ fi
+
+ if [ -c "${_dev}" ]; then
+ src/lstat64 "${_dev}" | $AWK_PROG '/Device type:/ { print $9 }'
+ fi
+}
+
# Do a command, log it to $seqres.full, optionally test return status
# and die if command fails. If called with one argument _do executes the
# command, logs it, and returns its exit status. With two arguments _do
(eval "echo '---' \"$_cmd\"") >>$seqres.full
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
cat $tmp._out | _fix_malloc >>$seqres.full
+ rm -f $tmp._out
if [ $# -eq 2 ]; then
if [ $ret -eq 0 ]; then
echo "done"
local mnt=$4
local type=$5
- # Note that we use -F here so grep doesn't try to interpret an NFS over
- # IPv6 server as a regular expression. Because of that, we cannot use
- # ^$dev so we use "$dev on " to avoid matching $dev to mount point field
- # for overlay case, where $dev is a directory.
- local mount_rec=`_mount | grep -F "$dev on "`
+ # find $dev as the source, and print result in "$dev $mnt" format
+ local mount_rec=`findmnt -rncv -S $dev -o SOURCE,TARGET`
[ -n "$mount_rec" ] || return 1 # 1 = not mounted
# if it's mounted, make sure its on $mnt
- if ! (echo $mount_rec | grep -q "$dev on $mnt")
- then
+ if [ "$mount_rec" != "$dev $mnt" ]; then
echo "$devname=$dev is mounted but not on $mntname=$mnt - aborting"
echo "Already mounted result:"
echo $mount_rec
return 2 # 2 = mounted on wrong mnt
fi
- if [ -n "$type" -a "`_fs_type $dev`" != "$type" ]
- then
+ if [ -n "$type" -a "`_fs_type $dev`" != "$type" ]; then
echo "$devname=$dev is mounted but not a type $type filesystem"
# raw $DF_PROG cannot handle NFS/CIFS/overlay correctly
_df_device $dev
_require_scratch_nocheck()
{
case "$FSTYP" in
+ glusterfs)
+ echo $SCRATCH_DEV | egrep -q ":/?" > /dev/null 2>&1
+ if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
+ _notrun "this test requires a valid \$SCRATCH_DEV"
+ fi
+ if [ ! -d "$SCRATCH_MNT" ]; then
+ _notrun "this test requires a valid \$SCRATCH_MNT"
+ fi
+ ;;
nfs*|ceph)
echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
_notrun "this test requires a valid \$SCRATCH_MNT"
fi
;;
+ pvfs2)
+ echo $SCRATCH_DEV | grep -q "://" > /dev/null 2>&1
+ if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
+ _notrun "this test requires a valid \$SCRATCH_DEV"
+ fi
+ if [ ! -d "$SCRATCH_MNT" ]; then
+ _notrun "this test requires a valid \$SCRATCH_MNT"
+ fi
+ ;;
cifs)
echo $SCRATCH_DEV | grep -q "//" > /dev/null 2>&1
if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
_notrun "this test requires a valid \$SCRATCH_MNT and unique $SCRATCH_DEV"
fi
;;
+ ubifs)
+ # ubifs needs an UBI volume. This will be a char device, not a block device.
+ if [ ! -c "$SCRATCH_DEV" ]; then
+ _notrun "this test requires a valid UBI volume for \$SCRATCH_DEV"
+ fi
+ if [ ! -d "$SCRATCH_MNT" ]; then
+ _notrun "this test requires a valid \$SCRATCH_MNT"
+ fi
+ ;;
*)
if [ -z "$SCRATCH_DEV" -o "`_is_block_dev "$SCRATCH_DEV"`" = "" ]
then
_require_test()
{
case "$FSTYP" in
+ glusterfs)
+ echo $TEST_DEV | egrep -q ":/?" > /dev/null 2>&1
+ if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
+ _notrun "this test requires a valid \$TEST_DEV"
+ fi
+ if [ ! -d "$TEST_DIR" ]; then
+ _notrun "this test requires a valid \$TEST_DIR"
+ fi
+ ;;
nfs*|ceph)
echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
_notrun "this test requires a valid \$TEST_DIR"
fi
;;
+ pvfs2)
+ echo $TEST_DEV | grep -q "://" > /dev/null 2>&1
+ if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
+ _notrun "this test requires a valid \$TEST_DIR"
+ fi
+ if [ ! -d "$TEST_DIR" ]; then
+ _notrun "this test requires a valid \$TEST_DIR"
+ fi
+ ;;
overlay)
if [ -z "$OVL_BASE_TEST_DIR" -o ! -d "$OVL_BASE_TEST_DIR" ]; then
_notrun "this test requires a valid \$TEST_DIR as ovl base dir"
_notrun "this test requires a valid \$TEST_DIR and unique $TEST_DEV"
fi
;;
+ ubifs)
+ # ubifs needs an UBI volume. This will be a char device, not a block device.
+ if [ ! -c "$TEST_DEV" ]; then
+ _notrun "this test requires a valid UBI volume for \$TEST_DEV"
+ fi
+ if [ ! -d "$TEST_DIR" ]; then
+ _notrun "this test requires a valid \$TEST_DIR"
+ fi
+ ;;
*)
if [ -z "$TEST_DEV" ] || [ "`_is_block_dev "$TEST_DEV"`" = "" ]
then
touch ${RESULT_DIR}/require_test
}
+_has_logdev()
+{
+ local ret=0
+ [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && ret=1
+ [ "$USE_EXTERNAL" != yes ] && ret=1
+
+ return $ret
+}
+
# this test needs a logdev
#
_require_logdev()
fi
}
+# this test requires a path to refere to a local block or character device
+# $1 - device
+_require_local_device()
+{
+ if [ -z "$1" ]; then
+ echo "Usage: _require_local_device <dev>" 1>&2
+ exit 1
+ fi
+ if [ "`_is_block_dev "$1"`" != "" ]; then
+ return 0
+ fi
+ if [ "`_is_char_dev "$1"`" != "" ]; then
+ return 0
+ fi
+ _notrun "require $1 to be local device"
+}
+
# brd based ram disks erase the device when they receive a flush command when no
# active references are present. This causes problems for DM devices sitting on
# top of brd devices as DM doesn't hold active references to the brd device.
_notrun "External device testing in progress, skipped this test"
}
+# this test requires that the kernel supports asynchronous I/O
+_require_aio()
+{
+ $here/src/feature -A
+ case $? in
+ 0)
+ ;;
+ 1)
+ _notrun "kernel does not support asynchronous I/O"
+ ;;
+ *)
+ _fail "unexpected error testing for asynchronous I/O support"
+ ;;
+ esac
+}
+
# this test requires that a (specified) aio-dio executable exists
+# and that the kernel supports asynchronous I/O.
# $1 - command (optional)
#
_require_aiodio()
AIO_TEST=src/aio-dio-regress/$1
[ -x $AIO_TEST ] || _notrun "$AIO_TEST not built"
fi
+ _require_aio
_require_odirect
}
qa_group=$1
fi
_cat_group | grep -q $qa_group
- [ "$?" == "0" ] || _notrun "$qa_group user not defined."
+ [ "$?" == "0" ] || _notrun "$qa_group group not defined."
}
_filter_user_do()
_user_do()
{
- if [ "$HOSTOS" == "IRIX" ]
- then
- echo $1 | /bin/bash "su $qa_user 2>&1" | _filter_user_do
- else
echo $1 | su -s /bin/bash $qa_user 2>&1 | _filter_user_do
- fi
}
_require_xfs_io_command()
echo "Usage: _require_xfs_io_command command [switch]" 1>&2
exit 1
fi
- command=$1
+ local command=$1
shift
- param="$*"
+ local param="$*"
+ local param_checked=0
testfile=$TEST_DIR/$$.xfs_io
case $command in
"chproj")
testio=`$XFS_IO_PROG -F -f -c "chproj 0" $testfile 2>&1`
;;
+ "copy_range")
+ testcopy=$TEST_DIR/$$.copy.xfs_io
+ $XFS_IO_PROG -F -f -c "pwrite 0 4k" $testfile > /dev/null 2>&1
+ testio=`$XFS_IO_PROG -F -f -c "copy_range $testfile" $testcopy 2>&1`
+ rm -f $testcopy > /dev/null 2>&1
+ ;;
"falloc" )
- testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
+ testio=`$XFS_IO_PROG -F -f -c "falloc $param 0 1m" $testfile 2>&1`
+ param_checked=1
;;
"fpunch" | "fcollapse" | "zero" | "fzero" | "finsert" | "funshare")
testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
;;
"fiemap")
testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
- -c "fiemap -v" $testfile 2>&1`
+ -c "fiemap -v $param" $testfile 2>&1`
+ param_checked=1
;;
"flink" )
testio=`$XFS_IO_PROG -T -F -c "flink $testfile" \
;;
"fsmap" )
testio=`$XFS_IO_PROG -f -c "fsmap" $testfile 2>&1`
- echo $testio | egrep -q "Inappropriate ioctl" && \
+ echo $testio | grep -q "Inappropriate ioctl" && \
_notrun "xfs_io $command support is missing"
;;
"open")
# a new -C flag was introduced to execute one shot commands.
# Check for -C flag support as an indication for the bug fix.
testio=`$XFS_IO_PROG -F -f -C "open $testfile" $testfile 2>&1`
- echo $testio | egrep -q "invalid option" && \
+ echo $testio | grep -q "invalid option" && \
+ _notrun "xfs_io $command support is missing"
+ ;;
+ "scrub"|"repair")
+ testio=`$XFS_IO_PROG -x -c "$command probe 0" $TEST_DIR 2>&1`
+ echo $testio | grep -q "Inappropriate ioctl" && \
_notrun "xfs_io $command support is missing"
;;
"utimes" )
testio=`$XFS_IO_PROG -f -c "utimes" 0 0 0 0 $testfile 2>&1`
;;
*)
- testio=`$XFS_IO_PROG -c "$command help" 2>&1`
+ testio=`$XFS_IO_PROG -c "help $command" 2>&1`
esac
rm -f $testfile 2>&1 > /dev/null
_notrun "xfs_io $command support is missing"
echo $testio | grep -q "Operation not supported" && \
_notrun "xfs_io $command failed (old kernel/wrong fs?)"
+ echo $testio | grep -q "Invalid" && \
+ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"
echo $testio | grep -q "foreign file active" && \
_notrun "xfs_io $command not supported on $FSTYP"
+ echo $testio | grep -q "Function not implemented" && \
+ _notrun "xfs_io $command support is missing (missing syscall?)"
+
+ [ -n "$param" ] || return
- test -z "$param" && return
- $XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \
- _notrun "xfs_io $command doesn't support $param"
+ if [ $param_checked -eq 0 ]; then
+ $XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \
+ _notrun "xfs_io $command doesn't support $param"
+ else
+ echo $testio | grep -q "invalid option" && \
+ _notrun "xfs_io $command doesn't support $param"
+ fi
}
# check that kernel and filesystem support direct I/O
not found. Seems that CONFIG_FAIL_MAKE_REQUEST kernel config option not enabled"
}
-#
+# Disable extent zeroing for ext4 on the given device
+_ext4_disable_extent_zeroout()
+{
+ local dev=${1:-$TEST_DEV}
+ local sdev=`_short_dev $dev`
+
+ [ -f /sys/fs/ext4/$sdev/extent_max_zeroout_kb ] && \
+ echo 0 >/sys/fs/ext4/$sdev/extent_max_zeroout_kb
+}
+
# Check if the file system supports seek_data/hole
-#
_require_seek_data_hole()
{
- testfile=$TEST_DIR/$$.seek
- testseek=`$here/src/seek_sanity_test -t $testfile 2>&1`
- rm -f $testfile &>/dev/null
- echo $testseek | grep -q "Kernel does not support" && \
- _notrun "File system does not support llseek(2) SEEK_DATA/HOLE"
+ local dev=${1:-$TEST_DEV}
+ local testfile=$TEST_DIR/$$.seek
+ local testseek=`$here/src/seek_sanity_test -t $testfile 2>&1`
+
+ rm -f $testfile &>/dev/null
+ echo $testseek | grep -q "Kernel does not support" && \
+ _notrun "File system does not support llseek(2) SEEK_DATA/HOLE"
+ # Disable extent zeroing for ext4 as that change where holes are
+ # created
+ if [ "$FSTYP" = "ext4" ]; then
+ _ext4_disable_extent_zeroout $dev
+ fi
}
_require_runas()
ceph)
# no way to check consistency for CephFS
;;
+ glusterfs)
+ # no way to check consistency for GlusterFS
+ ;;
overlay)
# no way to check consistency for overlay
;;
+ pvfs2)
+ ;;
udf)
# do nothing for now
;;
tmpfs)
# no way to check consistency for tmpfs
;;
+ ubifs)
+ # there is no fsck program for ubifs yet
+ ;;
*)
_check_generic_filesystem $TEST_DEV
;;
ceph)
# no way to check consistency for CephFS
;;
+ glusterfs)
+ # no way to check consistency for GlusterFS
+ ;;
overlay)
# no way to check consistency for overlay
;;
+ pvfs2)
+ ;;
btrfs)
_check_btrfs_filesystem $device
;;
tmpfs)
# no way to check consistency for tmpfs
;;
+ ubifs)
+ # there is no fsck program for ubifs yet
+ ;;
*)
_check_generic_filesystem $device
;;
_get_os_name()
{
- if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
- echo 'irix'
- elif [ "`uname`" == "Linux" ]; then
+ if [ "`uname`" == "Linux" ]; then
echo 'linux'
else
echo Unknown operating system: `uname`
[ $result -eq 0 ] || _notrun "$FSTYP does not support freezing"
}
+# Does NFS export work on this fs?
+_require_exportfs()
+{
+ _require_test_program "open_by_handle"
+ mkdir -p "$TEST_DIR"/exportfs_test
+ $here/src/open_by_handle -c "$TEST_DIR"/exportfs_test 2>&1 \
+ || _notrun "$FSTYP does not support NFS export"
+}
+
+
# Does shutdown work on this fs?
_require_scratch_shutdown()
{
fi
case "$FSTYP" in
- ext2|vfat|msdos)
+ ext2|vfat|msdos|udf)
_notrun "$FSTYP does not support metadata journaling"
;;
ext4)
esac
}
-# Does fiemap support?
-_require_fiemap()
-{
- _require_xfs_io_command "fiemap"
-}
-
_count_extents()
{
$XFS_IO_PROG -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
$XFS_IO_PROG -c "fiemap" $1 | tail -n +2 | grep hole | wc -l
}
+_count_attr_extents()
+{
+ $XFS_IO_PROG -c "fiemap -a" $1 | tail -n +2 | grep -v hole | wc -l
+}
+
# arg 1 is dev to remove and is output of the below eg.
# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
_devmgt_remove()
_require_test_symlinks()
{
- # IRIX UDF does not support symlinks
- [ "$HOSTOS" = "IRIX" -a "$FSTYP" = 'udf' ] && \
- _notrun "Require symlinks support"
target=`mktemp -p $TEST_DIR`
link=`mktemp -p $TEST_DIR -u`
ln -s `basename $target` $link
_require_chattr()
{
- attribute=$1
-
- touch $TEST_DIR/syscalltest
- chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
- status=$?
- chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
- if [ "$status" -ne 0 ]; then
- _notrun "file system doesn't support chattr +$attribute"
- fi
- cat $TEST_DIR/syscalltest.out >> $seqres.full
+ if [ -z "$1" ]; then
+ echo "Usage: _require_chattr <attr>"
+ exit 1
+ fi
+ local attribute=$1
- rm -f $TEST_DIR/syscalltest.out
+ touch $TEST_DIR/syscalltest
+ chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+ status=$?
+ chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+ if [ "$status" -ne 0 ]; then
+ _notrun "file system doesn't support chattr +$attribute"
+ fi
+ cat $TEST_DIR/syscalltest.out >> $seqres.full
+ rm -f $TEST_DIR/syscalltest.out
}
_get_total_inode()
# use sed \cregexpc address type, since $seqnum contains "/"
dmesg | tac | sed -ne "0,\#run fstests $seqnum at $date_time#p" | \
tac | $filter >$seqres.dmesg
- grep -q -e "kernel BUG at" \
+ egrep -q -e "kernel BUG at" \
-e "WARNING:" \
-e "BUG:" \
-e "Oops:" \
-e "possible recursive locking detected" \
-e "Internal error" \
- -e "INFO: suspicious RCU usage" \
+ -e "(INFO|ERR): suspicious RCU usage" \
-e "INFO: possible circular locking dependency detected" \
-e "general protection fault:" \
+ -e "BUG .* remaining" \
$seqres.dmesg
if [ $? -eq 0 ]; then
_dump_err "_check_dmesg: something found in dmesg (see $seqres.dmesg)"
"$@" 2>&1 | tee -a $seqres.full >$tmp.fsx
if [ ${PIPESTATUS[0]} -ne 0 ]; then
cat $tmp.fsx
+ rm -f $tmp.fsx
exit 1
fi
+ rm -f $tmp.fsx
}
# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
fi
}
+_require_statx()
+{
+ $here/src/stat_test --check-statx ||
+ _notrun "This test requires the statx system call"
+}
+
# Write "content" into /sys/fs/$FSTYP/$DEV/$ATTR
#
# All arguments are necessary, and in this order:
cat /sys/fs/${FSTYP}/${dname}/${attr}
}
+# Generic test for specific filesystem feature.
+# Currently only implemented to test overlayfs features.
+_require_scratch_feature()
+{
+ local feature=$1
+ case "$FSTYP" in
+ overlay)
+ _require_scratch_overlay_feature ${feature}
+ ;;
+ *)
+ _fail "Test for feature '${feature}' of ${FSTYP} is not implemented"
+ ;;
+ esac
+}
init_rc