Commit aea6794e authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: Make tcon contain a wrapper structure cached_fids instead of cached_fid

This wrapper structure will later be expanded to contain a list of
fids that are cached and not just the root fid.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 68e14569
...@@ -52,7 +52,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -52,7 +52,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
dentry = cifs_sb->root; dentry = cifs_sb->root;
cfid = tcon->cfid; cfid = &tcon->cfids->cfid;
mutex_lock(&cfid->fid_mutex); mutex_lock(&cfid->fid_mutex);
if (cfid->is_valid) { if (cfid->is_valid) {
cifs_dbg(FYI, "found a cached root file handle\n"); cifs_dbg(FYI, "found a cached root file handle\n");
...@@ -226,7 +226,7 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon, ...@@ -226,7 +226,7 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
{ {
struct cached_fid *cfid; struct cached_fid *cfid;
cfid = tcon->cfid; cfid = &tcon->cfids->cfid;
mutex_lock(&cfid->fid_mutex); mutex_lock(&cfid->fid_mutex);
if (cfid->dentry == dentry) { if (cfid->dentry == dentry) {
...@@ -320,7 +320,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb) ...@@ -320,7 +320,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
tcon = tlink_tcon(tlink); tcon = tlink_tcon(tlink);
if (IS_ERR(tcon)) if (IS_ERR(tcon))
continue; continue;
cfid = tcon->cfid; cfid = &tcon->cfids->cfid;
mutex_lock(&cfid->fid_mutex); mutex_lock(&cfid->fid_mutex);
if (cfid->dentry) { if (cfid->dentry) {
dput(cfid->dentry); dput(cfid->dentry);
...@@ -336,12 +336,14 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb) ...@@ -336,12 +336,14 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
*/ */
void invalidate_all_cached_dirs(struct cifs_tcon *tcon) void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
{ {
mutex_lock(&tcon->cfid->fid_mutex); struct cached_fid *cfid = &tcon->cfids->cfid;
tcon->cfid->is_valid = false;
mutex_lock(&cfid->fid_mutex);
cfid->is_valid = false;
/* cached handle is not valid, so SMB2_CLOSE won't be sent below */ /* cached handle is not valid, so SMB2_CLOSE won't be sent below */
close_cached_dir_lease_locked(tcon->cfid); close_cached_dir_lease_locked(cfid);
memset(&tcon->cfid->fid, 0, sizeof(struct cifs_fid)); memset(&cfid->fid, 0, sizeof(struct cifs_fid));
mutex_unlock(&tcon->cfid->fid_mutex); mutex_unlock(&cfid->fid_mutex);
} }
static void static void
...@@ -355,34 +357,36 @@ smb2_cached_lease_break(struct work_struct *work) ...@@ -355,34 +357,36 @@ smb2_cached_lease_break(struct work_struct *work)
int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]) int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16])
{ {
if (tcon->cfid->is_valid && struct cached_fid *cfid = &tcon->cfids->cfid;
if (cfid->is_valid &&
!memcmp(lease_key, !memcmp(lease_key,
tcon->cfid->fid.lease_key, cfid->fid.lease_key,
SMB2_LEASE_KEY_SIZE)) { SMB2_LEASE_KEY_SIZE)) {
tcon->cfid->time = 0; cfid->time = 0;
INIT_WORK(&tcon->cfid->lease_break, INIT_WORK(&cfid->lease_break,
smb2_cached_lease_break); smb2_cached_lease_break);
queue_work(cifsiod_wq, queue_work(cifsiod_wq,
&tcon->cfid->lease_break); &cfid->lease_break);
return true; return true;
} }
return false; return false;
} }
struct cached_fid *init_cached_dir(void) struct cached_fids *init_cached_dirs(void)
{ {
struct cached_fid *cfid; struct cached_fids *cfids;
cfid = kzalloc(sizeof(*cfid), GFP_KERNEL); cfids = kzalloc(sizeof(*cfids), GFP_KERNEL);
if (!cfid) if (!cfids)
return NULL; return NULL;
INIT_LIST_HEAD(&cfid->dirents.entries); INIT_LIST_HEAD(&cfids->cfid.dirents.entries);
mutex_init(&cfid->dirents.de_mutex); mutex_init(&cfids->cfid.dirents.de_mutex);
mutex_init(&cfid->fid_mutex); mutex_init(&cfids->cfid.fid_mutex);
return cfid; return cfids;
} }
void free_cached_dir(struct cifs_tcon *tcon) void free_cached_dirs(struct cached_fids *cfids)
{ {
kfree(tcon->cfid); kfree(cfids);
} }
...@@ -45,8 +45,12 @@ struct cached_fid { ...@@ -45,8 +45,12 @@ struct cached_fid {
struct cached_dirents dirents; struct cached_dirents dirents;
}; };
extern struct cached_fid *init_cached_dir(void); struct cached_fids {
extern void free_cached_dir(struct cifs_tcon *tcon); struct cached_fid cfid;
};
extern struct cached_fids *init_cached_dirs(void);
extern void free_cached_dirs(struct cached_fids *cfids);
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,
......
...@@ -1228,7 +1228,7 @@ struct cifs_tcon { ...@@ -1228,7 +1228,7 @@ struct cifs_tcon {
struct fscache_volume *fscache; /* cookie for share */ struct fscache_volume *fscache; /* cookie for share */
#endif #endif
struct list_head pending_opens; /* list of incomplete opens */ struct list_head pending_opens; /* list of incomplete opens */
struct cached_fid *cfid; /* Cached root fid */ struct cached_fids *cfids;
/* BB add field for back pointer to sb struct(s)? */ /* BB add field for back pointer to sb struct(s)? */
#ifdef CONFIG_CIFS_DFS_UPCALL #ifdef CONFIG_CIFS_DFS_UPCALL
struct list_head ulist; /* cache update list */ struct list_head ulist; /* cache update list */
......
...@@ -117,8 +117,8 @@ tconInfoAlloc(void) ...@@ -117,8 +117,8 @@ tconInfoAlloc(void)
ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL); ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL);
if (!ret_buf) if (!ret_buf)
return NULL; return NULL;
ret_buf->cfid = init_cached_dir(); ret_buf->cfids = init_cached_dirs();
if (!ret_buf->cfid) { if (!ret_buf->cfids) {
kfree(ret_buf); kfree(ret_buf);
return NULL; return NULL;
} }
...@@ -144,7 +144,7 @@ tconInfoFree(struct cifs_tcon *tcon) ...@@ -144,7 +144,7 @@ tconInfoFree(struct cifs_tcon *tcon)
cifs_dbg(FYI, "Null buffer passed to tconInfoFree\n"); cifs_dbg(FYI, "Null buffer passed to tconInfoFree\n");
return; return;
} }
free_cached_dir(tcon); free_cached_dirs(tcon->cfids);
atomic_dec(&tconInfoAllocCount); atomic_dec(&tconInfoAllocCount);
kfree(tcon->nativeFileSystem); kfree(tcon->nativeFileSystem);
kfree_sensitive(tcon->password); kfree_sensitive(tcon->password);
......
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