overlay mount tests
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
PATCH 1/5 overlay/014: remove unneeded require and include
--- tests/overlay/014 | 2 -- 1 file changed, 2 deletions(-)
tests/overlay/014 +0 -2
@@ -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
PATCH 2/5 overlay/014: fix test with inodes index enabled
In reply to Amir GoldsteinWhen 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
@@ -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
PATCH 3/5 overlay: create overlay/mount test group
In reply to Amir GoldsteinAdd 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
@@ -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
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
@@ -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
@@ -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
@@ -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
PATCH 5/5 overlay: test mount error cases with exclusive directories
In reply to Amir GoldsteinExpect 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
@@ -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
@@ -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
@@ -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
Re: [PATCH 4/5] overlay: test cases that force read-only mount
In reply to Amir GoldsteinQuoted 83 lines · Amir Goldstein
- Mount with no upper dir
- Failure to create work dirVerify that overlay is mounted read-only and that it cannot be remounted rw.
Signed-off-by Amir Goldstein <[email protected]>--- 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.outtests/overlay/035 new file +62
-0@@ -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 +exittests/overlay/035.out new file +5
-0@@ -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-protectedtests/overlay/group +1
-0@@ -37,3 +37,4 @@ 032 auto quick copyup hardlink 033 auto quick copyup hardlink 034 auto quick copyup hardlink +035 auto quick mountSignature · 1 line
2.7.4
Re: [PATCH 2/5] overlay/014: fix test with inodes index enabled
In reply to Amir GoldsteinQuoted 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.Signed-off-by Amir Goldstein <[email protected]>--- tests/overlay/014 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)tests/overlay/014 +0
-0
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 fsSignature · 1 line
2.7.4
Re: [PATCH 4/5] overlay: test cases that force read-only mount
In reply to Eryu GuanQuoted 88 lines · Eryu Guan
Quoted 87 lines · Amir Goldstein
- Mount with no upper dir
- Failure to create work dirVerify that overlay is mounted read-only and that it cannot be remounted rw.
Signed-off-by Amir Goldstein <[email protected]>--- 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.outtests/overlay/035 new file +66
-0@@ -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_remountrw 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.^^^^^^ workdirtests/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_scratchSame here.
Quoted 3 lines
Otherwise test looks good to me. I can fix them at commit time if you think
_scratch_remountis OK (it works for me in my test).
Sure thanks
Re: [PATCH 2/5] overlay/014: fix test with inodes index enabled
In reply to Eryu GuanQuoted 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.Signed-off-by Amir Goldstein <[email protected]>--- tests/overlay/014 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)tests/overlay/014 +0
-0tests/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 $workdirI 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
Re: [PATCH 5/5] overlay: test mount error cases with exclusive directories
In reply to Amir GoldsteinQuoted 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 mountSigned-off-by Amir Goldstein <[email protected]>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
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
Signed-off-by Amir Goldstein <[email protected]>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.
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 mountSigned-off-by Amir Goldstein <[email protected]>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
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 mountSigned-off-by Amir Goldstein <[email protected]>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.
PATCH v2 5/5 overlay: test mount error cases with exclusive directories
In reply to Amir GoldsteinOverlayfs 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
@@ -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
@@ -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
@@ -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