Commit 7eb59a98 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: Do not access tcon->cfids->cfid directly from is_path_accessible

cfids will soon keep a list of cached fids so we should not access this
directly from outside of cached_dir.c
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent a63ec83c
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
* If error then *cfid is not initialized. * If error then *cfid is not initialized.
*/ */
int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
const char *path, const char *path,
struct cifs_sb_info *cifs_sb, struct cifs_sb_info *cifs_sb,
struct cached_fid **ret_cfid) bool lookup_only, struct cached_fid **ret_cfid)
{ {
struct cifs_ses *ses; struct cifs_ses *ses;
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
...@@ -68,9 +68,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -68,9 +68,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
* cifs_mark_open_files_invalid() which takes the lock again * cifs_mark_open_files_invalid() which takes the lock again
* thus causing a deadlock * thus causing a deadlock
*/ */
mutex_unlock(&cfid->fid_mutex); mutex_unlock(&cfid->fid_mutex);
if (lookup_only)
return -ENOENT;
if (smb3_encryption_required(tcon)) if (smb3_encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ; flags |= CIFS_TRANSFORM_REQ;
......
...@@ -50,7 +50,7 @@ extern void free_cached_dir(struct cifs_tcon *tcon); ...@@ -50,7 +50,7 @@ extern void free_cached_dir(struct cifs_tcon *tcon);
extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
const char *path, const char *path,
struct cifs_sb_info *cifs_sb, struct cifs_sb_info *cifs_sb,
struct cached_fid **cfid); bool lookup_only, struct cached_fid **cfid);
extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon, extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
struct dentry *dentry, struct dentry *dentry,
struct cached_fid **cfid); struct cached_fid **cfid);
......
...@@ -1072,7 +1072,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) ...@@ -1072,7 +1072,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)
tcon = tlink_tcon(cifsFile->tlink); tcon = tlink_tcon(cifsFile->tlink);
} }
rc = open_cached_dir(xid, tcon, full_path, cifs_sb, &cfid); rc = open_cached_dir(xid, tcon, full_path, cifs_sb, false, &cfid);
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
if (rc) if (rc)
goto cache_not_found; goto cache_not_found;
...@@ -1143,7 +1143,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) ...@@ -1143,7 +1143,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)
tcon = tlink_tcon(cifsFile->tlink); tcon = tlink_tcon(cifsFile->tlink);
rc = find_cifs_entry(xid, tcon, ctx->pos, file, full_path, rc = find_cifs_entry(xid, tcon, ctx->pos, file, full_path,
&current_entry, &num_to_fill); &current_entry, &num_to_fill);
open_cached_dir(xid, tcon, full_path, cifs_sb, &cfid); open_cached_dir(xid, tcon, full_path, cifs_sb, false, &cfid);
if (rc) { if (rc) {
cifs_dbg(FYI, "fce error %d\n", rc); cifs_dbg(FYI, "fce error %d\n", rc);
goto rddir2_exit; goto rddir2_exit;
......
...@@ -516,7 +516,7 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -516,7 +516,7 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
if (strcmp(full_path, "")) if (strcmp(full_path, ""))
rc = -ENOENT; rc = -ENOENT;
else else
rc = open_cached_dir(xid, tcon, full_path, cifs_sb, &cfid); rc = open_cached_dir(xid, tcon, full_path, cifs_sb, false, &cfid);
/* If it is a root and its handle is cached then use it */ /* If it is a root and its handle is cached then use it */
if (!rc) { if (!rc) {
if (cfid->file_all_info_is_valid) { if (cfid->file_all_info_is_valid) {
......
...@@ -720,7 +720,7 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -720,7 +720,7 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon,
oparms.fid = &fid; oparms.fid = &fid;
oparms.reconnect = false; oparms.reconnect = false;
rc = open_cached_dir(xid, tcon, "", cifs_sb, &cfid); rc = open_cached_dir(xid, tcon, "", cifs_sb, false, &cfid);
if (rc == 0) if (rc == 0)
memcpy(&fid, &cfid->fid, sizeof(struct cifs_fid)); memcpy(&fid, &cfid->fid, sizeof(struct cifs_fid));
else else
...@@ -783,9 +783,16 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -783,9 +783,16 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
__u8 oplock = SMB2_OPLOCK_LEVEL_NONE; __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
struct cifs_open_parms oparms; struct cifs_open_parms oparms;
struct cifs_fid fid; struct cifs_fid fid;
struct cached_fid *cfid;
if ((*full_path == 0) && tcon->cfid->is_valid) rc = open_cached_dir(xid, tcon, full_path, cifs_sb, true, &cfid);
return 0; if (!rc) {
if (cfid->is_valid) {
close_cached_dir(cfid);
return 0;
}
close_cached_dir(cfid);
}
utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
if (!utf16_path) if (!utf16_path)
...@@ -2430,8 +2437,12 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -2430,8 +2437,12 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER; resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
memset(rsp_iov, 0, sizeof(rsp_iov)); memset(rsp_iov, 0, sizeof(rsp_iov));
/*
* We can only call this for things we know are directories.
*/
if (!strcmp(path, "")) if (!strcmp(path, ""))
open_cached_dir(xid, tcon, path, cifs_sb, &cfid); /* cfid null if open dir failed */ open_cached_dir(xid, tcon, path, cifs_sb, false,
&cfid); /* cfid null if open dir failed */
memset(&open_iov, 0, sizeof(open_iov)); memset(&open_iov, 0, sizeof(open_iov));
rqst[0].rq_iov = open_iov; rqst[0].rq_iov = open_iov;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment