Re: [PATCH 08/12] ovl: narrow locking in ovl_cleanup_whiteouts()

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

 



On Wed, Jun 25, 2025 at 1:07 AM NeilBrown <neil@xxxxxxxxxx> wrote:
>
> Rather than lock the directory for the whole operation, use
> ovl_lookup_upper_unlocked() and ovl_cleanup_unlocked() to take the lock
> only when needed.
>
> This makes way for future changes where locks are taken on individual
> dentries rather than the whole directory.
>
> Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx>

> ---
>  fs/overlayfs/readdir.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
> index 68cca52ae2ac..2a222b8185a3 100644
> --- a/fs/overlayfs/readdir.c
> +++ b/fs/overlayfs/readdir.c
> @@ -1034,14 +1034,13 @@ void ovl_cleanup_whiteouts(struct ovl_fs *ofs, struct dentry *upper,
>  {
>         struct ovl_cache_entry *p;
>
> -       inode_lock_nested(upper->d_inode, I_MUTEX_CHILD);
>         list_for_each_entry(p, list, l_node) {
>                 struct dentry *dentry;
>
>                 if (WARN_ON(!p->is_whiteout || !p->is_upper))
>                         continue;
>
> -               dentry = ovl_lookup_upper(ofs, p->name, upper, p->len);
> +               dentry = ovl_lookup_upper_unlocked(ofs, p->name, upper, p->len);
>                 if (IS_ERR(dentry)) {
>                         pr_err("lookup '%s/%.*s' failed (%i)\n",
>                                upper->d_name.name, p->len, p->name,
> @@ -1049,10 +1048,9 @@ void ovl_cleanup_whiteouts(struct ovl_fs *ofs, struct dentry *upper,
>                         continue;
>                 }
>                 if (dentry->d_inode)
> -                       ovl_cleanup(ofs, upper->d_inode, dentry);
> +                       ovl_cleanup_unlocked(ofs, upper, dentry);
>                 dput(dentry);
>         }
> -       inode_unlock(upper->d_inode);
>  }
>
>  static bool ovl_check_d_type(struct dir_context *ctx, const char *name,
> --
> 2.49.0
>





[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