diff mbox series

[SMB3] do not try to cache root directory if dir leases not supported

Message ID CAH2r5mvY127tWa5mtGDkxKU4gB6SyW5a_jjuAeoWmyDB9vCGrw@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series [SMB3] do not try to cache root directory if dir leases not supported | expand

Commit Message

Steve French Oct. 21, 2020, 5:25 a.m. UTC
To servers which do not support directory leases (e.g. Samba)
    it is wasteful to try to open_shroot (ie attempt to cache the
    root directory handle).  Skip attempt to open_shroot when
    server does not indicate support for directory leases.

    Cuts the number of requests on mount from 17 to 15, and
    cuts the number of requests on stat of the root directory
    from 4 to 3.

(also added cc: stable v5.1+)
diff mbox series

Patch

From b640e377cd8276a2f7406a6b473ba19f98a31fed Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Wed, 21 Oct 2020 00:15:42 -0500
Subject: [PATCH] smb3: do not try to cache root directory if dir leases not
 supported

To servers which do not support directory leases (e.g. Samba)
it is wasteful to try to open_shroot (ie attempt to cache the
root directory handle).  Skip attempt to open_shroot when
server does not indicate support for directory leases.

Cuts the number of requests on mount from 17 to 15, and
cuts the number of requests on stat of the root directory
from 4 to 3.

Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Stable <stable@vger.kernel.org> # v5.1+
---
 fs/cifs/connect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index b4282abc3d12..bcb539c22e39 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3608,7 +3608,10 @@  cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 	 */
 	tcon->retry = volume_info->retry;
 	tcon->nocase = volume_info->nocase;
-	tcon->nohandlecache = volume_info->nohandlecache;
+	if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
+		tcon->nohandlecache = volume_info->nohandlecache;
+	else
+		tcon->nohandlecache = 1;
 	tcon->nodelete = volume_info->nodelete;
 	tcon->local_lease = volume_info->local_lease;
 	INIT_LIST_HEAD(&tcon->pending_opens);
-- 
2.25.1