Commit 0d424ad0 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: add cifs_sb_master_tcon and convert some callers to use it

At mount time, we'll always need to create a tcon that will serve as a
template for others that are associated with the mount. This tcon is
known as the "master" tcon.

In some cases, we'll need to use that tcon regardless of who's accessing
the mount. Add an accessor function for the master tcon and go ahead and
switch the appropriate places to use it.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent f6acb9d0
...@@ -222,7 +222,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -222,7 +222,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
{ {
struct super_block *sb = dentry->d_sb; struct super_block *sb = dentry->d_sb;
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb); struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
int rc = -EOPNOTSUPP; int rc = -EOPNOTSUPP;
int xid; int xid;
...@@ -364,7 +364,7 @@ static int ...@@ -364,7 +364,7 @@ static int
cifs_show_options(struct seq_file *s, struct vfsmount *m) cifs_show_options(struct seq_file *s, struct vfsmount *m)
{ {
struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb);
struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb); struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
struct sockaddr *srcaddr; struct sockaddr *srcaddr;
srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
...@@ -455,7 +455,7 @@ static void cifs_umount_begin(struct super_block *sb) ...@@ -455,7 +455,7 @@ static void cifs_umount_begin(struct super_block *sb)
if (cifs_sb == NULL) if (cifs_sb == NULL)
return; return;
tcon = cifs_sb_tcon(cifs_sb); tcon = cifs_sb_master_tcon(cifs_sb);
read_lock(&cifs_tcp_ses_lock); read_lock(&cifs_tcp_ses_lock);
if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) { if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
......
...@@ -419,6 +419,13 @@ cifs_sb_tcon(struct cifs_sb_info *cifs_sb) ...@@ -419,6 +419,13 @@ cifs_sb_tcon(struct cifs_sb_info *cifs_sb)
return cifs_sb->ptcon; return cifs_sb->ptcon;
} }
/* This function is always expected to succeed */
static inline struct cifsTconInfo *
cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb)
{
return cifs_sb->ptcon;
}
static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb) static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
{ {
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
......
...@@ -3025,9 +3025,9 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) ...@@ -3025,9 +3025,9 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
{ {
int rc = 0; int rc = 0;
char *tmp; char *tmp;
struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
if (cifs_sb_tcon(cifs_sb)) cifs_put_tcon(tcon);
cifs_put_tcon(cifs_sb_tcon(cifs_sb));
cifs_sb->ptcon = NULL; cifs_sb->ptcon = NULL;
tmp = cifs_sb->prepath; tmp = cifs_sb->prepath;
......
...@@ -54,18 +54,18 @@ build_path_from_dentry(struct dentry *direntry) ...@@ -54,18 +54,18 @@ build_path_from_dentry(struct dentry *direntry)
int dfsplen; int dfsplen;
char *full_path; char *full_path;
char dirsep; char dirsep;
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
if (direntry == NULL) if (direntry == NULL)
return NULL; /* not much we can do if dentry is freed and return NULL; /* not much we can do if dentry is freed and
we need to reopen the file after it was closed implicitly we need to reopen the file after it was closed implicitly
when the server crashed */ when the server crashed */
cifs_sb = CIFS_SB(direntry->d_sb);
dirsep = CIFS_DIR_SEP(cifs_sb); dirsep = CIFS_DIR_SEP(cifs_sb);
pplen = cifs_sb->prepathlen; pplen = cifs_sb->prepathlen;
if (cifs_sb_tcon(cifs_sb) && (cifs_sb_tcon(cifs_sb)->Flags & SMB_SHARE_IS_IN_DFS)) if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
dfsplen = strnlen(cifs_sb_tcon(cifs_sb)->treeName, MAX_TREE_SIZE + 1); dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
else else
dfsplen = 0; dfsplen = 0;
cifs_bp_rename_retry: cifs_bp_rename_retry:
...@@ -117,7 +117,7 @@ build_path_from_dentry(struct dentry *direntry) ...@@ -117,7 +117,7 @@ build_path_from_dentry(struct dentry *direntry)
/* BB test paths to Windows with '/' in the midst of prepath */ /* BB test paths to Windows with '/' in the midst of prepath */
if (dfsplen) { if (dfsplen) {
strncpy(full_path, cifs_sb_tcon(cifs_sb)->treeName, dfsplen); strncpy(full_path, tcon->treeName, dfsplen);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
int i; int i;
for (i = 0; i < dfsplen; i++) { for (i = 0; i < dfsplen; i++) {
......
...@@ -62,15 +62,15 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode) ...@@ -62,15 +62,15 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
{ {
struct cifsInodeInfo *cifsi = CIFS_I(inode); struct cifsInodeInfo *cifsi = CIFS_I(inode);
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
if (cifsi->fscache) if (cifsi->fscache)
return; return;
cifsi->fscache = fscache_acquire_cookie(cifs_sb_tcon(cifs_sb)->fscache, cifsi->fscache = fscache_acquire_cookie(tcon->fscache,
&cifs_fscache_inode_object_def, &cifs_fscache_inode_object_def, cifsi);
cifsi); cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", tcon->fscache,
cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", cifsi->fscache);
cifs_sb_tcon(cifs_sb)->fscache, cifsi->fscache);
} }
void cifs_fscache_release_inode_cookie(struct inode *inode) void cifs_fscache_release_inode_cookie(struct inode *inode)
...@@ -118,7 +118,7 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode) ...@@ -118,7 +118,7 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
fscache_relinquish_cookie(cifsi->fscache, 1); fscache_relinquish_cookie(cifsi->fscache, 1);
cifsi->fscache = fscache_acquire_cookie( cifsi->fscache = fscache_acquire_cookie(
cifs_sb_tcon(cifs_sb)->fscache, cifs_sb_master_tcon(cifs_sb)->fscache,
&cifs_fscache_inode_object_def, &cifs_fscache_inode_object_def,
cifsi); cifsi);
cFYI(1, "CIFS: new cookie 0x%p oldcookie 0x%p", cFYI(1, "CIFS: new cookie 0x%p oldcookie 0x%p",
......
...@@ -52,7 +52,7 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral) ...@@ -52,7 +52,7 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)
/* check if server can support readpages */ /* check if server can support readpages */
if (cifs_sb_tcon(cifs_sb)->ses->server->maxBuf < if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
inode->i_data.a_ops = &cifs_addr_ops_smallbuf; inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
...@@ -476,6 +476,8 @@ static void ...@@ -476,6 +476,8 @@ static void
cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
struct cifs_sb_info *cifs_sb, bool adjust_tz) struct cifs_sb_info *cifs_sb, bool adjust_tz)
{ {
struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
memset(fattr, 0, sizeof(*fattr)); memset(fattr, 0, sizeof(*fattr));
fattr->cf_cifsattrs = le32_to_cpu(info->Attributes); fattr->cf_cifsattrs = le32_to_cpu(info->Attributes);
if (info->DeletePending) if (info->DeletePending)
...@@ -490,8 +492,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, ...@@ -490,8 +492,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
if (adjust_tz) { if (adjust_tz) {
fattr->cf_ctime.tv_sec += cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; fattr->cf_ctime.tv_sec += tcon->ses->server->timeAdj;
fattr->cf_mtime.tv_sec += cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; fattr->cf_mtime.tv_sec += tcon->ses->server->timeAdj;
} }
fattr->cf_eof = le64_to_cpu(info->EndOfFile); fattr->cf_eof = le64_to_cpu(info->EndOfFile);
...@@ -698,6 +700,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb) ...@@ -698,6 +700,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
int pplen = cifs_sb->prepathlen; int pplen = cifs_sb->prepathlen;
int dfsplen; int dfsplen;
char *full_path = NULL; char *full_path = NULL;
struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
/* if no prefix path, simply set path to the root of share to "" */ /* if no prefix path, simply set path to the root of share to "" */
if (pplen == 0) { if (pplen == 0) {
...@@ -707,8 +710,8 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb) ...@@ -707,8 +710,8 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
return full_path; return full_path;
} }
if (cifs_sb_tcon(cifs_sb) && (cifs_sb_tcon(cifs_sb)->Flags & SMB_SHARE_IS_IN_DFS)) if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
dfsplen = strnlen(cifs_sb_tcon(cifs_sb)->treeName, MAX_TREE_SIZE + 1); dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
else else
dfsplen = 0; dfsplen = 0;
...@@ -717,7 +720,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb) ...@@ -717,7 +720,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
return full_path; return full_path;
if (dfsplen) { if (dfsplen) {
strncpy(full_path, cifs_sb_tcon(cifs_sb)->treeName, dfsplen); strncpy(full_path, tcon->treeName, dfsplen);
/* switch slash direction in prepath depending on whether /* switch slash direction in prepath depending on whether
* windows or posix style path names * windows or posix style path names
*/ */
...@@ -831,18 +834,18 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr) ...@@ -831,18 +834,18 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr)
struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino) struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
{ {
int xid; int xid;
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct inode *inode = NULL; struct inode *inode = NULL;
long rc; long rc;
char *full_path; char *full_path;
struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
cifs_sb = CIFS_SB(sb);
full_path = cifs_build_path_to_root(cifs_sb); full_path = cifs_build_path_to_root(cifs_sb);
if (full_path == NULL) if (full_path == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
xid = GetXid(); xid = GetXid();
if (cifs_sb_tcon(cifs_sb)->unix_ext) if (tcon->unix_ext)
rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
else else
rc = cifs_get_inode_info(&inode, full_path, NULL, sb, rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
...@@ -853,10 +856,10 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino) ...@@ -853,10 +856,10 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
#ifdef CONFIG_CIFS_FSCACHE #ifdef CONFIG_CIFS_FSCACHE
/* populate tcon->resource_id */ /* populate tcon->resource_id */
cifs_sb_tcon(cifs_sb)->resource_id = CIFS_I(inode)->uniqueid; tcon->resource_id = CIFS_I(inode)->uniqueid;
#endif #endif
if (rc && cifs_sb_tcon(cifs_sb)->ipc) { if (rc && tcon->ipc) {
cFYI(1, "ipc connection - fake read inode"); cFYI(1, "ipc connection - fake read inode");
inode->i_mode |= S_IFDIR; inode->i_mode |= S_IFDIR;
inode->i_nlink = 2; inode->i_nlink = 2;
...@@ -1661,7 +1664,7 @@ int cifs_revalidate_dentry(struct dentry *dentry) ...@@ -1661,7 +1664,7 @@ int cifs_revalidate_dentry(struct dentry *dentry)
"jiffies %ld", full_path, inode, inode->i_count.counter, "jiffies %ld", full_path, inode, inode->i_count.counter,
dentry, dentry->d_time, jiffies); dentry, dentry->d_time, jiffies);
if (cifs_sb_tcon(CIFS_SB(sb))->unix_ext) if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
else else
rc = cifs_get_inode_info(&inode, full_path, NULL, sb, rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
...@@ -2087,7 +2090,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -2087,7 +2090,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs)
{ {
struct inode *inode = direntry->d_inode; struct inode *inode = direntry->d_inode;
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct cifsTconInfo *pTcon = cifs_sb_tcon(cifs_sb); struct cifsTconInfo *pTcon = cifs_sb_master_tcon(cifs_sb);
if (pTcon->unix_ext) if (pTcon->unix_ext)
return cifs_setattr_unix(direntry, attrs); return cifs_setattr_unix(direntry, attrs);
......
...@@ -729,6 +729,6 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb) ...@@ -729,6 +729,6 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
"properly. Hardlinks will not be recognized on this " "properly. Hardlinks will not be recognized on this "
"mount. Consider mounting with the \"noserverino\" " "mount. Consider mounting with the \"noserverino\" "
"option to silence this message.", "option to silence this message.",
cifs_sb_tcon(cifs_sb)->treeName); cifs_sb_master_tcon(cifs_sb)->treeName);
} }
} }
...@@ -102,7 +102,7 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name, ...@@ -102,7 +102,7 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
return NULL; return NULL;
} }
if (cifs_sb_tcon(CIFS_SB(sb))->nocase) if (cifs_sb_master_tcon(CIFS_SB(sb))->nocase)
dentry->d_op = &cifs_ci_dentry_ops; dentry->d_op = &cifs_ci_dentry_ops;
else else
dentry->d_op = &cifs_dentry_ops; dentry->d_op = &cifs_dentry_ops;
...@@ -171,7 +171,7 @@ static void ...@@ -171,7 +171,7 @@ static void
cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info, cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info,
struct cifs_sb_info *cifs_sb) struct cifs_sb_info *cifs_sb)
{ {
int offset = cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; int offset = cifs_sb_master_tcon(cifs_sb)->ses->server->timeAdj;
memset(fattr, 0, sizeof(*fattr)); memset(fattr, 0, sizeof(*fattr));
fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate, fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate,
......
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