From: Miklos Szeredi <mszeredi@redhat.com>
To: linux-unionfs@vger.kernel.org
Cc: Amir Goldstein <amir73il@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup()
Date: Fri, 25 Oct 2024 17:01:50 +0200 [thread overview]
Message-ID: <20241025150154.879541-1-mszeredi@redhat.com> (raw)
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
next reply other threads:[~2024-10-25 15:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 15:01 Miklos Szeredi [this message]
2024-10-26 6:30 ` [PATCH v2] ovl: replace dget/dput with d_drop in ovl_cleanup() Amir Goldstein
2024-10-26 6:56 ` Al Viro
2024-11-05 11:34 ` Miklos Szeredi
2024-11-05 13:58 ` Amir Goldstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241025150154.879541-1-mszeredi@redhat.com \
--to=mszeredi@redhat.com \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).