Signed-off-by: Ronnie Sahlberg <lsahlber@xxxxxxxxxx> --- 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