Skip to contentSkip to conversation

overlay mount tests

PATCH In review Amir Goldstein 2 participants 15 messages Jul 11, 2017 – Jul 12, 2017

lore
Share & tools
lore
#0 lore raw

cover overlay mount tests

Eryu,

overlayfs-next brings some changes of mount behavior described at [1]. Some of the changes depend on the new inodes index opt-in feature and some don't.

The new test overlay/035 checks for overlay mount behaviors, which are already present in upstream.

The new test overlay/036 checks for new overlay mount behaviors related to exclusivity of upper and work dirs among overlay mounts. This test is expected to fail on upstream kernel, but for a good reason, because the mount configurations that it tests (sharing upper dir among two overlay mounts) are not wise at all.

The old test overlay/014 is modified to work well with current upstream kernel as well as with overlayfs-next with inodes index enabled.

I have one more test for the overlay/mount group to test specific behavior with index=on, but holding it back until Miklos picks up a patch that fixes one of the mount verifications that is currently broken on overlayfs-next.

Thanks,
Amir.

[1] https://github.com/amir73il/linux/commit/9412812ef54861081904f24ddaf176b957b98d40

Amir Goldstein (5):
overlay/014: remove unneeded require and include overlay/014: fix test with inodes index enabled
overlay: create overlay/mount test group
overlay: test cases that force read-only mount
overlay: test mount error cases with exclusive directories

 tests/overlay/014     |  7 ++---
 tests/overlay/035     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/035.out |  5 +++
 tests/overlay/036     | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/036.out |  3 ++
 tests/overlay/group   |  6 ++--
 6 files changed, 184 insertions(+), 6 deletions(-)
 create mode 100755 tests/overlay/035
 create mode 100644 tests/overlay/035.out
 create mode 100755 tests/overlay/036
 create mode 100644 tests/overlay/036.out
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 overlay/014: remove unneeded require and include

---
 tests/overlay/014 | 2 --
 1 file changed, 2 deletions(-)
tests/overlay/014 +0 -2
index 653b7d6..40d10f5 100755
@@ -46,7 +46,6 @@ _cleanup()
 # get standard environment, filters and checks
 . ./common/rc
 . ./common/filter
-. ./common/attr
 
 # remove previous $seqres.full before test
 rm -f $seqres.full
@@ -54,7 +53,6 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_test
 _require_scratch
 
 # Remove all files from previous tests
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/5 overlay/014: fix test with inodes index enabled

In reply to Amir Goldstein

When overlayfs is configured with CONFIG_OVERLAY_FS_INDEX=y, workdir from previous overlay mount cannot be reused in a new overlay mount that uses a different upper dir.

Fix the test to use a different workdir when mounting with a different upper dir.

This change has not effect on older kernels and overlay configured without CONFIG_OVERLAY_FS_INDEX.

---
 tests/overlay/014 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/overlay/014 +3 -2
index 40d10f5..6a551b7 100755
@@ -63,12 +63,13 @@ lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
 upperdir=$OVL_BASE_SCRATCH_MNT/upper
 workdir=$OVL_BASE_SCRATCH_MNT/workdir
-mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
+workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
+mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
 mkdir -p $lowerdir1/testdir/d
 
 # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir,
 # make testdir on $lowerdir2 opaque
-_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir2 $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
 rm -rf $SCRATCH_MNT/testdir
 mkdir -p $SCRATCH_MNT/testdir/visibledir
 # unmount overlayfs but not base fs
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH 2/5] overlay/014: fix test with inodes index enabled

Quoted 20 lines · Amir Goldstein

When overlayfs is configured with CONFIG_OVERLAY_FS_INDEX=y, workdir from previous overlay mount cannot be reused in a new overlay mount that uses a different upper dir.

Fix the test to use a different workdir when mounting with a different upper dir.

This change has not effect on older kernels and overlay configured without CONFIG_OVERLAY_FS_INDEX.

---
 tests/overlay/014 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/overlay/014 +0 -0
index 40d10f5..6a551b7 100755

tests/overlay/014 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1 · line 66

Quoted 4 lines
tests/overlay/014 +0 -1
@@ -63,12 +63,13 @@ lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
 upperdir=$OVL_BASE_SCRATCH_MNT/upper
 workdir=$OVL_BASE_SCRATCH_MNT/workdir
-mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir

I added some comments before creating workdir2 (mostly copied from your overlay document patch), please let me know if you have different thoughts.

+# When overlay inode index feature is enabled, using an upper layer path and/or +# a workdir path that are already used by another overlay mount is not allowed +# and will fail with EBUSY, so create another workdir for the second overlay +# mount

tests/overlay/014 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1 · line 68

Quoted 3 lines
tests/overlay/014 +2 -0
+workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
+mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
 mkdir -p $lowerdir1/testdir/d

Thanks,
Eryu

Quoted 11 lines
tests/overlay/014 +1 -1
 # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir,
 # make testdir on $lowerdir2 opaque
-_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir2 $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
 rm -rf $SCRATCH_MNT/testdir
 mkdir -p $SCRATCH_MNT/testdir/visibledir
 # unmount overlayfs but not base fs
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH 2/5] overlay/014: fix test with inodes index enabled

Quoted 34 lines · Eryu Guan
Quoted 20 lines · Amir Goldstein

When overlayfs is configured with CONFIG_OVERLAY_FS_INDEX=y, workdir from previous overlay mount cannot be reused in a new overlay mount that uses a different upper dir.

Fix the test to use a different workdir when mounting with a different upper dir.

This change has not effect on older kernels and overlay configured without CONFIG_OVERLAY_FS_INDEX.

---
 tests/overlay/014 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/overlay/014 +0 -0
index 40d10f5..6a551b7 100755

tests/overlay/014 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1 · line 66

Quoted 4 lines
tests/overlay/014 +0 -1
@@ -63,12 +63,13 @@ lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
 upperdir=$OVL_BASE_SCRATCH_MNT/upper
 workdir=$OVL_BASE_SCRATCH_MNT/workdir
-mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir

I added some comments before creating workdir2 (mostly copied from your overlay document patch), please let me know if you have different thoughts.

(quoted diff) +4 -0
+# When overlay inode index feature is enabled, using an upper layer path and/or
+# a workdir path that are already used by another overlay mount is not allowed
+# and will fail with EBUSY, so create another workdir for the second overlay
+# mount
Quoted 4 lines

tests/overlay/014 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1 · line 68

Quoted 3 lines
tests/overlay/014 +2 -0
+workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
+mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
 mkdir -p $lowerdir1/testdir/d

Looks good to me.
Thanks

#5 lore raw

PATCH 3/5 overlay: create overlay/mount test group

In reply to Amir Goldstein

Add tests overlay/022 and overlay/024 to overlay/mount test group. These tests check behavior of overlay mount cases.

---
 tests/overlay/group | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/overlay/group +2 -2
index b55ed0c..356a322 100644
@@ -24,9 +24,9 @@
 019 auto stress
 020 auto quick copyup perms
 021 auto quick copyup
-022 auto quick
+022 auto quick mount
 023 auto quick attr
-024 auto quick
+024 auto quick mount
 025 auto quick attr
 026 auto attr quick
 027 auto quick perms
Signature · 1 line
2.7.4
#6 lore raw

PATCH 4/5 overlay: test cases that force read-only mount

In reply to Amir Goldstein

- Mount with no upper dir
- Failure to create work dir

Verify that overlay is mounted read-only and that it cannot be remounted rw.

---
 tests/overlay/035     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/035.out |  5 +++
 tests/overlay/group   |  1 +
 3 files changed, 93 insertions(+)
 create mode 100755 tests/overlay/035
 create mode 100644 tests/overlay/035.out
