From: Pavel Tikhomirov <ptikhomi...@virtuozzo.com> 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 <ptikhomi...@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 <ptikhomi...@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 Rebased to vz9: - dropped all patches already present in ms (cherry picked from vz8 commit 8d81d6d2563c029fdd8c26064ca0fdbc6666120b) Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com> --- fs/overlayfs/Kconfig | 16 ++++++++++++++++ fs/overlayfs/namei.c | 19 ++++++++++++++++--- fs/overlayfs/super.c | 11 ++++++++--- .../generic/CONFIG_OVERLAY_FS_UUID_OFF | 1 + 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 redhat/configs/custom-overrides/generic/CONFIG_OVERLAY_FS_UUID_OFF diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig index 1ba9411..ed41761 100644 --- a/fs/overlayfs/Kconfig +++ b/fs/overlayfs/Kconfig @@ -61,6 +61,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 diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 210cd6f..4aec6b2 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -164,8 +164,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)); @@ -432,8 +435,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 2f49706..d855963 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -43,6 +43,11 @@ 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, @@ -403,8 +408,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"); @@ -2022,7 +2027,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ofs->share_whiteout = true; 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; diff --git a/redhat/configs/custom-overrides/generic/CONFIG_OVERLAY_FS_UUID_OFF b/redhat/configs/custom-overrides/generic/CONFIG_OVERLAY_FS_UUID_OFF new file mode 100644 index 0000000..1529aad --- /dev/null +++ b/redhat/configs/custom-overrides/generic/CONFIG_OVERLAY_FS_UUID_OFF @@ -0,0 +1 @@ +CONFIG_OVERLAY_FS_UUID_OFF=y -- 1.8.3.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel