From: Vivek Goyal <vgoyal@redhat.com>
To: linux-unionfs@vger.kernel.org
Cc: amir73il@gmail.com, miklos@szeredi.hu, vgoyal@redhat.com
Subject: [PATCH 3/8] ovl: Provide a mount option metacopy=on/off for metadata copyup
Date: Fri, 6 Oct 2017 13:47:12 -0400 [thread overview]
Message-ID: <1507312037-30909-4-git-send-email-vgoyal@redhat.com> (raw)
In-Reply-To: <1507312037-30909-1-git-send-email-vgoyal@redhat.com>
By default metadata only copy up is disabled. Provide a mount option so
that users can choose one way or other.
Also metadata copyup is conditional on index=on. If index=off and user
specifies metacopy=on, it goes back to metacopy=off and a warning is
printed.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
fs/overlayfs/Kconfig | 9 +++++++++
fs/overlayfs/ovl_entry.h | 1 +
fs/overlayfs/super.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig
index cbfc196e5dc5..94d4c61719c8 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -43,3 +43,12 @@ config OVERLAY_FS_INDEX
outcomes. However, mounting the same overlay with an old kernel
read-write and then mounting it again with a new kernel, will have
unexpected results.
+
+config OVERLAY_FS_METACOPY
+ bool "Overlayfs: turn on metadata only copy up feature by default"
+ depends on OVERLAY_FS
+ depends on OVERLAY_FS_INDEX
+ help
+ If this config option is enabled then overlay filesystems will
+ copy up only metadata where appropriate and data copy up will
+ happen when a file is opended for WRITE operation.
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 878a750986dd..a49f61111c79 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 index;
+ bool metacopy;
};
/* private information held for overlayfs's superblock */
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index fd5ea4facc62..338fb0c3d345 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -39,6 +39,11 @@ module_param_named(index, ovl_index_def, bool, 0644);
MODULE_PARM_DESC(ovl_index_def,
"Default to on or off for the inodes index feature");
+static bool ovl_metacopy_def = IS_ENABLED(CONFIG_OVERLAY_FS_METACOPY);
+module_param_named(metacopy, ovl_metacopy_def, bool, 0644);
+MODULE_PARM_DESC(ovl_metacopy_def,
+ "Default to on or off for the metadata only copy up feature");
+
static void ovl_dentry_release(struct dentry *dentry)
{
struct ovl_entry *oe = dentry->d_fsdata;
@@ -302,6 +307,9 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
if (ufs->config.index != ovl_index_def)
seq_printf(m, ",index=%s",
ufs->config.index ? "on" : "off");
+ if (ufs->config.metacopy != ovl_metacopy_def)
+ seq_printf(m, ",metacopy=%s",
+ ufs->config.metacopy ? "on" : "off");
return 0;
}
@@ -335,6 +343,8 @@ enum {
OPT_REDIRECT_DIR_OFF,
OPT_INDEX_ON,
OPT_INDEX_OFF,
+ OPT_METACOPY_ON,
+ OPT_METACOPY_OFF,
OPT_ERR,
};
@@ -347,6 +357,8 @@ static const match_table_t ovl_tokens = {
{OPT_REDIRECT_DIR_OFF, "redirect_dir=off"},
{OPT_INDEX_ON, "index=on"},
{OPT_INDEX_OFF, "index=off"},
+ {OPT_METACOPY_ON, "metacopy=on"},
+ {OPT_METACOPY_OFF, "metacopy=off"},
{OPT_ERR, NULL}
};
@@ -427,6 +439,14 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
config->index = false;
break;
+ case OPT_METACOPY_ON:
+ config->metacopy = true;
+ break;
+
+ case OPT_METACOPY_OFF:
+ config->metacopy = false;
+ break;
+
default:
pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p);
return -EINVAL;
@@ -441,6 +461,12 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
config->workdir = NULL;
}
+ /* As of now metacopy=on is dependent on index=on */
+ if (config->metacopy && !config->index) {
+ pr_warn("overlayfs: can not enable metadata only copyup with index=off. Falling back to metacopy=off\n");
+ config->metacopy = false;
+ }
+
return 0;
}
@@ -846,6 +872,12 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
ufs->config.redirect_dir = ovl_redirect_dir_def;
ufs->config.index = ovl_index_def;
+ if (ovl_metacopy_def && !ovl_index_def) {
+ pr_warn("overlayfs: metadata copy up can not be enabled by default as index feature is not enabled by default.\n");
+ ovl_metacopy_def = false;
+ }
+ ufs->config.metacopy = ovl_metacopy_def;
+
err = ovl_parse_opt((char *) data, &ufs->config);
if (err)
goto out_free_config;
--
2.13.5
next prev parent reply other threads:[~2017-10-06 17:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 17:47 [RFC PATCH 0/8][V2] overlayfs: Delayed copy up of data Vivek Goyal
2017-10-06 17:47 ` [PATCH 1/8] ovl: ovl_check_setxattr() get rid of redundant -EOPNOTSUPP check Vivek Goyal
2017-10-06 17:47 ` [PATCH 2/8] ovl: During copy up, first copy up metadata and then data Vivek Goyal
2017-10-06 17:47 ` Vivek Goyal [this message]
2017-10-06 19:01 ` [PATCH 3/8] ovl: Provide a mount option metacopy=on/off for metadata copyup Amir Goldstein
2017-10-09 14:53 ` Vivek Goyal
2017-10-06 17:47 ` [PATCH 4/8] ovl: Copy up only metadata during copy up where it makes sense Vivek Goyal
2017-10-06 17:47 ` [PATCH 5/8] ovl: Set xattr OVL_XATTR_METACOPY on upper file Vivek Goyal
2017-10-06 17:47 ` [PATCH 6/8] ovl: Set OVL_METACOPY flag during ovl_lookup() Vivek Goyal
2017-10-06 17:47 ` [PATCH 7/8] ovl: Return lower dentry if only metadata copy up took place Vivek Goyal
2017-10-06 17:47 ` [PATCH 8/8] ovl: Fix ovl_getattr() to get number of blocks from lower Vivek Goyal
2017-10-06 18:58 ` Amir Goldstein
2017-10-06 19:01 ` Vivek Goyal
2017-10-06 19:09 ` Amir Goldstein
2017-10-09 14:45 ` Vivek Goyal
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=1507312037-30909-4-git-send-email-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;
as well as URLs for NNTP newsgroup(s).