tests/overlay/035 new file +87 -0
new file mode 100755
index 0000000..e3fbed7
@@ -0,0 +1,87 @@
+#! /bin/bash
+# FS QA Test 035
+#
+# Test cases that force read-only mount
+#
+# - No upper dir
+# - Failure to create work dir
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# 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 /
+	$CHATTR_PROG -i $workdir
+	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
+_require_scratch
+_require_chattr i
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create multiple lowerdirs and upperdir, workdir
+lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
+
+# Mount overlay with lower layers only.
+# Verify that overlay is mounted read-only and that it cannot be remounted rw.
+$MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \
+			$OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Make workdir immutable to prevent workdir re-create on mount
+$CHATTR_PROG +i $workdir
+
+# Mount overlay with upper and wordir and expect failure to re-create workdir.
+# Verify that overlay is mounted read-only and that it cannot be remounted rw.
+_overlay_mount_dirs $lowerdir2 $upperdir $workdir \
+		    $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
+$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/overlay/035.out new file +5 -0
new file mode 100644
index 0000000..5a5f677
@@ -0,0 +1,5 @@
+QA output created by 035
+touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system
+mount: cannot remount SCRATCH_DEV read-write, is write-protected
+touch: cannot touch 'SCRATCH_MNT/bar': Read-only file system
+mount: cannot remount SCRATCH_DEV read-write, is write-protected
tests/overlay/group +1 -0
index 356a322..87e3aaf 100644
@@ -37,3 +37,4 @@
 032 auto quick copyup hardlink
 033 auto quick copyup hardlink
 034 auto quick copyup hardlink
+035 auto quick mount
Signature · 1 line
2.7.4
#7 lore raw

Re: [PATCH 4/5] overlay: test cases that force read-only mount

Quoted 83 lines · Amir Goldstein

- Mount with no upper dir
- Failure to create work dir

Verify that overlay is mounted read-only and that it cannot be remounted rw.

---
 tests/overlay/035     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/035.out |  5 +++
 tests/overlay/group   |  1 +
 3 files changed, 93 insertions(+)
 create mode 100755 tests/overlay/035
 create mode 100644 tests/overlay/035.out
tests/overlay/035 new file +62 -0
new file mode 100755
index 0000000..e3fbed7
@@ -0,0 +1,87 @@
+#! /bin/bash
+# FS QA Test 035
+#
+# Test cases that force read-only mount
+#
+# - No upper dir
+# - Failure to create work dir
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# 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 /
+	$CHATTR_PROG -i $workdir
+	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
+_require_scratch
+_require_chattr i
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create multiple lowerdirs and upperdir, workdir
+lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2

tests/overlay/035 line 72

Quoted 10 lines
tests/overlay/035 new file +10 -0
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
+
+# Mount overlay with lower layers only.
+# Verify that overlay is mounted read-only and that it cannot be remounted rw.
+$MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \
+			$OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch

_scratch_remount rw 2>&1 | _filter_scratch ?

tests/overlay/035 line 78

Quoted 6 lines
tests/overlay/035 new file +6 -0
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Make workdir immutable to prevent workdir re-create on mount
+$CHATTR_PROG +i $workdir
+
+# Mount overlay with upper and wordir and expect failure to re-create workdir.
                                  ^^^^^^ workdir

tests/overlay/035 line 83

Quoted 5 lines
tests/overlay/035 new file +5 -0
+# Verify that overlay is mounted read-only and that it cannot be remounted rw.
+_overlay_mount_dirs $lowerdir2 $upperdir $workdir \
+		    $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
+$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch

Same here.

Otherwise test looks good to me. I can fix them at commit time if you think _scratch_remount is OK (it works for me in my test).

Thanks,
Eryu

Quoted 27 lines
tests/overlay/035 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/overlay/035.out new file +5 -0
new file mode 100644
index 0000000..5a5f677
@@ -0,0 +1,5 @@
+QA output created by 035
+touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system
+mount: cannot remount SCRATCH_DEV read-write, is write-protected
+touch: cannot touch 'SCRATCH_MNT/bar': Read-only file system
+mount: cannot remount SCRATCH_DEV read-write, is write-protected
tests/overlay/group +1 -0
index 356a322..87e3aaf 100644
@@ -37,3 +37,4 @@
 032 auto quick copyup hardlink
 033 auto quick copyup hardlink
 034 auto quick copyup hardlink
