Re: [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()

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

 



On Fri, Oct 25, 2024 at 5:02 PM Miklos Szeredi <mszeredi@xxxxxxxxxx> wrote:
>
> The reason for the dget/dput pair was to force the upperdentry to be
> dropped from the cache instead of turning it negative and keeping it
> cached.
>
> Simpler and cleaner way to achieve the same effect is to just drop the
> dentry after unlink/rmdir if it was turned negative.
>
> Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>

Looks sane.
Applied to overlayfs-next for testing.

Thanks,
Amir.

> ---
> v2:
>  - use d_drop()
>
>  fs/overlayfs/dir.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index ab65e98a1def..c7548c2bbc12 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -28,12 +28,14 @@ int ovl_cleanup(struct ovl_fs *ofs, struct inode *wdir, struct dentry *wdentry)
>  {
>         int err;
>
> -       dget(wdentry);
>         if (d_is_dir(wdentry))
>                 err = ovl_do_rmdir(ofs, wdir, wdentry);
>         else
>                 err = ovl_do_unlink(ofs, wdir, wdentry);
> -       dput(wdentry);
> +
> +       /* A cached negative upper dentry is generally not useful, so drop it. */
> +       if (d_is_negative(wdentry))
> +               d_drop(wdentry);
>
>         if (err) {
>                 pr_err("cleanup of '%pd2' failed (%i)\n",
> --
> 2.47.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