linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ronnie Sahlberg <lsahlber@redhat.com>
To: linux-cifs <linux-cifs@vger.kernel.org>
Cc: Ronnie Sahlberg <lsahlber@redhat.com>
Subject: [PATCH] cifs: use the cached root handle for readdir() if possible
Date: Wed, 16 Oct 2019 16:55:10 +1000	[thread overview]
Message-ID: <20191016065510.31291-1-lsahlber@redhat.com> (raw)

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


                 reply	other threads:[~2019-10-16  6:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191016065510.31291-1-lsahlber@redhat.com \
    --to=lsahlber@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).