[Devel] [PATCH vz9 v2 1/2] overlayfs: fix lowerpaths handling in dynamic path resolving

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Jul 23 10:02:22 MSK 2024


Looks good, I personally prefer not changing ovl_stack_put -> 
__ovl_stack_put and not adding unified ovl_stacks_put to be closer to 
existing code, but that is not a big thing.

Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

On 7/20/24 06:07, Konstantin Khorenko wrote:
> RedHat in RHEL9.4 has backported overlayfs data-only lower layers
> feature (ms commit 37ebf056d6cf ("ovl: introduce data-only lower
> layers")), so we have to adjust our dynamic path resolving feature.
> 
> Additionally store number of lowerpaths as it now differs from saved
> number of lowerstacks due to data-only lower layers presence.
> 
> Fixes: 5f2c7b5e4d33 ("overlayfs: add dynamic path resolving in mount
> options")
> https://virtuozzo.atlassian.net/browse/PSBM-157244
> 
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>


> diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
> index 3676eaa83f7d..21acc780ebfc 100644
> --- a/fs/overlayfs/util.c
> +++ b/fs/overlayfs/util.c
> @@ -100,7 +100,7 @@ void ovl_stack_cpy(struct ovl_path *dst, struct ovl_path *src, unsigned int n)
>   		dget(src[i].dentry);
>   }
>   
> -void ovl_stack_put(struct ovl_path *stack, unsigned int n)
> +void __ovl_stack_put(struct ovl_path *stack, unsigned int n)

Do we really need this change?

>   {
>   	unsigned int i;
>   
> @@ -110,10 +110,24 @@ void ovl_stack_put(struct ovl_path *stack, unsigned int n)
>   
>   void ovl_stack_free(struct ovl_path *stack, unsigned int n)
>   {
> -	ovl_stack_put(stack, n);
> +	__ovl_stack_put(stack, n);
>   	kfree(stack);
>   }
>   
> +void __ovl_lowerpaths_put(struct path *lowerpaths, unsigned int n)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < n; i++)
> +		path_put(&lowerpaths[i]);
> +}
> +
> +void ovl_stacks_put(struct ovl_entry *oe)
> +{
> +	__ovl_stack_put(ovl_lowerstack(oe), ovl_numlower(oe));
> +	__ovl_lowerpaths_put(ovl_lowerpaths(oe), ovl_numlowerpaths(oe));
> +}

Do we really need to put those together in separate function? Maybe just 
add:

ovl_lowerpaths_put(ovl_lowerpaths(oe), ovl_numlowerpaths(oe));
kfree(ovl_lowerpaths(oe));

where needed, without changing preexisting functions?

> +
>   struct ovl_entry *ovl_alloc_entry(unsigned int numlower)
>   {
>   	size_t size = offsetof(struct ovl_entry, __lowerstack[numlower]);
> @@ -127,7 +141,8 @@ struct ovl_entry *ovl_alloc_entry(unsigned int numlower)


More information about the Devel mailing list