[Devel] [PATCH RH8 1/4] Revert "ovl: introduce new "index=nouuid" option for inodes index feature"
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Mon Aug 9 17:34:26 MSK 2021
This reverts commit 2ebaa4caa924185b1d7490a3f18691eec3e17ea2.
We want to switch to mainstream "uuid=off" variant.
https://jira.sw.ru/browse/PSBM-123536
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
.../kernel-4.18.0-x86_64-KVM-minimal.config | 1 -
configs/kernel-4.18.0-x86_64-debug.config | 1 -
configs/kernel-4.18.0-x86_64.config | 1 -
fs/overlayfs/Kconfig | 16 -----
fs/overlayfs/export.c | 6 +-
fs/overlayfs/namei.c | 35 ++++-------
fs/overlayfs/overlayfs.h | 23 ++------
fs/overlayfs/ovl_entry.h | 2 +-
fs/overlayfs/super.c | 59 +++++--------------
9 files changed, 36 insertions(+), 108 deletions(-)
diff --git a/configs/kernel-4.18.0-x86_64-KVM-minimal.config b/configs/kernel-4.18.0-x86_64-KVM-minimal.config
index 658e6967f59e..ee046f4ae07e 100644
--- a/configs/kernel-4.18.0-x86_64-KVM-minimal.config
+++ b/configs/kernel-4.18.0-x86_64-KVM-minimal.config
@@ -4162,7 +4162,6 @@ CONFIG_OVERLAY_FS=y
# CONFIG_OVERLAY_FS_REDIRECT_DIR is not set
CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW=y
CONFIG_OVERLAY_FS_INDEX=y
-CONFIG_OVERLAY_FS_INDEX_NOUUID=y
CONFIG_OVERLAY_FS_NFS_EXPORT=y
# CONFIG_OVERLAY_FS_XINO_AUTO is not set
# CONFIG_OVERLAY_FS_METACOPY is not set
diff --git a/configs/kernel-4.18.0-x86_64-debug.config b/configs/kernel-4.18.0-x86_64-debug.config
index b88049916d65..cbb51c5c8ae1 100644
--- a/configs/kernel-4.18.0-x86_64-debug.config
+++ b/configs/kernel-4.18.0-x86_64-debug.config
@@ -7948,7 +7948,6 @@ CONFIG_BLK_DEV_CBT=y
CONFIG_DM_PUSH_BACKUP=m
CONFIG_OVERLAY_FS_DYNAMIC_RESOLVE_PATH_OPTIONS=y
CONFIG_OVERLAY_FS_PATH_OPTIONS_MNT_ID=y
-CONFIG_OVERLAY_FS_INDEX_NOUUID=y
# CONFIG_FUSE_KIO_NOOP is not set
# CONFIG_FUSE_KIO_NULLIO is not set
diff --git a/configs/kernel-4.18.0-x86_64.config b/configs/kernel-4.18.0-x86_64.config
index e4578a6a846d..44561dd11b44 100644
--- a/configs/kernel-4.18.0-x86_64.config
+++ b/configs/kernel-4.18.0-x86_64.config
@@ -7895,7 +7895,6 @@ CONFIG_BLK_DEV_CBT=y
CONFIG_DM_PUSH_BACKUP=m
CONFIG_OVERLAY_FS_DYNAMIC_RESOLVE_PATH_OPTIONS=y
CONFIG_OVERLAY_FS_PATH_OPTIONS_MNT_ID=y
-CONFIG_OVERLAY_FS_INDEX_NOUUID=y
# CONFIG_FUSE_KIO_NOOP is not set
# CONFIG_FUSE_KIO_NULLIO is not set
diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig
index 89afd55f8bfe..b8ea6a2e78f6 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -60,22 +60,6 @@ config OVERLAY_FS_INDEX
If unsure, say N.
-config OVERLAY_FS_INDEX_NOUUID
- bool "Overlayfs: relax uuid checks of inodes index feature"
- depends on OVERLAY_FS
- depends on OVERLAY_FS_INDEX
- help
- If this config option is enabled then overlay will skip uuid checks
- for index lower to upper inode map, this only can be done if all
- upper and lower directories are on the same filesystem where basic
- fhandles are uniq.
-
- It is needed to overcome possible change of uuid on superblock of the
- backing filesystem, e.g. when you copied the virtual disk and mount
- both the copy of the disk and the original one at the same time.
-
- If unsure, say N.
-
config OVERLAY_FS_NFS_EXPORT
bool "Overlayfs: turn on NFS export feature by default"
depends on OVERLAY_FS
diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index 211b8228dfc0..8d86d9a5e9b6 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -679,12 +679,11 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
struct ovl_fs *ofs = sb->s_fs_info;
struct dentry *dentry;
struct dentry *upper;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
if (!ofs->upper_mnt)
return ERR_PTR(-EACCES);
- upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true, nouuid);
+ upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true);
if (IS_ERR_OR_NULL(upper))
return upper;
@@ -704,7 +703,6 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
struct dentry *index = NULL;
struct inode *inode;
int err;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
/* First lookup overlay inode in inode cache by origin fh */
err = ovl_check_origin_fh(ofs, fh, false, NULL, &stack);
@@ -757,7 +755,7 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
goto out_err;
}
if (index) {
- err = ovl_verify_origin(index, origin.dentry, false, nouuid);
+ err = ovl_verify_origin(index, origin.dentry, false);
if (err)
goto out_err;
}
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 668531ae9e4f..4bbefc699fba 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -152,7 +152,7 @@ static struct ovl_fh *ovl_get_fh(struct dentry *dentry, const char *name)
}
struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt,
- bool connected, bool nouuid)
+ bool connected)
{
struct dentry *real;
int bytes;
@@ -161,7 +161,7 @@ struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt,
* Make sure that the stored uuid matches the uuid of the lower
* layer where file handle will be decoded.
*/
- if (!nouuid && !uuid_equal(&fh->fb.uuid, &mnt->mnt_sb->s_uuid))
+ if (!uuid_equal(&fh->fb.uuid, &mnt->mnt_sb->s_uuid))
return NULL;
bytes = (fh->fb.len - offsetof(struct ovl_fb, fid));
@@ -324,7 +324,6 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
{
struct dentry *origin = NULL;
int i;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
for (i = 1; i < ofs->numlayer; i++) {
/*
@@ -336,7 +335,7 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
continue;
origin = ovl_decode_real_fh(fh, ofs->layers[i].mnt,
- connected, nouuid);
+ connected);
if (origin)
break;
}
@@ -401,7 +400,7 @@ static int ovl_check_origin(struct ovl_fs *ofs, struct dentry *upperdentry,
* Return 0 on match, -ESTALE on mismatch, < 0 on error.
*/
static int ovl_verify_fh(struct dentry *dentry, const char *name,
- const struct ovl_fh *fh, bool nouuid)
+ const struct ovl_fh *fh)
{
struct ovl_fh *ofh = ovl_get_fh(dentry, name);
int err = 0;
@@ -412,14 +411,8 @@ static int ovl_verify_fh(struct dentry *dentry, const char *name,
if (IS_ERR(ofh))
return PTR_ERR(ofh);
- if (fh->fb.len != ofh->fb.len) {
+ if (fh->fb.len != ofh->fb.len || memcmp(&fh->fb, &ofh->fb, fh->fb.len))
err = -ESTALE;
- } else {
- if (nouuid && !uuid_equal(&fh->fb.uuid, &ofh->fb.uuid))
- ofh->fb.uuid = fh->fb.uuid;
- if (memcmp(&fh->fb, &ofh->fb, fh->fb.len))
- err = -ESTALE;
- }
kfree(ofh);
return err;
@@ -434,8 +427,7 @@ static int ovl_verify_fh(struct dentry *dentry, const char *name,
* Return 0 on match, -ESTALE on mismatch, -ENODATA on no xattr, < 0 on error.
*/
int ovl_verify_set_fh(struct dentry *dentry, const char *name,
- struct dentry *real, bool is_upper, bool set,
- bool nouuid)
+ struct dentry *real, bool is_upper, bool set)
{
struct inode *inode;
struct ovl_fh *fh;
@@ -448,7 +440,7 @@ int ovl_verify_set_fh(struct dentry *dentry, const char *name,
goto fail;
}
- err = ovl_verify_fh(dentry, name, fh, nouuid);
+ err = ovl_verify_fh(dentry, name, fh);
if (set && err == -ENODATA)
err = ovl_do_setxattr(dentry, name, fh->buf, fh->fb.len, 0);
if (err)
@@ -471,7 +463,6 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
{
struct ovl_fh *fh;
struct dentry *upper;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
if (!d_is_dir(index))
return dget(index);
@@ -480,7 +471,7 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
if (IS_ERR_OR_NULL(fh))
return ERR_CAST(fh);
- upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true, nouuid);
+ upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true);
kfree(fh);
if (IS_ERR_OR_NULL(upper))
@@ -515,7 +506,6 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
struct ovl_path *stack = &origin;
struct dentry *upper = NULL;
int err;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
if (!d_inode(index))
return 0;
@@ -581,7 +571,7 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
goto fail;
}
- err = ovl_verify_fh(upper, OVL_XATTR_ORIGIN, fh, nouuid);
+ err = ovl_verify_fh(upper, OVL_XATTR_ORIGIN, fh);
dput(upper);
if (err)
goto fail;
@@ -697,7 +687,6 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper,
struct qstr name;
bool is_dir = d_is_dir(origin);
int err;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
err = ovl_get_index_name(origin, &name);
if (err)
@@ -749,7 +738,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper,
}
/* Verify that dir index 'upper' xattr points to upper dir */
- err = ovl_verify_upper(index, upper, false, nouuid);
+ err = ovl_verify_upper(index, upper, false);
if (err) {
if (err == -ESTALE) {
pr_warn_ratelimited("suspected multiply redirected dir found (upper=%pd2, origin=%pd2, index=%pd2).\n",
@@ -848,7 +837,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
.redirect = NULL,
.metacopy = false,
};
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
if (dentry->d_name.len > ofs->namelen)
return ERR_PTR(-ENAMETOOLONG);
@@ -951,8 +939,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
if (upperdentry && !ctr &&
((d.is_dir && ovl_verify_lower(dentry->d_sb)) ||
(!d.is_dir && ofs->config.index && origin_path))) {
- err = ovl_verify_origin(upperdentry, this, false,
- nouuid);
+ err = ovl_verify_origin(upperdentry, this, false);
if (err) {
dput(this);
if (d.is_dir)
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 7e103d002819..b46f1c8f053a 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -21,12 +21,6 @@ enum ovl_path_type {
__OVL_PATH_ORIGIN = (1 << 2),
};
-enum ovl_index_type {
- OVL_INDEX_OFF = 0,
- OVL_INDEX_ON,
- OVL_INDEX_NOUUID,
-};
-
#define OVL_TYPE_UPPER(type) ((type) & __OVL_PATH_UPPER)
#define OVL_TYPE_MERGE(type) ((type) & __OVL_PATH_MERGE)
#define OVL_TYPE_ORIGIN(type) ((type) & __OVL_PATH_ORIGIN)
@@ -378,12 +372,11 @@ static inline int ovl_check_fh_len(struct ovl_fh *fh, int fh_len)
}
struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt,
- bool connected, bool nouuid);
+ bool connected);
int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
struct dentry *upperdentry, struct ovl_path **stackp);
int ovl_verify_set_fh(struct dentry *dentry, const char *name,
- struct dentry *real, bool is_upper, bool set,
- bool nouuid);
+ struct dentry *real, bool is_upper, bool set);
struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index);
int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index);
int ovl_get_index_name(struct dentry *origin, struct qstr *name);
@@ -396,19 +389,15 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
bool ovl_lower_positive(struct dentry *dentry);
static inline int ovl_verify_origin(struct dentry *upper,
- struct dentry *origin, bool set,
- bool nouuid)
+ struct dentry *origin, bool set)
{
- return ovl_verify_set_fh(upper, OVL_XATTR_ORIGIN, origin, false, set,
- nouuid);
+ return ovl_verify_set_fh(upper, OVL_XATTR_ORIGIN, origin, false, set);
}
static inline int ovl_verify_upper(struct dentry *index,
- struct dentry *upper, bool set,
- bool nouuid)
+ struct dentry *upper, bool set)
{
- return ovl_verify_set_fh(index, OVL_XATTR_UPPER, upper, true, set,
- nouuid);
+ return ovl_verify_set_fh(index, OVL_XATTR_UPPER, upper, true, set);
}
/* readdir.c */
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 2315089a0211..0f3c34bd0b32 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -16,7 +16,7 @@ struct ovl_config {
bool redirect_dir;
bool redirect_follow;
const char *redirect_mode;
- int index;
+ bool index;
bool nfs_export;
int xino;
bool metacopy;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 27193800b77c..5e07d07ffd05 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -41,12 +41,10 @@ module_param_named(redirect_always_follow, ovl_redirect_always_follow,
MODULE_PARM_DESC(redirect_always_follow,
"Follow redirects even if redirect_dir feature is turned off");
-static int ovl_index_def = IS_ENABLED(CONFIG_OVERLAY_FS_INDEX_NOUUID) ?
- OVL_INDEX_NOUUID :
- IS_ENABLED(CONFIG_OVERLAY_FS_INDEX);
-module_param_named(index, ovl_index_def, int, 0644);
+static bool ovl_index_def = IS_ENABLED(CONFIG_OVERLAY_FS_INDEX);
+module_param_named(index, ovl_index_def, bool, 0644);
MODULE_PARM_DESC(index,
- "Default to on, off or nouuid for the inodes index feature");
+ "Default to on or off for the inodes index feature");
static bool ovl_nfs_export_def = IS_ENABLED(CONFIG_OVERLAY_FS_NFS_EXPORT);
module_param_named(nfs_export, ovl_nfs_export_def, bool, 0644);
@@ -388,18 +386,8 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
seq_puts(m, ",default_permissions");
if (strcmp(ofs->config.redirect_mode, ovl_redirect_mode_def()) != 0)
seq_printf(m, ",redirect_dir=%s", ofs->config.redirect_mode);
- if (ofs->config.index != ovl_index_def) {
- switch (ofs->config.index) {
- case OVL_INDEX_OFF:
- seq_puts(m, ",index=off");
- break;
- case OVL_INDEX_NOUUID:
- seq_puts(m, ",index=nouuid");
- break;
- default:
- seq_puts(m, ",index=on");
- }
- }
+ if (ofs->config.index != ovl_index_def)
+ seq_printf(m, ",index=%s", ofs->config.index ? "on" : "off");
if (ofs->config.nfs_export != ovl_nfs_export_def)
seq_printf(m, ",nfs_export=%s", ofs->config.nfs_export ?
"on" : "off");
@@ -449,7 +437,6 @@ enum {
OPT_REDIRECT_DIR,
OPT_INDEX_ON,
OPT_INDEX_OFF,
- OPT_INDEX_NOUUID,
OPT_NFS_EXPORT_ON,
OPT_NFS_EXPORT_OFF,
OPT_XINO_ON,
@@ -468,7 +455,6 @@ static const match_table_t ovl_tokens = {
{OPT_REDIRECT_DIR, "redirect_dir=%s"},
{OPT_INDEX_ON, "index=on"},
{OPT_INDEX_OFF, "index=off"},
- {OPT_INDEX_NOUUID, "index=nouuid"},
{OPT_NFS_EXPORT_ON, "nfs_export=on"},
{OPT_NFS_EXPORT_OFF, "nfs_export=off"},
{OPT_XINO_ON, "xino=on"},
@@ -579,17 +565,12 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
break;
case OPT_INDEX_ON:
- config->index = OVL_INDEX_ON;
+ config->index = true;
index_opt = true;
break;
case OPT_INDEX_OFF:
- config->index = OVL_INDEX_OFF;
- index_opt = true;
- break;
-
- case OPT_INDEX_NOUUID:
- config->index = OVL_INDEX_NOUUID;
+ config->index = false;
index_opt = true;
break;
@@ -687,7 +668,7 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
config->nfs_export = false;
} else {
/* Automatically enable index otherwise. */
- config->index = OVL_INDEX_ON;
+ config->index = true;
}
}
@@ -907,7 +888,7 @@ static int ovl_lower_dir(const char *name, struct path *path,
fh_type = ovl_can_decode_fh(path->dentry->d_sb);
if ((ofs->config.nfs_export ||
(ofs->config.index && ofs->config.upperdir)) && !fh_type) {
- ofs->config.index = OVL_INDEX_OFF;
+ ofs->config.index = false;
ofs->config.nfs_export = false;
pr_warn("fs on '%s' does not support file handles, falling back to index=off,nfs_export=off.\n",
name);
@@ -1298,7 +1279,7 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
err = ovl_do_setxattr(ofs->workdir, OVL_XATTR_OPAQUE, "0", 1, 0);
if (err) {
ofs->noxattr = true;
- ofs->config.index = OVL_INDEX_OFF;
+ ofs->config.index = false;
ofs->config.metacopy = false;
pr_warn("upper fs does not support xattr, falling back to index=off and metacopy=off.\n");
err = 0;
@@ -1321,7 +1302,7 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
/* Check if upper/work fs supports file handles */
fh_type = ovl_can_decode_fh(ofs->workdir->d_sb);
if (ofs->config.index && !fh_type) {
- ofs->config.index = OVL_INDEX_OFF;
+ ofs->config.index = false;
pr_warn("upper fs does not support file handles, falling back to index=off.\n");
}
@@ -1383,7 +1364,6 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
{
struct vfsmount *mnt = ofs->upper_mnt;
int err;
- bool nouuid = ofs->config.index == OVL_INDEX_NOUUID;
err = mnt_want_write(mnt);
if (err)
@@ -1391,7 +1371,7 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
/* Verify lower root is upper root origin */
err = ovl_verify_origin(upperpath->dentry, oe->lowerstack[0].dentry,
- true, nouuid);
+ true);
if (err) {
pr_err("failed to verify upper root origin\n");
goto out;
@@ -1414,13 +1394,11 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
*/
if (ovl_check_origin_xattr(ofs->indexdir)) {
err = ovl_verify_set_fh(ofs->indexdir, OVL_XATTR_ORIGIN,
- upperpath->dentry, true, false,
- nouuid);
+ upperpath->dentry, true, false);
if (err)
pr_err("failed to verify index dir 'origin' xattr\n");
}
- err = ovl_verify_upper(ofs->indexdir, upperpath->dentry, true,
- nouuid);
+ err = ovl_verify_upper(ofs->indexdir, upperpath->dentry, true);
if (err)
pr_err("failed to verify index dir 'upper' xattr\n");
@@ -1477,7 +1455,7 @@ static int ovl_get_fsid(struct ovl_fs *ofs, const struct path *path)
if (!ovl_lower_uuid_ok(ofs, &sb->s_uuid)) {
bad_uuid = true;
if (ofs->config.index || ofs->config.nfs_export) {
- ofs->config.index = OVL_INDEX_OFF;
+ ofs->config.index = false;
ofs->config.nfs_export = false;
pr_warn("%s uuid detected in lower fs '%pd2', falling back to index=off,nfs_export=off.\n",
uuid_is_null(&sb->s_uuid) ? "null" :
@@ -1908,14 +1886,9 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (err)
goto out_free_oe;
- if (ofs->config.index == OVL_INDEX_NOUUID && (ofs->numfs > 1)) {
- pr_warn("index=nouuid requires an single fs for lower and upper, falling back to index=on.\n");
- ofs->config.index = OVL_INDEX_ON;
- }
-
/* Show index=off in /proc/mounts for forced r/o mount */
if (!ofs->indexdir) {
- ofs->config.index = OVL_INDEX_OFF;
+ ofs->config.index = false;
if (ofs->upper_mnt && ofs->config.nfs_export) {
pr_warn("NFS export requires an index dir, falling back to nfs_export=off.\n");
ofs->config.nfs_export = false;
--
2.31.1
More information about the Devel
mailing list