All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Vivek Goyal <vgoyal@redhat.com>, linux-unionfs@vger.kernel.org
Subject: [PATCH v2 5/5] ovl: enforce 'strict' upper fs and feature requirements with strict=on
Date: Thu,  1 Nov 2018 02:48:13 +0200	[thread overview]
Message-ID: <20181101004813.31349-6-amir73il@gmail.com> (raw)
In-Reply-To: <20181101004813.31349-1-amir73il@gmail.com>

Overlayfs works sub-optimally with upper fs that has no
xattr/d_type/O_TMPFILE/RENAME_WHITEOUT support. We should basically
deprecate support for those filesystems, but so far, we only issue a
warning and don't fail the mount for the sake of backward compat.
Some features are already being disabled with no xattr support in upper
fs and with no file handle support in underlying fs.

when user asks explicitly via Kconfig/module/mount option to enable
strict feature requirements, we do not need to worry about backward
compatibility and we can fail the mount if upper fs is a sub-optimal
filesystem or if any of the feature requirements are not met.

So far, the 'strict' behavior was enabled implicitly for metacopy=on.
With that change, the 'strcit' behavior can be enabled regardless of
metacopy=on and can be relaxed even with metacopy, with mount options
"metacopy=on,strict=off" (order is important).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/overlayfs/Kconfig | 23 +++++++++++++++++++++++
 fs/overlayfs/super.c | 20 ++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig
index 2ef91be2a04e..620e379959c2 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -109,6 +109,7 @@ config OVERLAY_FS_METACOPY
 	bool "Overlayfs: turn on metadata only copy up feature by default"
 	depends on OVERLAY_FS
 	select OVERLAY_FS_REDIRECT_DIR
+	select OVERLAY_FS_STRICT
 	help
 	  If this config option is enabled then overlay filesystems will
 	  copy up only metadata where appropriate and data copy up will
@@ -122,3 +123,25 @@ config OVERLAY_FS_METACOPY
 	  that doesn't support this feature will have unexpected results.
 
 	  If unsure, say N.
+
+config OVERLAY_FS_STRICT
+	bool "Overlayfs: turn on strict requirements by default"
+	depends on OVERLAY_FS
+	help
+	  The overlayfs filesystem is fully functional and optimal when the
+	  underlying filesystems support extended attributes, d_type values
+	  in readdir, O_TMPFILE and RENAME_WHITEOUT.  In addition, some
+	  overlay filesystem features require that underlying filesystems
+	  support exporting NFS file handles.
+
+	  If this config option is enabled, then overlay filesystem mount
+	  will fail if any of the requirements from underlying filesystems
+	  are not met.  When strict requirements are enabled, overlay filesystem
+	  mount will also fail if any of the mount options are conflicting,
+	  for example: "nfs_export=on,metacopy=on".
+
+	  If this config option is enabled, it is still possible to turn off
+	  strict requirements globally with the "strict=off" module option or
+	  on a filesystem instance basis with the "strict=off" mount option.
+
+	  If unsure, say N.
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index d848112f4fc9..b6fd86b0a1c8 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -61,6 +61,11 @@ 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 bool ovl_strict_def = IS_ENABLED(CONFIG_OVERLAY_FS_STRICT);
+module_param_named(strict, ovl_strict_def, bool, 0644);
+MODULE_PARM_DESC(ovl_strict_def,
+		 "Default to on or off for strict feature requirements");
+
 static int ovl_feature_requires(struct ovl_config *config, const char *feature,
 				const char *requirement)
 {
@@ -401,6 +406,8 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
 	if (ofs->config.metacopy != ovl_metacopy_def)
 		seq_printf(m, ",metacopy=%s",
 			   ofs->config.metacopy ? "on" : "off");
+	if (ofs->config.strict != ovl_strict_def)
+		seq_printf(m, ",strict=%s", ofs->config.strict ? "on" : "off");
 	return 0;
 }
 
@@ -440,6 +447,8 @@ enum {
 	OPT_XINO_AUTO,
 	OPT_METACOPY_ON,
 	OPT_METACOPY_OFF,
+	OPT_STRICT_ON,
+	OPT_STRICT_OFF,
 	OPT_ERR,
 };
 
@@ -458,6 +467,8 @@ static const match_table_t ovl_tokens = {
 	{OPT_XINO_AUTO,			"xino=auto"},
 	{OPT_METACOPY_ON,		"metacopy=on"},
 	{OPT_METACOPY_OFF,		"metacopy=off"},
+	{OPT_STRICT_ON,			"strict=on"},
+	{OPT_STRICT_OFF,		"strict=off"},
 	{OPT_ERR,			NULL}
 };
 
@@ -594,6 +605,14 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
 			config->metacopy = false;
 			break;
 
+		case OPT_STRICT_ON:
+			config->strict = true;
+			break;
+
+		case OPT_STRICT_OFF:
+			config->strict = false;
+			break;
+
 		default:
 			pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p);
 			return -EINVAL;
@@ -1533,6 +1552,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 	ofs->config.nfs_export = ovl_nfs_export_def;
 	ofs->config.xino = ovl_xino_def();
 	ofs->config.metacopy = ovl_metacopy_def;
+	ofs->config.strict = ovl_strict_def;
 	err = ovl_parse_opt((char *) data, &ofs->config);
 	if (err)
 		goto out_err;
-- 
2.17.1

  parent reply	other threads:[~2018-11-01  9:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01  0:48 [PATCH v2 0/5] Overlayfs strict feature requirements Amir Goldstein
2018-11-01  0:48 ` [PATCH v2 1/5] ovl: return error on mount if metacopy cannot be enabled Amir Goldstein
2018-11-01 13:03   ` Vivek Goyal
2018-11-01 13:11     ` Miklos Szeredi
2018-11-01 20:41       ` Miklos Szeredi
2018-11-01 21:22         ` Amir Goldstein
2018-11-01 21:39           ` Miklos Szeredi
2018-11-05 12:57             ` Amir Goldstein
2018-11-07 11:26               ` Miklos Szeredi
2018-11-07 11:59                 ` Amir Goldstein
2018-11-07 12:09                   ` Miklos Szeredi
2018-11-01 21:25         ` Vivek Goyal
2018-11-01 21:35           ` Miklos Szeredi
2018-11-01  0:48 ` [PATCH v2 2/5] ovl: enforce 'strict' feature requirements with metacopy=on Amir Goldstein
2018-11-01  0:48 ` [PATCH v2 3/5] ovl: enforce 'strict' upper fs " Amir Goldstein
2018-11-01  0:48 ` [PATCH v2 4/5] ovl: enforce 'strict' unique uuid requirement " Amir Goldstein
2018-11-01  0:48 ` Amir Goldstein [this message]
2018-11-01  7:42 ` [PATCH v2 0/5] Overlayfs strict feature requirements Amir Goldstein
2018-11-01 13:16 ` Vivek Goyal
2018-11-01 13:42   ` Amir Goldstein
2018-11-01 14:02     ` 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=20181101004813.31349-6-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=vgoyal@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.