FS/XFS testing framework
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: fstests@vger.kernel.org
Subject: [PATCH 2/2] fstests: Add overlayfs support
Date: Fri, 20 Mar 2015 11:22:41 -0500	[thread overview]
Message-ID: <550C4951.1030804@sandeen.net> (raw)
In-Reply-To: <550C46B2.8060407@sandeen.net>

If OVERLAYFS=1 is set, then every time we mount the scratch or
test device, set up overlayfs directories under it, and switch
the directory under test to the upper directory.

This doesn't specifically or directly test overlayfs, it simply
runs the existing tests over it.  As such, a few tests fail,
and may be expected to fail due to overlayfs limitations and
caveats.  I haven't sorted through the results yet.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/README b/README
index 0c9449a..2b1d023 100644
--- a/README
+++ b/README
@@ -78,6 +78,8 @@ Preparing system for tests (IRIX and Linux):
                added to the end of fsstresss and fsx invocations, respectively,
                in case you wish to exclude certain operational modes from these
                tests.
+             - setenv OVERLAYFS "1" to set up an overlay directory after each
+               test or scratch mount, and run all tests in the upper directory,
 
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
diff --git a/common/rc b/common/rc
index 22b9a6c..aeca679 100644
--- a/common/rc
+++ b/common/rc
@@ -200,6 +200,33 @@ _mount_ops_filter()
 
 }
 
+# Given a directory, set up 4 subdirectories and create an overlay mount
+# on $DIRECTORY/merged
+_overlayfs_mount()
+{
+	local DIR=$1
+	# No mkdir -p $DIR/lowerdir; see below
+	mkdir -p $DIR/upperdir
+	mkdir -p $DIR/workdir
+	mkdir -p $DIR/merged
+	# We make lowerdir the root dir, because at least for the test dev,
+	# it stands a chance of having content, making overlayfs a bit more
+	# interesting
+	mount -t overlay none $SELINUX_MOUNT_OPTIONS \
+		-o lowerdir=$DIR/		\
+		-o upperdir=$DIR/upperdir	\
+		-o workdir=$DIR/workdir		\
+		$DIR/merged
+}
+
+# Expects to get a $DIR which contains the /merged mountpoint
+_overlayfs_unmount()
+{
+	local DIR=$1
+	$UMOUNT_PROG $DIR/merged
+}
+
+
 _scratch_mount_options()
 {
     _scratch_options mount
@@ -210,10 +237,15 @@ _scratch_mount_options()
 _scratch_mount()
 {
     _mount -t $FSTYP `_scratch_mount_options $*`
+    if [ -n "$OVERLAYFS" ]; then
+	_overlayfs_mount $SCRATCH_MNT && SCRATCH_MNT=$SCRATCH_MNT/upperdir
+    fi
 }
 
 _scratch_unmount()
 {
+    SCRATCH_MNT=${SCRATCH_MNT%/upperdir}
+    _overlayfs_unmount $SCRATCH_MNT
     $UMOUNT_PROG $SCRATCH_DEV
 }
 
@@ -227,10 +259,15 @@ _test_mount()
 {
     _test_options mount
     _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
+    if [ -n "$OVERLAYFS" ]; then
+	_overlayfs_mount $TEST_DIR && TEST_DIR=$TEST_DIR/upperdir
+    fi
 }
 
 _test_unmount()
 {
+    TEST_DIR=${TEST_DIR%/upperdir}
+    _overlayfs_unmount $TEST_DIR
     $UMOUNT_PROG $TEST_DEV
 }
 
@@ -1679,6 +1716,9 @@ _umount_or_remount_ro()
     mountpoint=`_is_mounted $device`
 
     if [ $USE_REMOUNT -eq 0 ]; then
+        if [ -n "$OVERLAYFS" ]; then
+            _overlayfs_unmount $mountpoint
+        fi
         $UMOUNT_PROG $device
     else
         _remount $device ro
@@ -1704,6 +1744,9 @@ _mount_or_remount_rw()
             echo "!!! failed to remount $device on $mountpoint"
             return 0 # ok=0
         fi
+        if [ -n "$OVERLAYFS" ]; then
+            _overlayfs_mount $mountpoint
+        fi
     else
         _remount $device rw
     fi



  parent reply	other threads:[~2015-03-20 16:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 16:11 [PATCH 0/2] fstests: rudimentary overlayfs testing Eric Sandeen
2015-03-20 16:13 ` [PATCH 1/2] fstests: use mount/umount helpers everywhere Eric Sandeen
2015-03-20 18:56   ` Zach Brown
2015-03-20 18:59     ` Eric Sandeen
2015-03-20 20:01       ` Eric Sandeen
2015-03-20 21:01         ` Zach Brown
2015-03-20 16:22 ` Eric Sandeen [this message]
2015-03-20 18:57   ` [PATCH 2/2] fstests: Add overlayfs support Eric Sandeen
2015-04-02 14:41     ` Jan Tulak

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=550C4951.1030804@sandeen.net \
    --to=sandeen@sandeen.net \
    --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