Re: [PATCH 10/20] ovl: narrow locking in ovl_cleanup_index()

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

 



On Fri, Jul 11, 2025 at 1:21 AM NeilBrown <neil@xxxxxxxxxx> wrote:
>
> ovl_cleanup_index() takes a lock on the directory and then does a lookup
> and possibly one of two different cleanups.
> This patch narrows the locking to use the _unlocked() versions of the
> lookup and one cleanup, and just takes the lock for the other cleanup.
>
> A subsequent patch will take the lock into the cleanup.
>
> Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
> ---
>  fs/overlayfs/util.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
> index 9ce9fe62ef28..7369193b11ec 100644
> --- a/fs/overlayfs/util.c
> +++ b/fs/overlayfs/util.c
> @@ -1107,21 +1107,20 @@ static void ovl_cleanup_index(struct dentry *dentry)
>                 goto out;
>         }
>
> -       inode_lock_nested(dir, I_MUTEX_PARENT);
> -       index = ovl_lookup_upper(ofs, name.name, indexdir, name.len);
> +       index = ovl_lookup_upper_unlocked(ofs, name.name, indexdir, name.len);
>         err = PTR_ERR(index);
>         if (IS_ERR(index)) {
>                 index = NULL;
>         } else if (ovl_index_all(dentry->d_sb)) {
>                 /* Whiteout orphan index to block future open by handle */
> +               inode_lock_nested(dir, I_MUTEX_PARENT);

Don't we need to verify that index wasn't moved with
parent_lock(indexdi, index)?

Thanks,
Amir.

>                 err = ovl_cleanup_and_whiteout(OVL_FS(dentry->d_sb),
>                                                indexdir, index);
> +               inode_unlock(dir);
>         } else {
>                 /* Cleanup orphan index entries */
> -               err = ovl_cleanup(ofs, dir, index);
> +               err = ovl_cleanup_unlocked(ofs, indexdir, index);
>         }
> -
> -       inode_unlock(dir);
>         if (err)
>                 goto fail;
>
> --
> 2.49.0
>





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux