glusterfs)
;;
overlay)
+ . ./common/overlay
;;
reiser4)
[ "$MKFS_REISER4_PROG" = "" ] && _fatal "mkfs.reiser4 not found"
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
}
_mkfs_dev()
{
+ local tmp=`mktemp -u`
case $FSTYP in
nfs*)
# do nothing for nfs
# 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
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 \""
;;
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
;;
(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"
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()
_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()
;;
"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" )
_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
- if [ -n "$param" -a $param_checked -eq 0 ]; then
+ 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
}
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()
_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`
_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
-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
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