[Devel] [PATCH RHEL8 COMMIT] ovl: make uuid=off compatible with overlayfs created without it
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 13 10:07:45 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.vz8.7.5
------>
commit 1cc8adcbe1b0c5b3c13f85b379b2db5701a388bb
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date: Fri Aug 13 10:07:44 2021 +0300
ovl: make uuid=off compatible with overlayfs created without it
Patch makes mainstream "uuid=off" compatible with our reverted
"index=nouuid" option.
To make overlayfs mounts in containers be copyable by vzmlocal (which
implies uuid change) we need to set "uuid=off" by default for all
overlayfs mounts. So add CONFIG_OVERLAY_FS_UUID_OFF and uuid module
param to configure defaults.
To make overlayfs mounts created on older kernel without "uuid=off" also
copyable by vzmlocal we also need to skip uuid checks. Mainstream
version compares uuid with zero, but old overlayfs mount xattrs can
store non-zero uuids as fhandles already.
https://jira.sw.ru/browse/PSBM-123536
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
====================
Patchset descrition:
ovl: replace "index=nouuid" with "uuid=off"
Mainstream base is a bit different so we need some more ovl_fs
propagation to functions. Also we still need some vz-specific hunks
which were not allowed to mainstream overlay, so add them as a separate
patch.
https://jira.sw.ru/browse/PSBM-123536
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Pavel Tikhomirov (4):
Revert "ovl: introduce new "index=nouuid" option for inodes index
feature"
ovl: propagate ovl_fs to ovl_decode_real_fh and ovl_encode_real_fh
ovl: introduce new "uuid=off" option for inodes index feature
ovl: make uuid=off compatible with overlayfs created without it
---
configs/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 | 18 +++++++++++++++++-
fs/overlayfs/namei.c | 19 ++++++++++++++++---
fs/overlayfs/super.c | 11 ++++++++---
6 files changed, 44 insertions(+), 7 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 ee046f4ae07e..c4f2fd21c3d6 100644
--- a/configs/kernel-4.18.0-x86_64-KVM-minimal.config
+++ b/configs/kernel-4.18.0-x86_64-KVM-minimal.config
@@ -4163,6 +4163,7 @@ CONFIG_OVERLAY_FS=y
CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW=y
CONFIG_OVERLAY_FS_INDEX=y
CONFIG_OVERLAY_FS_NFS_EXPORT=y
+CONFIG_OVERLAY_FS_UUID_OFF=y
# CONFIG_OVERLAY_FS_XINO_AUTO is not set
# CONFIG_OVERLAY_FS_METACOPY is not set
CONFIG_OVERLAY_FS_DYNAMIC_RESOLVE_PATH_OPTIONS=y
diff --git a/configs/kernel-4.18.0-x86_64-debug.config b/configs/kernel-4.18.0-x86_64-debug.config
index cbb51c5c8ae1..51b2e941b477 100644
--- a/configs/kernel-4.18.0-x86_64-debug.config
+++ b/configs/kernel-4.18.0-x86_64-debug.config
@@ -7948,6 +7948,7 @@ 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_UUID_OFF=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 44561dd11b44..f82bad56b783 100644
--- a/configs/kernel-4.18.0-x86_64.config
+++ b/configs/kernel-4.18.0-x86_64.config
@@ -7895,6 +7895,7 @@ 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_UUID_OFF=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 b8ea6a2e78f6..e26e17be859b 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -60,6 +60,22 @@ config OVERLAY_FS_INDEX
If unsure, say N.
+config OVERLAY_FS_UUID_OFF
+ bool "Overlayfs: skip uuid checks for fhandles"
+ 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
@@ -179,4 +195,4 @@ config OVERLAY_FS_PATH_OPTIONS_MNT_ID
For more information, see Documentation/filesystems/overlayfs.txt
- If unsure, say N.
\ No newline at end of file
+ If unsure, say N.
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 141b9246f9ac..4e2368620fda 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -162,8 +162,11 @@ struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
* layer where file handle will be decoded.
* In case of uuid=off option just make sure that stored uuid is null.
*/
- if (ofs->config.uuid ? !uuid_equal(&fh->fb.uuid, &mnt->mnt_sb->s_uuid) :
- !uuid_is_null(&fh->fb.uuid))
+ /* Virtuozzo: Skip uuid is zero check when uuid=off is set for
+ * compatibility with older containers which had overlayfs mounts
+ * mounted without it and have non-zero uuid in fhandles.
+ */
+ if (ofs->config.uuid && !uuid_equal(&fh->fb.uuid, &mnt->mnt_sb->s_uuid))
return NULL;
bytes = (fh->fb.len - offsetof(struct ovl_fb, fid));
@@ -413,8 +416,18 @@ static int ovl_verify_fh(struct ovl_fs *ofs, struct dentry *dentry,
if (IS_ERR(ofh))
return PTR_ERR(ofh);
- if (fh->fb.len != ofh->fb.len || memcmp(&fh->fb, &ofh->fb, fh->fb.len))
+ if (fh->fb.len != ofh->fb.len) {
err = -ESTALE;
+ } else {
+ /*
+ * Virtuozzo: Skip uuid comparison check when uuid=off is set
+ * for compatibility.
+ */
+ if (!ofs->config.uuid && !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;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index feaa93132edc..e6edd0de5fd3 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -46,6 +46,11 @@ module_param_named(index, ovl_index_def, bool, 0644);
MODULE_PARM_DESC(index,
"Default to on or off for the inodes index feature");
+static bool ovl_uuid_def = !IS_ENABLED(CONFIG_OVERLAY_FS_UUID_OFF);
+module_param_named(uuid, ovl_uuid_def, bool, 0644);
+MODULE_PARM_DESC(uuid,
+ "Default to on or off for the inodes uuid 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);
MODULE_PARM_DESC(nfs_export,
@@ -388,8 +393,8 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
seq_printf(m, ",redirect_dir=%s", ofs->config.redirect_mode);
if (ofs->config.index != ovl_index_def)
seq_printf(m, ",index=%s", ofs->config.index ? "on" : "off");
- if (!ofs->config.uuid)
- seq_puts(m, ",uuid=off");
+ if (ofs->config.uuid != ovl_uuid_def)
+ seq_printf(m, ",uuid=%s", ofs->config.uuid ? "on" : "off");
if (ofs->config.nfs_export != ovl_nfs_export_def)
seq_printf(m, ",nfs_export=%s", ofs->config.nfs_export ?
"on" : "off");
@@ -1825,7 +1830,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
goto out_err;
ofs->config.index = ovl_index_def;
- ofs->config.uuid = true;
+ ofs->config.uuid = ovl_uuid_def;
ofs->config.nfs_export = ovl_nfs_export_def;
ofs->config.xino = ovl_xino_def();
ofs->config.metacopy = ovl_metacopy_def;
More information about the Devel
mailing list