From: "Theodore Ts'o" <tytso@mit.edu>
To: fstests@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH] common: add support for the "local" file system type
Date: Fri, 23 Sep 2016 16:05:26 -0400 [thread overview]
Message-ID: <20160923200526.29674-1-tytso@mit.edu> (raw)
It is sometimes useful to be able to test the local file system
provided in a restricted execution environment (such as that which is
provided by Docker, for example) where it is not possible to mount and
unmount the file system under test.
To support this test case, add support for a new file system type
called "local". The TEST_DEV and SCRATCH_DEV should be have a
non-block device format (e.g., local:/test or local:/scratch), and the
TEST_DIR and SCRATCH_MNT directories should be pre-existing
directories provided by the execution environment.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
common/rc | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
tests/generic/027 | 2 +-
2 files changed, 70 insertions(+), 4 deletions(-)
diff --git a/common/rc b/common/rc
index 70d79c9..c03b132 100644
--- a/common/rc
+++ b/common/rc
@@ -330,12 +330,29 @@ _overlay_scratch_unmount()
$UMOUNT_PROG $SCRATCH_MNT
}
+_local_validate_mount_opt()
+{
+ case "$*" in
+ ro|ro,*|*,ro) _notrun "ro mount option not supported" ;;
+ *nosuid*) _notrun "nosuid mount option not supported" ;;
+ *noatime*) _notrun "noatime mount option not supported" ;;
+ *relatime*) _notrun "relatime mount option not supported" ;;
+ *diratime*) _notrun "diratime mount option not supported" ;;
+ *strictatime*) _notrun "strictatime mount option not supported" ;;
+ esac
+}
+
_scratch_mount()
{
if [ "$FSTYP" == "overlay" ]; then
_overlay_scratch_mount $*
return $?
fi
+ if [ "$FSTYP" == "local" ]; then
+ _local_validate_mount_opt "$*"
+ mkdir -p $SCRATCH_MNT
+ return $?
+ fi
_mount -t $FSTYP `_scratch_mount_options $*`
}
@@ -348,6 +365,9 @@ _scratch_unmount()
btrfs)
$UMOUNT_PROG $SCRATCH_MNT
;;
+ local)
+ rm -rf $SCRATCH_MNT/*
+ ;;
*)
$UMOUNT_PROG $SCRATCH_DEV
;;
@@ -358,6 +378,10 @@ _scratch_remount()
{
local opts="$1"
+ if [ "$FSTYP" = "local" ]; then
+ _local_validate_mount_opt "$*"
+ return 0;
+ fi
if test -n "$opts"; then
mount -o "remount,$opts" $SCRATCH_MNT
fi
@@ -367,7 +391,7 @@ _scratch_cycle_mount()
{
local opts="$1"
- if [ "$FSTYP" = tmpfs ]; then
+ if [ "$FSTYP" = "tmpfs" -o "$FSTYP" = "local" ] ; then
_scratch_remount "$opts"
return
fi
@@ -384,6 +408,10 @@ _test_mount()
_overlay_test_mount $*
return $?
fi
+ if [ "$FSTYP" == "local" ]; then
+ mkdir -p $TEST_DIR
+ return $?
+ fi
_test_options mount
_mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
}
@@ -392,7 +420,7 @@ _test_unmount()
{
if [ "$FSTYP" == "overlay" ]; then
_overlay_test_unmount
- else
+ elif [ "$FSTYP" != "local" ]; then
$UMOUNT_PROG $TEST_DEV
fi
}
@@ -811,6 +839,9 @@ _scratch_mkfs()
tmpfs)
# do nothing for tmpfs
;;
+ local)
+ _scratch_cleanup_files
+ ;;
f2fs)
$MKFS_F2FS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
;;
@@ -1031,6 +1062,13 @@ _scratch_mkfs_sized()
fi
export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
;;
+ local)
+ _scratch_cleanup_files
+ free_space=$(_df_dir $SCRATCH_MNT | $AWK_PROG '{ print $5 }')
+ if [ "$(expr $free_space * 1024)" -lt "$fssize" ] ; then
+ _notrun "Not enough space ($free_space) for local with $fssize bytes"
+ fi
+ ;;
*)
_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
;;
@@ -1517,6 +1555,13 @@ _require_scratch_nocheck()
_notrun "this test requires a valid \$SCRATCH_MNT and unique $SCRATCH_DEV"
fi
;;
+ local)
+ if [ -z "$SCRATCH_DEV" -o ! -d "$SCRATCH_MNT" ];
+ then
+ _notrun "this test requires a valid \$SCRATCH_MNT and unique $SCRATCH_DEV"
+ fi
+ return 0
+ ;;
*)
if [ -z "$SCRATCH_DEV" -o "`_is_block_dev "$SCRATCH_DEV"`" = "" ]
then
@@ -1602,6 +1647,13 @@ _require_test()
_notrun "this test requires a valid \$TEST_DIR and unique $TEST_DEV"
fi
;;
+ local)
+ if [ -z "$TEST_DEV" -o ! -d "$TEST_DIR" ];
+ then
+ _notrun "this test requires a valid \$TEST_DIR and unique $TEST_DEV"
+ fi
+ return 0
+ ;;
*)
if [ -z "$TEST_DEV" ] || [ "`_is_block_dev "$TEST_DEV"`" = "" ]
then
@@ -2264,6 +2316,10 @@ _remount()
device=$1
mode=$2
+ if [ "$FSTYP" == "local" ] ; then
+ return 0
+ fi
+
if ! mount -o remount,$mode $device
then
echo "_remount: failed to remount filesystem on $device as $mode"
@@ -2309,6 +2365,10 @@ _mount_or_remount_rw()
device=$2
mountpoint=$3
+ if [ "$FSTYP" == "local" ] ; then
+ return 0
+ fi
+
if [ $USE_REMOUNT -eq 0 ]; then
if [ "$FSTYP" != "overlay" ]; then
_mount -t $FSTYP $mount_opts $device $mountpoint
@@ -2666,6 +2726,9 @@ _check_test_fs()
tmpfs)
# no way to check consistency for tmpfs
;;
+ local)
+ # no way to check consistency for local
+ ;;
*)
_check_generic_filesystem $TEST_DEV
;;
@@ -2707,6 +2770,9 @@ _check_scratch_fs()
tmpfs)
# no way to check consistency for tmpfs
;;
+ local)
+ # no way to check consistency for local
+ ;;
*)
_check_generic_filesystem $device
;;
@@ -3784,7 +3850,7 @@ init_rc()
fi
fi
- if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
+ if [ "$FSTYP" != "local" -a "`_fs_type $TEST_DEV`" != "$FSTYP" ]
then
echo "common/rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
# raw $DF_PROG cannot handle NFS/CIFS/overlay correctly
diff --git a/tests/generic/027 b/tests/generic/027
index d2e59d6..73565fc 100755
--- a/tests/generic/027
+++ b/tests/generic/027
@@ -77,7 +77,7 @@ rm -f $SCRATCH_MNT/testfile
loop=100
# btrfs takes much longer time, reduce the loop count
-if [ "$FSTYP" == "btrfs" ]; then
+if [ "$FSTYP" == "btrfs" -o "$FSTYP" == "local" ]; then
loop=10
fi
--
2.9.0.243.g5c589a7.dirty
next reply other threads:[~2016-09-23 20:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 20:05 Theodore Ts'o [this message]
2016-09-26 13:25 ` [PATCH] common: add support for the "local" file system type Eryu Guan
2016-09-26 15:14 ` Theodore Ts'o
2016-09-27 9:55 ` Eryu Guan
2016-09-29 0:01 ` Theodore Ts'o
2016-09-26 22:18 ` Dave Chinner
2016-09-28 23:57 ` Theodore Ts'o
2016-09-29 2:16 ` Dave Chinner
2016-09-29 3:56 ` Theodore Ts'o
2016-09-29 5:37 ` Dave Chinner
2016-09-29 13:05 ` Theodore Ts'o
2016-09-29 22:49 ` Dave Chinner
2016-09-30 3:43 ` Theodore Ts'o
2016-09-29 13:37 ` Eric Sandeen
2016-09-29 13:57 ` Eric Sandeen
-- strict thread matches above, loose matches on Subject: below --
2018-05-03 3:43 Theodore Y. Ts'o
2018-05-03 9:22 ` Amir Goldstein
2018-05-03 18:35 ` Theodore Y. Ts'o
2018-05-03 19:24 ` Amir Goldstein
2018-05-06 3:54 ` Eryu Guan
2018-05-12 8:42 ` Eryu Guan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160923200526.29674-1-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox