Skip to contentSkip to conversation

ovl: clarify dget/dput in ovl_cleanup()

PATCH In review Miklos Szeredi 3 participants 3 messages Oct 22, 2024 – Oct 23, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ovl: clarify dget/dput in ovl_cleanup()

Add a comment explaining the reason for the seemingly pointless extra reference.

---
 fs/overlayfs/dir.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/overlayfs/dir.c +4 -0
index ab65e98a1def..9e97f7dffd90 100644
@@ -28,6 +28,10 @@ int ovl_cleanup(struct ovl_fs *ofs, struct inode *wdir, struct dentry *wdentry)
 {
 	int err;
 
+	/*
+	 * Cached negative upper dentries are generally not useful, so grab a
+	 * ref to the victim to keep it from turning negative.
+	 */
 	dget(wdentry);
 	if (d_is_dir(wdentry))
 		err = ovl_do_rmdir(ofs, wdir, wdentry);
Signature · 1 line
2.47.0
maintainer
#1 lore raw
Quoted 15 lines · Miklos Szeredi

Add a comment explaining the reason for the seemingly pointless extra reference.

---
 fs/overlayfs/dir.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/overlayfs/dir.c +0 -0
index ab65e98a1def..9e97f7dffd90 100644

fs/overlayfs/dir.c int ovl_cleanup(struct ovl_fs *ofs, struct inode *wdir, struct dentry *wdentry) · line 34

Quoted 7 lines
fs/overlayfs/dir.c +4 -0
@@ -28,6 +28,10 @@ int ovl_cleanup(struct ovl_fs *ofs, struct inode *wdir, struct dentry *wdentry)
 {
        int err;
 
+       /*
+        * Cached negative upper dentries are generally not useful, so grab a
+        * ref to the victim to keep it from turning negative.
+        */

In fact an explicit d_drop() after the fact would have exactly the same effect, so maybe that would be cleaner...

Thanks,
Miklos

maintainer
#2 lore raw
Quoted 20 lines · Miklos Szeredi
Quoted 18 lines · Miklos Szeredi

Add a comment explaining the reason for the seemingly pointless extra reference.

---
 fs/overlayfs/dir.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/overlayfs/dir.c +0 -0
index ab65e98a1def..9e97f7dffd90 100644
@@ -28,6 +28,10 @@ int ovl_cleanup(struct ovl_fs *ofs, struct inode *wdir, struct dentry *wdentry)
 {
        int err;
 
Quoted 8 lines

fs/overlayfs/dir.c int ovl_cleanup(struct ovl_fs *ofs, struct inode *wdir, struct dentry *wdentry) · line 34

Quoted 4 lines
fs/overlayfs/dir.c +4 -0
+       /*
+        * Cached negative upper dentries are generally not useful, so grab a
+        * ref to the victim to keep it from turning negative.
+        */

In fact an explicit d_drop() after the fact would have exactly the same effect, so maybe that would be cleaner...

Agree.

Thanks,
Amir.