[PATCH v4 11/11] fs/9p: Fix revalidate

Eric Van Hensbergen posted 11 patches 2 years, 6 months ago
[PATCH v4 11/11] fs/9p: Fix revalidate
Posted by Eric Van Hensbergen 2 years, 6 months ago
Unclear if this case ever happens, but if no inode in dentry, then
the dentry is definitely invalid.  Seemed to be the opposite in the
existing code.

Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
---
 fs/9p/vfs_dentry.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 65fa2df5e49b..b0c3f8e8ea00 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -68,7 +68,7 @@ static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
 
 	inode = d_inode(dentry);
 	if (!inode)
-		goto out_valid;
+		return 0;
 
 	v9inode = V9FS_I(inode);
 	if (v9inode->cache_validity & V9FS_INO_INVALID_ATTR) {
@@ -91,7 +91,6 @@ static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
 		if (retval < 0)
 			return retval;
 	}
-out_valid:
 	return 1;
 }
 
-- 
2.37.2
Re: [PATCH v4 11/11] fs/9p: Fix revalidate
Posted by asmadeus@codewreck.org 2 years, 6 months ago
Eric Van Hensbergen wrote on Sat, Feb 18, 2023 at 12:33:23AM +0000:
> Unclear if this case ever happens, but if no inode in dentry, then
> the dentry is definitely invalid.  Seemed to be the opposite in the
> existing code.

Looking at other implementations of d_revalidate (ecryptfs, cifs, vfat)
it seems to be assumed that the inode is always valid.

I'd just remove the if, or if we keep it add a WARN or something for a
while so we can remove it in a few releases?

(That said, it's better to return 0 than 1 here, so don't take this for
a no -- progress is progress)
-- 
Dominique