+035 auto quick mount
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH 4/5] overlay: test cases that force read-only mount

Quoted 88 lines · Eryu Guan
Quoted 87 lines · Amir Goldstein

- Mount with no upper dir
- Failure to create work dir

Verify that overlay is mounted read-only and that it cannot be remounted rw.

---
 tests/overlay/035     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/035.out |  5 +++
 tests/overlay/group   |  1 +
 3 files changed, 93 insertions(+)
 create mode 100755 tests/overlay/035
 create mode 100644 tests/overlay/035.out
tests/overlay/035 new file +66 -0
new file mode 100755
index 0000000..e3fbed7
@@ -0,0 +1,87 @@
+#! /bin/bash
+# FS QA Test 035
+#
+# Test cases that force read-only mount
+#
+# - No upper dir
+# - Failure to create work dir
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# 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 /
+     $CHATTR_PROG -i $workdir
+     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
+_require_scratch
+_require_chattr i
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create multiple lowerdirs and upperdir, workdir
+lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
+
Quoted 8 lines

tests/overlay/035 line 72

Quoted 6 lines
tests/overlay/035 new file +6 -0
+# Mount overlay with lower layers only.
+# Verify that overlay is mounted read-only and that it cannot be remounted rw.
+$MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \
+                     $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch

_scratch_remount rw 2>&1 | _filter_scratch ?

yes. that's better.

Quoted 16 lines

tests/overlay/035 line 78

Quoted 7 lines
tests/overlay/035 new file +6 -0
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Make workdir immutable to prevent workdir re-create on mount
+$CHATTR_PROG +i $workdir
+
+# Mount overlay with upper and wordir and expect failure to re-create workdir.
                                  ^^^^^^ workdir

tests/overlay/035 line 83

Quoted 5 lines
tests/overlay/035 new file +5 -0
+# Verify that overlay is mounted read-only and that it cannot be remounted rw.
+_overlay_mount_dirs $lowerdir2 $upperdir $workdir \
+                 $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
+$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch

Same here.

Quoted 3 lines

Otherwise test looks good to me. I can fix them at commit time if you think _scratch_remount is OK (it works for me in my test).

Sure thanks

#9 lore raw

PATCH 5/5 overlay: test mount error cases with exclusive directories

In reply to Amir Goldstein

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

---
 tests/overlay/036     | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/036.out |  3 ++
 tests/overlay/group   |  1 +
 3 files changed, 86 insertions(+)
 create mode 100755 tests/overlay/036
 create mode 100644 tests/overlay/036.out
tests/overlay/036 new file +82 -0
new file mode 100755
index 0000000..4100b80
@@ -0,0 +1,82 @@
+#! /bin/bash
+# FS QA Test 036
+#
+# Test mount error cases with exclusive directories
+#
+# - Upper dir is in-use by another overlay mount
+# - Work dir is in-use by another overlay mount
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# 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.*
+	# unmount the two extra mounts in case they did not fail
+	$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+	$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+}
+
+# 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
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create multiple lowerdirs, upperdirs and workdirs
+lowerdir=$OVL_BASE_SCRATCH_MNT/lower
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+upperdir2=$OVL_BASE_SCRATCH_MNT/upper2
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
+mkdir -p $lowerdir $lowerdir2 $upperdir $upperdir2 $workdir $workdir2
+
+# Mount overlay with lowerdir, upperdir, workdir
+_overlay_mount_dirs $lowerdir $upperdir $workdir \
+		    overlay1 $SCRATCH_MNT
+# Try to mount another overlay with the same upperdir - expect EBUSY
+_overlay_mount_dirs $lowerdir2 $upperdir $workdir2 \
+		    overlay2 $SCRATCH_MNT 2>&1 | _filter_scratch
+# Try to mount another overlay with the same workdir - expect EBUSY
+_overlay_mount_dirs $lowerdir2 $upperdir2 $workdir \
+		    overlay3 $SCRATCH_MNT 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/overlay/036.out new file +3 -0
new file mode 100644
index 0000000..5174611
@@ -0,0 +1,3 @@
+QA output created by 036
+mount: overlay2 is already mounted or SCRATCH_MNT busy
+mount: overlay3 is already mounted or SCRATCH_MNT busy
tests/overlay/group +1 -0
index 87e3aaf..4cc1d74 100644
@@ -38,3 +38,4 @@
 033 auto quick copyup hardlink
 034 auto quick copyup hardlink
 035 auto quick mount
+036 auto quick mount
Signature · 1 line
2.7.4
#10 lore raw

Re: [PATCH 5/5] overlay: test mount error cases with exclusive directories

Quoted 7 lines · Amir Goldstein

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

From patch 2/5, seems this behavior requires inode index feature to be

enabled, and now test fails on old kernels for me. Is this expected?

Thanks,
Eryu

#11 lore raw

Re: [PATCH 5/5] overlay: test mount error cases with exclusive directories

Quoted 5 lines · Eryu Guan
Quoted 4 lines · Amir Goldstein

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

Quoted 7 lines
Quoted 1 line

From patch 2/5, seems this behavior requires inode index feature to be enabled, and now test fails on old kernels for me. Is this expected?

From my cover letter:

"The new test overlay/036 checks for new overlay mount behaviors related to exclusivity of upper and work dirs among overlay mounts. This test is expected to fail on upstream kernel, but for a good reason, because the mount configurations that it tests (sharing upper dir among two overlay mounts) are not wise at all."

So the answer is yes, this is expected and also does not depend on index feature.

I know this is a bit confusing, but inode index enforces that 2 *subsequent* overlay
mount don't reuse the same upper/work dir with different lower/upper. The test that checks this behavior is overlay/037, still on my overlayfs-devel branch.

overlay/036 verifies that 2 *concurrent* overlay mount don't reuse the same upper/work dir. The is enforced by overlayfs-next regardless on index feature. A setup like this will cause troubles in old kernel as well, but mount will not detect it.

Amir.

#12 lore raw

Re: [PATCH 5/5] overlay: test mount error cases with exclusive directories

Quoted 19 lines · Amir Goldstein
Quoted 10 lines · Eryu Guan
Quoted 5 lines · Amir Goldstein

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

From patch 2/5, seems this behavior requires inode index feature to be enabled, and now test fails on old kernels for me. Is this expected?

From my cover letter:
"The new test overlay/036 checks for new overlay mount behaviors related to exclusivity of upper and work dirs among overlay mounts. This test is expected to fail on upstream kernel, but for a good reason, because the mount configurations that it tests (sharing upper dir among two overlay mounts) are not wise at all."

Quoted 2 lines

So the answer is yes, this is expected and also does not depend on index feature.

I usually read the cover letter (I saved it in my 'review' mailbox along with patches to review), but somehow I forgot about it this time..

Quoted 11 lines

I know this is a bit confusing, but inode index enforces that 2 *subsequent* overlay
mount don't reuse the same upper/work dir with different lower/upper. The test that checks this behavior is overlay/037, still on my overlayfs-devel branch.

overlay/036 verifies that 2 *concurrent* overlay mount don't reuse the same upper/work dir. The is enforced by overlayfs-next regardless on index feature. A setup like this will cause troubles in old kernel as well, but mount will not detect it.

Thanks for the explanation! The commit log and test description don't provide enough background information. If you could resend with detailed explanation on the test, that'd be great!

Thanks,
Eryu

#13 lore raw

Re: [PATCH 5/5] overlay: test mount error cases with exclusive directories

Quoted 33 lines · Eryu Guan
Quoted 19 lines · Amir Goldstein
Quoted 10 lines · Eryu Guan
Quoted 5 lines · Amir Goldstein

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

From patch 2/5, seems this behavior requires inode index feature to be enabled, and now test fails on old kernels for me. Is this expected?

From my cover letter:
"The new test overlay/036 checks for new overlay mount behaviors related to exclusivity of upper and work dirs among overlay mounts. This test is expected to fail on upstream kernel, but for a good reason, because the mount configurations that it tests (sharing upper dir among two overlay mounts) are not wise at all."

