From: Amir Goldstein <amir73il@gmail.com>
To: Zorro Lang <zlang@redhat.com>
Cc: Alexander Larsson <alexl@redhat.com>,
Miklos Szeredi <miklos@szeredi.hu>,
linux-unionfs@vger.kernel.org, fstests@vger.kernel.org,
Zorro Lang <zlang@kernel.org>
Subject: [PATCH] overlay: create helper _overlay_scratch_mount_opts()
Date: Wed, 6 Dec 2023 14:18:57 +0200 [thread overview]
Message-ID: <20231206121857.3873367-1-amir73il@gmail.com> (raw)
The new overlayfs mount options lowerdir+,datadir+ don't fit well
into any of the existing _overlay_scratch_mount* helpers.
Add this new helper to reduce a common pattern of custom mount options.
Suggested-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
Zorro,
Here is the cleanup patch that you suggested.
Note that tests overlay/083 and overlay/086 intentionally use
$MOUNT_PROG directly because some of the tests cases use escaping
character "\" and calling _overlay_mount_* helpers can loose the
special chars escaping when bash is evaluating the arguments.
Maybe it is solvabale, but that would be very high on the list of
things that I do not want to do.
Thanks,
Amir.
common/overlay | 8 +++++++-
tests/overlay/011 | 2 +-
tests/overlay/035 | 3 +--
tests/overlay/052 | 4 ++--
tests/overlay/053 | 4 ++--
tests/overlay/062 | 2 +-
tests/overlay/079 | 4 ++--
tests/overlay/085 | 4 ++--
8 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/common/overlay b/common/overlay
index ea1eb7b1..faa9339a 100644
--- a/common/overlay
+++ b/common/overlay
@@ -32,6 +32,12 @@ _overlay_mount_dirs()
$MOUNT_PROG -t overlay $diropts `_common_dev_mount_options $*`
}
+# Mount with mnt/dev of scratch mount and custom mount options
+_overlay_scratch_mount_opts()
+{
+ $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT $*
+}
+
# Mount with same options/mnt/dev of scratch mount, but optionally
# with different lower/upper/work dirs
_overlay_scratch_mount_dirs()
@@ -254,7 +260,7 @@ _require_scratch_overlay_lowerdir_add_layers()
local datadir="$OVL_BASE_SCRATCH_MNT/$OVL_LOWER"
_scratch_mkfs > /dev/null 2>&1
- $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+ _overlay_scratch_mount_opts \
-o"lowerdir+=$lowerdir,datadir+=$datadir" \
-o"redirect_dir=follow,metacopy=on" > /dev/null 2>&1 || \
_notrun "overlay lowerdir+,datadir+ not supported on ${SCRATCH_DEV}"
diff --git a/tests/overlay/011 b/tests/overlay/011
index 20812d88..09a950ba 100755
--- a/tests/overlay/011
+++ b/tests/overlay/011
@@ -37,7 +37,7 @@ $SETFATTR_PROG -n "trusted.overlay.opaque" -v "y" $upperdir/testdir
# $upperdir overlaid on top of $lowerdir, so that "trusted.overlay.opaque"
# xattr should be honored and should not be listed
# mount readonly, because there's no upper and workdir
-$MOUNT_PROG -t overlay -o ro -o lowerdir=$upperdir:$lowerdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
+_overlay_scratch_mount_opts -o ro -o lowerdir=$upperdir:$lowerdir
# Dump trusted.overlay xattr, we should not see the "opaque" xattr
_getfattr -d -m overlay $SCRATCH_MNT/testdir
diff --git a/tests/overlay/035 b/tests/overlay/035
index 8cd76979..f4c981ad 100755
--- a/tests/overlay/035
+++ b/tests/overlay/035
@@ -42,8 +42,7 @@ 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
+_overlay_scratch_mount_opts -o"lowerdir=$lowerdir2:$lowerdir1"
touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
$MOUNT_PROG -o remount,rw $SCRATCH_MNT 2>&1 | _filter_ro_mount
$UMOUNT_PROG $SCRATCH_MNT
diff --git a/tests/overlay/052 b/tests/overlay/052
index da8c645b..6abe2e01 100755
--- a/tests/overlay/052
+++ b/tests/overlay/052
@@ -133,7 +133,7 @@ unmount_dirs
# Check encode/decode/read of lower file handles on lower layers only r/o overlay.
# For non-upper overlay mount, nfs_export requires disabling redirect_dir.
-$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+_overlay_scratch_mount_opts \
-o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$middle:$lower
test_file_handles $SCRATCH_MNT/lowertestdir -rp
test_file_handles $SCRATCH_MNT/lowertestdir/subdir -rp
@@ -144,7 +144,7 @@ unmount_dirs
# Overlay lookup cannot follow the redirect from $upper/lowertestdir.new to
# $lower/lowertestdir. Instead, we mount an overlay subtree rooted at these
# directories.
-$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+_overlay_scratch_mount_opts \
-o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$upper/lowertestdir.new:$lower/lowertestdir
test_file_handles $SCRATCH_MNT -r
test_file_handles $SCRATCH_MNT/subdir -rp
diff --git a/tests/overlay/053 b/tests/overlay/053
index dfa29d01..cf94f930 100755
--- a/tests/overlay/053
+++ b/tests/overlay/053
@@ -162,7 +162,7 @@ unmount_dirs
# Check encode/decode/read of lower file handles on lower layers only r/o overlay.
# For non-upper overlay mount, nfs_export requires disabling redirect_dir.
-$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+_overlay_scratch_mount_opts \
-o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$middle:$lower
test_file_handles $SCRATCH_MNT/lowertestdir -rp
test_file_handles $SCRATCH_MNT/lowertestdir/subdir -rp
@@ -173,7 +173,7 @@ unmount_dirs
# Overlay lookup cannot follow the redirect from $upper/lowertestdir.new to
# $lower/lowertestdir. Instead, we mount an overlay subtree rooted at these
# directories.
-$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+_overlay_scratch_mount_opts \
-o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$upper/lowertestdir.new:$lower/lowertestdir
test_file_handles $SCRATCH_MNT -r
test_file_handles $SCRATCH_MNT/subdir -rp
diff --git a/tests/overlay/062 b/tests/overlay/062
index 04e13e46..a4e9560a 100755
--- a/tests/overlay/062
+++ b/tests/overlay/062
@@ -65,7 +65,7 @@ create_test_files $lowertestdir
$MOUNT_PROG --bind $lowertestdir $lowertestdir
# For non-upper overlay mount, nfs_export requires disabling redirect_dir.
-$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+_overlay_scratch_mount_opts \
-o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$lower:$lower2
# Decode an overlay directory file handle, whose underlying lower dir dentry
diff --git a/tests/overlay/079 b/tests/overlay/079
index 078ee816..f28fc313 100755
--- a/tests/overlay/079
+++ b/tests/overlay/079
@@ -141,7 +141,7 @@ mount_overlay()
{
local _lowerdir=$1 _datadir2=$2 _datadir=$3
- $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+ _overlay_scratch_mount_opts \
-o"lowerdir=$_lowerdir::$_datadir2::$_datadir" \
-o"upperdir=$upperdir,workdir=$workdir" \
-o redirect_dir=on,metacopy=on
@@ -151,7 +151,7 @@ mount_ro_overlay()
{
local _lowerdir=$1 _datadir2=$2 _datadir=$3
- $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+ _overlay_scratch_mount_opts \
-o"lowerdir=$_lowerdir::$_datadir2::$_datadir" \
-o redirect_dir=follow,metacopy=on
}
diff --git a/tests/overlay/085 b/tests/overlay/085
index 07a32c24..0f4e4b06 100755
--- a/tests/overlay/085
+++ b/tests/overlay/085
@@ -142,7 +142,7 @@ mount_overlay()
{
local _lowerdir=$1 _datadir2=$2 _datadir=$3
- $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+ _overlay_scratch_mount_opts \
-o"lowerdir+=$_lowerdir,datadir+=$_datadir2,datadir+=$_datadir" \
-o"upperdir=$upperdir,workdir=$workdir" \
-o redirect_dir=on,metacopy=on
@@ -152,7 +152,7 @@ mount_ro_overlay()
{
local _lowerdir=$1 _datadir2=$2 _datadir=$3
- $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
+ _overlay_scratch_mount_opts \
-o"lowerdir+=$_lowerdir,datadir+=$_datadir2,datadir+=$_datadir" \
-o redirect_dir=follow,metacopy=on
}
--
2.34.1
next reply other threads:[~2023-12-06 12:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 12:18 Amir Goldstein [this message]
2023-12-25 20:08 ` [PATCH] overlay: create helper _overlay_scratch_mount_opts() Amir Goldstein
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=20231206121857.3873367-1-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=alexl@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=zlang@kernel.org \
--cc=zlang@redhat.com \
/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