Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Paulo Alcantara <pc@manguebit.com>
To: Henrique Carvalho <henrique.carvalho@suse.com>, sfrench@samba.org
Cc: ematsumiya@suse.de, ronniesahlberg@gmail.com,
	sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com,
	linux-cifs@vger.kernel.org,
	Henrique Carvalho <henrique.carvalho@suse.com>
Subject: Re: [PATCH 1/2] smb: client: disable directory caching when dir_cache_timeout is zero
Date: Fri, 22 Nov 2024 19:07:06 -0300	[thread overview]
Message-ID: <7e76e6d3a5a194b87ae98e13c354a4f8@manguebit.com> (raw)
In-Reply-To: <20241122203901.283703-1-henrique.carvalho@suse.com>

Henrique Carvalho <henrique.carvalho@suse.com> writes:

> According to the dir_cache_timeout description, setting it to zero
> should disable the caching of directory contents. However, even when
> dir_cache_timeout is zero, some caching related functions are still
> invoked, and the worker thread is initiated, which is unintended
> behavior.
>
> Fix the issue by setting tcon->nohandlecache to true when
> dir_cache_timeout is zero, ensuring that directory handle caching
> is properly disabled.
>
> Clean up the code to reflect this change, to improve consistency,
> and to remove other unnecessary checks.
>
> is_smb1_server() check inside open_cached_dir() can be removed because
> dir caching is only enabled for SMB versions >= 2.0.
>
> Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
> ---
>  fs/smb/client/cached_dir.c | 12 +++++++-----
>  fs/smb/client/cifsproto.h  |  2 +-
>  fs/smb/client/connect.c    | 10 +++++-----
>  fs/smb/client/misc.c       |  4 ++--
>  4 files changed, 15 insertions(+), 13 deletions(-)

The fix could be simply this:

	diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
	index b227d61a6f20..62a29183c655 100644
	--- a/fs/smb/client/connect.c
	+++ b/fs/smb/client/connect.c
	@@ -2614,7 +2614,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
	 
	 	if (ses->server->dialect >= SMB20_PROT_ID &&
	 	    (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING))
	-		nohandlecache = ctx->nohandlecache;
	+		nohandlecache = ctx->nohandlecache || !dir_cache_timeout;
	 	else
	 		nohandlecache = true;
	 	tcon = tcon_info_alloc(!nohandlecache, netfs_trace_tcon_ref_new);

and easily backported to -stable kernels that have

        238b351d0935 ("smb3: allow controlling length of time directory entries are cached with dir leases")

And yes, is_smb1_server() check makes no sense as tcon->nohandlecache
would already be set.

  parent reply	other threads:[~2024-11-22 22:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-22 20:39 [PATCH 1/2] smb: client: disable directory caching when dir_cache_timeout is zero Henrique Carvalho
2024-11-22 20:39 ` [PATCH 2/2] smb: client: remove unnecessary NULL check in open_cached_dir_by_dentry() Henrique Carvalho
2024-11-22 22:21   ` Paulo Alcantara
2024-11-22 22:07 ` Paulo Alcantara [this message]
2024-11-22 22:37   ` [PATCH 1/2] smb: client: disable directory caching when dir_cache_timeout is zero Henrique Carvalho
2024-11-22 22:55     ` Paulo Alcantara
2024-11-22 23:23       ` Henrique Carvalho
2024-11-22 23:59         ` Paulo Alcantara
2024-11-23  1:16           ` Henrique Carvalho

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=7e76e6d3a5a194b87ae98e13c354a4f8@manguebit.com \
    --to=pc@manguebit.com \
    --cc=bharathsm@microsoft.com \
    --cc=ematsumiya@suse.de \
    --cc=henrique.carvalho@suse.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=sfrench@samba.org \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /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