diff mbox series

[v2] 9p: v9fs_fid_find: also lookup by inode if not found dentry

Message ID 20240523210024.1214386-1-asmadeus@codewreck.org (mailing list archive)
State New
Headers show
Series [v2] 9p: v9fs_fid_find: also lookup by inode if not found dentry | expand

Commit Message

Dominique Martinet May 23, 2024, 9 p.m. UTC
It's possible for v9fs_fid_find "find by dentry" branch to not turn up
anything despite having an entry set (because e.g. uid doesn't match),
in which case the calling code will generally make an extra lookup
to the server.

In this case we might have had better luck looking by inode, so fall
back to look up by inode if we have one and the lookup by dentry failed.

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
v1 -> v2: fix build error

Sorry, shouldn't send patches without testing even if I'm not planning
to apply them for a while...

 fs/9p/fid.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Christian Schoenebeck May 26, 2024, 8:43 a.m. UTC | #1
On Thursday, May 23, 2024 11:00:23 PM CEST Dominique Martinet wrote:
> It's possible for v9fs_fid_find "find by dentry" branch to not turn up
> anything despite having an entry set (because e.g. uid doesn't match),
> in which case the calling code will generally make an extra lookup
> to the server.
> 
> In this case we might have had better luck looking by inode, so fall
> back to look up by inode if we have one and the lookup by dentry failed.

I'm not sure how that's supposed to happen. Both lookups check for (uid, any),
just on two separate fid lists (dentry vs. inode). But OTOH I don't see no
harm either, so:

Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>

> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
> ---
> v1 -> v2: fix build error
> 
> Sorry, shouldn't send patches without testing even if I'm not planning
> to apply them for a while...
> 
>  fs/9p/fid.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/9p/fid.c b/fs/9p/fid.c
> index de009a33e0e2..f84412290a30 100644
> --- a/fs/9p/fid.c
> +++ b/fs/9p/fid.c
> @@ -131,10 +131,9 @@ static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
>  			}
>  		}
>  		spin_unlock(&dentry->d_lock);
> -	} else {
> -		if (dentry->d_inode)
> -			ret = v9fs_fid_find_inode(dentry->d_inode, false, uid, any);
>  	}
> +	if (!ret && dentry->d_inode)
> +		ret = v9fs_fid_find_inode(dentry->d_inode, false, uid, any);
>  
>  	return ret;
>  }
>
diff mbox series

Patch

diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index de009a33e0e2..f84412290a30 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -131,10 +131,9 @@  static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
 			}
 		}
 		spin_unlock(&dentry->d_lock);
-	} else {
-		if (dentry->d_inode)
-			ret = v9fs_fid_find_inode(dentry->d_inode, false, uid, any);
 	}
+	if (!ret && dentry->d_inode)
+		ret = v9fs_fid_find_inode(dentry->d_inode, false, uid, any);
 
 	return ret;
 }