Quoted 2 lines

So the answer is yes, this is expected and also does not depend on index feature.

I usually read the cover letter (I saved it in my 'review' mailbox along with patches to review), but somehow I forgot about it this time..

Quoted 7 lines

I know this is a bit confusing, but inode index enforces that 2 *subsequent* overlay
mount don't reuse the same upper/work dir with different lower/upper. The test that checks this behavior is overlay/037, still on my overlayfs-devel branch.

Quoted 9 lines
Quoted 4 lines

overlay/036 verifies that 2 *concurrent* overlay mount don't reuse the same upper/work dir. The is enforced by overlayfs-next regardless on index feature. A setup like this will cause troubles in old kernel as well, but mount will not detect it.

Thanks for the explanation! The commit log and test description don't provide enough background information. If you could resend with detailed explanation on the test, that'd be great!

No problem.

#14 lore raw

PATCH v2 5/5 overlay: test mount error cases with exclusive directories

In reply to Amir Goldstein

Overlayfs is often used to mount several mounts that share a single lower dir, but every overlayfs mount should have its own private upperdir and private workdir.

Overlayfs mount on kernel <= v4.12 does not check if upper/work dirs are currently in-use by another overlayfs mount on the system and bad things can happen with such configuration.

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

This test does not depend on the overlay index feature.

---
 tests/overlay/036     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/036.out |  3 ++
 tests/overlay/group   |  1 +
 3 files changed, 95 insertions(+)
 create mode 100755 tests/overlay/036
 create mode 100644 tests/overlay/036.out
tests/overlay/036 new file +91 -0
new file mode 100755
index 0000000..d44efc1
@@ -0,0 +1,91 @@
+#! /bin/bash
+# FS QA Test 036
+#
+# Test mount error cases with exclusive directories
+#
+# Overlayfs is often used to mount several mounts that share a single
+# lower dir, but every overlayfs mount should have its own private
+# upperdir and private workdir.
+#
+# Overlayfs mount on kernel <= v4.12 does not check if upper/work dirs
+# are currently in-use by another overlayfs mount on the system and bad
+# things can happen with such configuration.
+#
+# Expect EBUSY when trying to mount overlay when:
+# - Upper dir is in-use by another overlay mount
+# - Work dir is in-use by another overlay mount
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# 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.*
+	# unmount the two extra mounts in case they did not fail
+	$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+	$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+}
+
+# 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
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create multiple lowerdirs, upperdirs and workdirs
+lowerdir=$OVL_BASE_SCRATCH_MNT/lower
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+upperdir2=$OVL_BASE_SCRATCH_MNT/upper2
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
+mkdir -p $lowerdir $lowerdir2 $upperdir $upperdir2 $workdir $workdir2
+
+# Mount overlay with lowerdir, upperdir, workdir
+_overlay_mount_dirs $lowerdir $upperdir $workdir \
+		    overlay1 $SCRATCH_MNT
+# Try to mount another overlay with the same upperdir - expect EBUSY
+_overlay_mount_dirs $lowerdir2 $upperdir $workdir2 \
+		    overlay2 $SCRATCH_MNT 2>&1 | _filter_scratch
+# Try to mount another overlay with the same workdir - expect EBUSY
+_overlay_mount_dirs $lowerdir2 $upperdir2 $workdir \
+		    overlay3 $SCRATCH_MNT 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/overlay/036.out new file +3 -0
new file mode 100644
index 0000000..5174611
@@ -0,0 +1,3 @@
+QA output created by 036
+mount: overlay2 is already mounted or SCRATCH_MNT busy
+mount: overlay3 is already mounted or SCRATCH_MNT busy
tests/overlay/group +1 -0
index 87e3aaf..4cc1d74 100644
@@ -38,3 +38,4 @@
 033 auto quick copyup hardlink
 034 auto quick copyup hardlink
 035 auto quick mount
+036 auto quick mount
Signature · 1 line
2.7.4