All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: use the cached root handle for readdir() if possible
@ 2019-10-16  6:55 Ronnie Sahlberg
  0 siblings, 0 replies; only message in thread
From: Ronnie Sahlberg @ 2019-10-16  6:55 UTC (permalink / raw)
  To: linux-cifs; +Cc: Ronnie Sahlberg

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/smb2ops.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 4c0922596467..7aab18552dd8 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -681,7 +681,7 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
 
 	oparms.tcon = tcon;
 	oparms.create_options = 0;
-	oparms.desired_access = FILE_READ_ATTRIBUTES;
+	oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
 	oparms.disposition = FILE_OPEN;
 	oparms.fid = pfid;
 	oparms.reconnect = false;
@@ -1999,6 +1999,14 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
 	int rc;
 	__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
 	struct cifs_open_parms oparms;
+	bool no_cached_open = tcon->nohandlecache;
+
+	if (!strlen(path) && !no_cached_open) {
+		rc = open_shroot(xid, tcon, fid);
+		if (rc)
+			return rc;
+		goto after_open;
+	}
 
 	utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
 	if (!utf16_path)
@@ -2021,6 +2029,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
 		return rc;
 	}
 
+ after_open:
 	srch_inf->entries_in_buffer = 0;
 	srch_inf->index_of_last_entry = 2;
 
@@ -2046,6 +2055,13 @@ static int
 smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
 	       struct cifs_fid *fid)
 {
+	if (tcon->crfid.is_valid &&
+	    tcon->crfid.fid->persistent_fid == fid->persistent_fid &&
+	    tcon->crfid.fid->volatile_fid == fid->volatile_fid) {
+		close_shroot(&tcon->crfid);
+		return 0;
+	}
+
 	return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
 }
 
-- 
2.13.6


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-16  6:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16  6:55 [PATCH] cifs: use the cached root handle for readdir() if possible Ronnie Sahlberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.