[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxi4Y7PPg8DH4NS2KhZxg0mirr3_4Dz5jiFiXBjZAdOtJg@mail.gmail.com>
Date: Thu, 14 Aug 2025 14:56:12 +0200
From: Amir Goldstein <amir73il@...il.com>
To: André Almeida <andrealmeid@...lia.com>
Cc: Miklos Szeredi <miklos@...redi.hu>, Theodore Tso <tytso@....edu>,
Gabriel Krisman Bertazi <krisman@...nel.org>, linux-unionfs@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
kernel-dev@...lia.com
Subject: Re: [PATCH v4 5/9] ovl: Ensure that all layers have the same encoding
On Thu, Aug 14, 2025 at 12:37 AM André Almeida <andrealmeid@...lia.com> wrote:
>
> When merging layers from different filesystems with casefold enabled,
> all layers should use the same encoding version and have the same flags
> to avoid any kind of incompatibility issues.
>
> Also, set the encoding and the encoding flags for the ovl super block as
> the same as used by the first valid layer.
>
> Signed-off-by: André Almeida <andrealmeid@...lia.com>
Reviewed-by: Amir Goldstein <amir73il@...il.com>
> ---
> Changes from v3:
> - Check this restriction just when casefold is enabled
> - Create new helper ovl_set_encoding() and change the logic a bit
> ---
> fs/overlayfs/super.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index df85a76597e910d00323018f1d2cd720c5db921d..b1dbd3c79961094d00c7f99cc622e515d544d22f 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -991,6 +991,18 @@ static int ovl_get_data_fsid(struct ovl_fs *ofs)
> return ofs->numfs;
> }
>
> +/*
> + * Set the ovl sb encoding as the same one used by the first layer
> + */
> +static void ovl_set_encoding(struct super_block *sb, struct super_block *fs_sb)
> +{
> +#if IS_ENABLED(CONFIG_UNICODE)
> + if (sb_has_encoding(fs_sb)) {
> + sb->s_encoding = fs_sb->s_encoding;
> + sb->s_encoding_flags = fs_sb->s_encoding_flags;
> + }
> +#endif
> +}
>
> static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
> struct ovl_fs_context *ctx, struct ovl_layer *layers)
> @@ -1024,6 +1036,9 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
> if (ovl_upper_mnt(ofs)) {
> ofs->fs[0].sb = ovl_upper_mnt(ofs)->mnt_sb;
> ofs->fs[0].is_lower = false;
> +
> + if (ofs->casefold)
> + ovl_set_encoding(sb, ofs->fs[0].sb);
> }
>
> nr_merged_lower = ctx->nr - ctx->nr_data;
> @@ -1083,6 +1098,16 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
> l->name = NULL;
> ofs->numlayer++;
> ofs->fs[fsid].is_lower = true;
> +
> + if (ofs->casefold) {
> + if (!ovl_upper_mnt(ofs) && !sb_has_encoding(sb))
> + ovl_set_encoding(sb, ofs->fs[fsid].sb);
> +
> + if (!sb_has_encoding(sb) || !sb_same_encoding(sb, mnt->mnt_sb)) {
> + pr_err("all layers must have the same encoding\n");
> + return -EINVAL;
> + }
> + }
> }
>
> /*
>
> --
> 2.50.1
>
Powered by blists - more mailing lists