aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2018-03-14 09:16:18 -0400
committerEryu Guan <guaneryu@gmail.com>2018-03-16 16:30:52 +0800
commit1afc31f99dd686ae2b37c940f4915453eb2ff4b9 (patch)
treec3d52455475fd7a210e087bc38e22580d55c0bec
parent2fcd134d393972815739e8c025e45e20f7a4ebe7 (diff)
downloadxfstests-1afc31f99dd686ae2b37c940f4915453eb2ff4b9.tar.gz
overlay: Absolute redirect should be followed even if ancestor is opaque
Typically, when following absolute redirect, if an opauqe dentry is found, lookup in further lower directories is stopped. But if a child dentry has another absolute redirect, then lookup in further lower layers should continue. Say, following is example setup. upper: /redirect (redirect=/a/b/c) lower1: /a/[b]/c ([b] is opaque) (c has absolute redirect=/a/b/d/) lower0: /a/b/d/foo "redirect" directory in upper should merge with lower1:/a/b/c/ and lower0:/a/b/d/, despite lower1:/a/b/ being opaque. This example and kernel fix has come from Amir Goldstein. I am just putting a test for it to make sure its not broken down the line. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-xtests/overlay/057103
-rw-r--r--tests/overlay/057.out3
-rw-r--r--tests/overlay/group1
3 files changed, 107 insertions, 0 deletions
diff --git a/tests/overlay/057 b/tests/overlay/057
new file mode 100755
index 0000000000..75b907ae92
--- /dev/null
+++ b/tests/overlay/057
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 057
+#
+# Test absolute redirect is followed even if ancestor is opaque
+#
+# Typically, when following absolute redirect, if an opauqe dentry is
+# found, lookup in further lower directories is stopped. But if a
+# child dentry has another absolute redirect, then lookup in further
+# lower layers should continue.
+#
+# Say, following is example setup.
+# upper: /redirect (redirect=/a/b/c)
+# lower1: /a/[b]/c ([b] is opaque) (c has absolute redirect=/a/b/d/)
+# lower0: /a/b/d/foo
+#
+# "redirect" directory in upper should merge with lower1:/a/b/c/ and
+# lower0:/a/b/d/, despite lower1:/a/b/ being opaque.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
+# Author: Vivek Goyal <vgoyal@redhat.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+# We use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
+_require_scratch_overlay_features redirect_dir
+
+# remove all files from previous tests
+_scratch_mkfs
+
+# Create test directories
+lowerdir=$OVL_BASE_SCRATCH_MNT/lower
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
+
+mkdir -p $lowerdir $lowerdir2 $upperdir $workdir $workdir2
+mkdir -p $lowerdir/origin
+touch $lowerdir/origin/foo
+_overlay_scratch_mount_dirs $lowerdir $lowerdir2 $workdir2 -o redirect_dir=on
+
+# Create opaque parent with absolute redirect child in middle layer
+mkdir $SCRATCH_MNT/pure
+mv $SCRATCH_MNT/origin $SCRATCH_MNT/pure/redirect
+$UMOUNT_PROG $SCRATCH_MNT
+_overlay_scratch_mount_dirs $lowerdir2:$lowerdir $upperdir $workdir -o redirect_dir=on
+mv $SCRATCH_MNT/pure/redirect $SCRATCH_MNT/redirect
+# List content of renamed merge dir before mount cycle
+ls $SCRATCH_MNT/redirect/
+
+# Verify that redirects are followed by listing content of renamed merge dir
+# after mount cycle
+$UMOUNT_PROG $SCRATCH_MNT
+_overlay_scratch_mount_dirs $lowerdir2:$lowerdir $upperdir $workdir -o redirect_dir=on
+ls $SCRATCH_MNT/redirect/
+
+# check overlayfs
+_overlay_check_scratch_dirs "$lowerdir2:$lowerdir" $upperdir $workdir -o redirect_dir=on
+
+# success, all done
+status=0
+exit
diff --git a/tests/overlay/057.out b/tests/overlay/057.out
new file mode 100644
index 0000000000..b3b4017d32
--- /dev/null
+++ b/tests/overlay/057.out
@@ -0,0 +1,3 @@
+QA output created by 057
+foo
+foo
diff --git a/tests/overlay/group b/tests/overlay/group
index 65f1fe6397..c49ae3aa9d 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -59,3 +59,4 @@
054 auto quick copyup redirect exportfs
055 auto quick copyup redirect exportfs nonsamefs
056 auto quick fsck
+057 auto quick redirect