Re: [PATCH RFC v3 4/7] ovl: Ensure that all mount points have the same encoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 8, 2025 at 10:59 PM André Almeida <andrealmeid@xxxxxxxxxx> wrote:
>
> When mounting different mount points with casefold support, they should

Different mount points in incorrect terminology, please use:
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.
>
> Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxx>
> ---
>  fs/overlayfs/super.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index df85a76597e910d00323018f1d2cd720c5db921d..bcb7f5dbf9a32e4aa09bc41596be443851e21200 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -998,6 +998,7 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
>         int err;
>         unsigned int i;
>         size_t nr_merged_lower;
> +       struct super_block *sb1 = NULL;
>
>         ofs->fs = kcalloc(ctx->nr + 2, sizeof(struct ovl_sb), GFP_KERNEL);
>         if (ofs->fs == NULL)
> @@ -1024,6 +1025,8 @@ 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;
> +
> +               sb1 = ofs->fs[0].sb;
>         }
>
>         nr_merged_lower = ctx->nr - ctx->nr_data;
> @@ -1067,6 +1070,9 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
>                         return err;
>                 }
>
> +               if (!sb1)
> +                       sb1 = mnt->mnt_sb;
> +
>                 /*
>                  * Make lower layers R/O.  That way fchmod/fchown on lower file
>                  * will fail instead of modifying lower fs.
> @@ -1083,6 +1089,11 @@ 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 (!sb_same_encoding(sb1, mnt->mnt_sb)) {
> +                       pr_err("all layers must have the same encoding\n");
> +                       return -EINVAL;
> +               }
>         }

This condition is too strict IMO.
It is only needed if ofs->casefold is enabled.
When casefolding is not enabled for the ovl mount,
we need not care about the layers encoding.

This is related to another comment I have on path 7 -
ofs->casefold config should be introduced much earlier in the
series, so that it could be used in conditions like this one and
in the S_CASEFOLD assertions after copying inode flags.

Thanks,
Amir.





[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux