diff mbox series

[v2,2/3] smb: client: remove unnecessary checks in open_cached_dir()

Message ID 20241123011437.375637-2-henrique.carvalho@suse.com (mailing list archive)
State New
Headers show
Series [v2,1/3] smb: client: disable directory caching when dir_cache_timeout is zero | expand

Commit Message

Henrique Carvalho Nov. 23, 2024, 1:14 a.m. UTC
Checks inside open_cached_dir() can be removed because if dir caching is
disabled then tcon->cfids is necessarily NULL. Therefore, all other checks
are redundant.

Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
---
V1 -> V2: Split patch and addressed review comments

 fs/smb/client/cached_dir.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Enzo Matsumiya Nov. 25, 2024, 4:07 p.m. UTC | #1
On 11/22, Henrique Carvalho wrote:
>Checks inside open_cached_dir() can be removed because if dir caching is
>disabled then tcon->cfids is necessarily NULL. Therefore, all other checks
>are redundant.
>
>Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
>---
>V1 -> V2: Split patch and addressed review comments
>
> fs/smb/client/cached_dir.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
>diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
>index 8b510c858f4ff..85a8cc04e2c81 100644
>--- a/fs/smb/client/cached_dir.c
>+++ b/fs/smb/client/cached_dir.c
>@@ -162,15 +162,17 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
> 	const char *npath;
> 	int retries = 0, cur_sleep = 1;
>
>-	if (tcon == NULL || tcon->cfids == NULL || tcon->nohandlecache ||
>-	    is_smb1_server(tcon->ses->server) || (dir_cache_timeout == 0))
>+	if (cifs_sb->root == NULL)
>+		return -ENOENT;

Callers of open_cached_dir() seems to only handle its return value as
0 or -ENOENT, but if cifs_sb->root is NULL at this point (even though
unlikely), it's definitely neither.

Maybe returning something different here (e.g. -EIO) and handling it
properly in a follow up patch would be good.

>+
>+	if (tcon == NULL)
> 		return -EOPNOTSUPP;
>
> 	ses = tcon->ses;
> 	cfids = tcon->cfids;
>
>-	if (cifs_sb->root == NULL)
>-		return -ENOENT;
>+	if (cfids == NULL)
>+		return -EOPNOTSUPP;
>
> replay_again:
> 	/* reinitialize for possible replay */

Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>


Cheers
diff mbox series

Patch

diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 8b510c858f4ff..85a8cc04e2c81 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -162,15 +162,17 @@  int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
 	const char *npath;
 	int retries = 0, cur_sleep = 1;
 
-	if (tcon == NULL || tcon->cfids == NULL || tcon->nohandlecache ||
-	    is_smb1_server(tcon->ses->server) || (dir_cache_timeout == 0))
+	if (cifs_sb->root == NULL)
+		return -ENOENT;
+
+	if (tcon == NULL)
 		return -EOPNOTSUPP;
 
 	ses = tcon->ses;
 	cfids = tcon->cfids;
 
-	if (cifs_sb->root == NULL)
-		return -ENOENT;
+	if (cfids == NULL)
+		return -EOPNOTSUPP;
 
 replay_again:
 	/* reinitialize for possible replay */