From: Vivek Goyal <vgoyal@redhat.com>
To: linux-unionfs@vger.kernel.org
Cc: miklos@szeredi.hu, amir73il@gmail.com, vgoyal@redhat.com
Subject: [PATCH v2 2/2] overlayfs: Enable redirect_dir automatically if metacopy=on needs it
Date: Tue, 30 Oct 2018 16:26:42 -0400 [thread overview]
Message-ID: <20181030202642.5025-3-vgoyal@redhat.com> (raw)
In-Reply-To: <20181030202642.5025-1-vgoyal@redhat.com>
metacopy feature requires either redirect_dir=on or redirect_dir=follow
depending on if upper directory is present or not. Enable this feature
automatically, if needed. It can't be enabled automatically enabled if
user has disabled this feature explicitly using redirect_dir mount option.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
fs/overlayfs/ovl_entry.h | 1 +
fs/overlayfs/super.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 23bd7507bf2c..8667ef60dfa9 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -15,6 +15,7 @@ struct ovl_config {
bool default_permissions;
bool redirect_dir;
bool redirect_follow;
+ bool redirect_enforce;
const char *redirect_mode;
bool index;
bool nfs_export;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 19f50783d92d..0d6d69c7012a 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -468,12 +468,29 @@ static int ovl_parse_redirect_mode(struct ovl_config *config, const char *mode)
return 0;
}
+static bool ovl_enable_redirect(struct ovl_config *config, bool follow) {
+ if (config->redirect_enforce)
+ return false;
+
+ config->redirect_follow = true;
+ if (!follow) {
+ config->redirect_dir = true;
+ pr_info("overlayfs: Enabling \"redirect_dir=on\".\n");
+ } else {
+ pr_info("overlayfs: Enabling \"redirect_dir=follow\".\n");
+ }
+ return true;
+}
+
static int ovl_process_metacopy_dependency(struct ovl_config *config)
{
if (!config->metacopy)
return 0;
if (config->upperdir && !config->redirect_dir) {
+ if (ovl_enable_redirect(config, false))
+ return 0;
+
/* metacopy feature with upper requires redirect_dir=on */
if (!config->metacopy_enforce) {
pr_warn("overlayfs: metadata only copy up requires"
@@ -486,6 +503,9 @@ static int ovl_process_metacopy_dependency(struct ovl_config *config)
" \"redirect_dir=on\".\n");
return -EINVAL;
} else if (!config->upperdir && !config->redirect_follow) {
+ if (ovl_enable_redirect(config, true))
+ return 0;
+
if (!config->metacopy_enforce) {
pr_warn("overlayfs: metadata only copy up requires"
" either \"redirect_dir=follow\" or"
@@ -551,6 +571,7 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
config->redirect_mode = match_strdup(&args[0]);
if (!config->redirect_mode)
return -ENOMEM;
+ config->redirect_enforce = true;
break;
case OPT_INDEX_ON:
--
2.13.6
prev parent reply other threads:[~2018-10-30 20:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 20:26 [PATCH v2 0/2] overlayfs: Handle metacopy mount option better Vivek Goyal
2018-10-30 20:26 ` [PATCH v2 1/2] overlayfs: Return error if metadata only copy-up can't be enabled Vivek Goyal
2018-10-30 21:16 ` Amir Goldstein
2018-10-30 20:26 ` Vivek Goyal [this message]
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=20181030202642.5025-3-vgoyal@redhat.com \
--to=vgoyal@redhat.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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