* [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()
@ 2024-10-25 15:01 Miklos Szeredi
2024-10-26 6:30 ` Amir Goldstein
0 siblings, 1 reply; 5+ messages in thread
From: Miklos Szeredi @ 2024-10-25 15:01 UTC (permalink / raw)
To: linux-unionfs; +Cc: Amir Goldstein, Al Viro, linux-fsdevel
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@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()
2024-10-25 15:01 [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup() Miklos Szeredi
@ 2024-10-26 6:30 ` Amir Goldstein
2024-10-26 6:56 ` Al Viro
0 siblings, 1 reply; 5+ messages in thread
From: Amir Goldstein @ 2024-10-26 6:30 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: linux-unionfs, Al Viro, linux-fsdevel
On Fri, Oct 25, 2024 at 5:02 PM Miklos Szeredi <mszeredi@redhat.com> 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@redhat.com>
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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()
2024-10-26 6:30 ` Amir Goldstein
@ 2024-10-26 6:56 ` Al Viro
2024-11-05 11:34 ` Miklos Szeredi
0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2024-10-26 6:56 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Miklos Szeredi, linux-unionfs, linux-fsdevel
On Sat, Oct 26, 2024 at 08:30:54AM +0200, Amir Goldstein wrote:
> On Fri, Oct 25, 2024 at 5:02 PM Miklos Szeredi <mszeredi@redhat.com> 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@redhat.com>
>
> Looks sane.
> Applied to overlayfs-next for testing.
I thought it was about preventing an overlayfs objects with negative ->__upperdentry;
why would a negative dentry in upper layer be a problem otherwise?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()
2024-10-26 6:56 ` Al Viro
@ 2024-11-05 11:34 ` Miklos Szeredi
2024-11-05 13:58 ` Amir Goldstein
0 siblings, 1 reply; 5+ messages in thread
From: Miklos Szeredi @ 2024-11-05 11:34 UTC (permalink / raw)
To: Al Viro; +Cc: Amir Goldstein, Miklos Szeredi, linux-unionfs, linux-fsdevel
On Sat, 26 Oct 2024 at 08:56, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Sat, Oct 26, 2024 at 08:30:54AM +0200, Amir Goldstein wrote:
> > On Fri, Oct 25, 2024 at 5:02 PM Miklos Szeredi <mszeredi@redhat.com> 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@redhat.com>
> >
> > Looks sane.
> > Applied to overlayfs-next for testing.
>
> I thought it was about preventing an overlayfs objects with negative ->__upperdentry;
Yeah, I overlooked that aspect. Amir, please drop this patch.
> why would a negative dentry in upper layer be a problem otherwise?
Double caching, see this commit:
commit 1434a65ea625c51317ccdf06dabf4bd27d20fa10
Author: Chengguang Xu <cgxu519@mykernel.net>
Date: Tue May 26 09:35:57 2020 +0800
ovl: drop negative dentry in upper layer
Negative dentries of upper layer are useless after construction of
overlayfs' own dentry and may keep in the memory long time even after
unmount of overlayfs instance. This patch tries to drop unnecessary
negative dentry of upper layer to effectively reclaim memory.
The reason lower dentries are different is that lower layers could be
(and often are) shared, while the upper layer is always private.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()
2024-11-05 11:34 ` Miklos Szeredi
@ 2024-11-05 13:58 ` Amir Goldstein
0 siblings, 0 replies; 5+ messages in thread
From: Amir Goldstein @ 2024-11-05 13:58 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: Al Viro, Miklos Szeredi, linux-unionfs, linux-fsdevel
On Tue, Nov 5, 2024 at 12:34 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> On Sat, 26 Oct 2024 at 08:56, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > On Sat, Oct 26, 2024 at 08:30:54AM +0200, Amir Goldstein wrote:
> > > On Fri, Oct 25, 2024 at 5:02 PM Miklos Szeredi <mszeredi@redhat.com> 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@redhat.com>
> > >
> > > Looks sane.
> > > Applied to overlayfs-next for testing.
> >
> > I thought it was about preventing an overlayfs objects with negative ->__upperdentry;
>
> Yeah, I overlooked that aspect. Amir, please drop this patch.
>
Dropped.
Thanks,
Amir.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-05 13:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-25 15:01 [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup() Miklos Szeredi
2024-10-26 6:30 ` Amir Goldstein
2024-10-26 6:56 ` Al Viro
2024-11-05 11:34 ` Miklos Szeredi
2024-11-05 13:58 ` Amir Goldstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).