aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-09-20 19:01:35 -0400
committerSteve French <sfrench@us.ibm.com>2010-09-29 15:04:33 -0400
commit0d424ad0a4b8c08e45928bccfa5b4b240097b01b (patch)
tree40f383b138d2e8121cda4b28f1f7c4b9642fe5ec
parentf6acb9d0596889a774e142ed76cb05b90d9763d2 (diff)
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: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/cifsglob.h7
-rw-r--r--fs/cifs/connect.c4
-rw-r--r--fs/cifs/dir.c10
-rw-r--r--fs/cifs/fscache.c12
-rw-r--r--fs/cifs/inode.c29
-rw-r--r--fs/cifs/misc.c2
-rw-r--r--fs/cifs/readdir.c4
8 files changed, 42 insertions, 32 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index b9624abb7261..898d2a5cfad2 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -222,7 +222,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
222{ 222{
223 struct super_block *sb = dentry->d_sb; 223 struct super_block *sb = dentry->d_sb;
224 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 224 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
225 struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb); 225 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
226 int rc = -EOPNOTSUPP; 226 int rc = -EOPNOTSUPP;
227 int xid; 227 int xid;
228 228
@@ -364,7 +364,7 @@ static int
364cifs_show_options(struct seq_file *s, struct vfsmount *m) 364cifs_show_options(struct seq_file *s, struct vfsmount *m)
365{ 365{
366 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); 366 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb);
367 struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb); 367 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
368 struct sockaddr *srcaddr; 368 struct sockaddr *srcaddr;
369 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; 369 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
370 370
@@ -455,7 +455,7 @@ static void cifs_umount_begin(struct super_block *sb)
455 if (cifs_sb == NULL) 455 if (cifs_sb == NULL)
456 return; 456 return;
457 457
458 tcon = cifs_sb_tcon(cifs_sb); 458 tcon = cifs_sb_master_tcon(cifs_sb);
459 459
460 read_lock(&cifs_tcp_ses_lock); 460 read_lock(&cifs_tcp_ses_lock);
461 if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) { 461 if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index cc8300c741b6..c265ebdcd177 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -419,6 +419,13 @@ cifs_sb_tcon(struct cifs_sb_info *cifs_sb)
419 return cifs_sb->ptcon; 419 return cifs_sb->ptcon;
420} 420}
421 421
422/* This function is always expected to succeed */
423static inline struct cifsTconInfo *
424cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb)
425{
426 return cifs_sb->ptcon;
427}
428
422static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb) 429static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
423{ 430{
424 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 431 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index b4bacea54626..f6a3091c2874 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3025,9 +3025,9 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3025{ 3025{
3026 int rc = 0; 3026 int rc = 0;
3027 char *tmp; 3027 char *tmp;
3028 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
3028 3029
3029 if (cifs_sb_tcon(cifs_sb)) 3030 cifs_put_tcon(tcon);
3030 cifs_put_tcon(cifs_sb_tcon(cifs_sb));
3031 3031
3032 cifs_sb->ptcon = NULL; 3032 cifs_sb->ptcon = NULL;
3033 tmp = cifs_sb->prepath; 3033 tmp = cifs_sb->prepath;
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f660a15eb14f..fe02435acb3c 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -54,18 +54,18 @@ build_path_from_dentry(struct dentry *direntry)
54 int dfsplen; 54 int dfsplen;
55 char *full_path; 55 char *full_path;
56 char dirsep; 56 char dirsep;
57 struct cifs_sb_info *cifs_sb; 57 struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
58 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
58 59
59 if (direntry == NULL) 60 if (direntry == NULL)
60 return NULL; /* not much we can do if dentry is freed and 61 return NULL; /* not much we can do if dentry is freed and
61 we need to reopen the file after it was closed implicitly 62 we need to reopen the file after it was closed implicitly
62 when the server crashed */ 63 when the server crashed */
63 64
64 cifs_sb = CIFS_SB(direntry->d_sb);
65 dirsep = CIFS_DIR_SEP(cifs_sb); 65 dirsep = CIFS_DIR_SEP(cifs_sb);
66 pplen = cifs_sb->prepathlen; 66 pplen = cifs_sb->prepathlen;
67 if (cifs_sb_tcon(cifs_sb) && (cifs_sb_tcon(cifs_sb)->Flags & SMB_SHARE_IS_IN_DFS)) 67 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
68 dfsplen = strnlen(cifs_sb_tcon(cifs_sb)->treeName, MAX_TREE_SIZE + 1); 68 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
69 else 69 else
70 dfsplen = 0; 70 dfsplen = 0;
71cifs_bp_rename_retry: 71cifs_bp_rename_retry:
@@ -117,7 +117,7 @@ cifs_bp_rename_retry:
117 /* BB test paths to Windows with '/' in the midst of prepath */ 117 /* BB test paths to Windows with '/' in the midst of prepath */
118 118
119 if (dfsplen) { 119 if (dfsplen) {
120 strncpy(full_path, cifs_sb_tcon(cifs_sb)->treeName, dfsplen); 120 strncpy(full_path, tcon->treeName, dfsplen);
121 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { 121 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
122 int i; 122 int i;
123 for (i = 0; i < dfsplen; i++) { 123 for (i = 0; i < dfsplen; i++) {
diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
index ec4318b019cc..a2ad94efcfe6 100644
--- a/fs/cifs/fscache.c
+++ b/fs/cifs/fscache.c
@@ -62,15 +62,15 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
62{ 62{
63 struct cifsInodeInfo *cifsi = CIFS_I(inode); 63 struct cifsInodeInfo *cifsi = CIFS_I(inode);
64 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 64 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
65 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
65 66
66 if (cifsi->fscache) 67 if (cifsi->fscache)
67 return; 68 return;
68 69
69 cifsi->fscache = fscache_acquire_cookie(cifs_sb_tcon(cifs_sb)->fscache, 70 cifsi->fscache = fscache_acquire_cookie(tcon->fscache,
70 &cifs_fscache_inode_object_def, 71 &cifs_fscache_inode_object_def, cifsi);
71 cifsi); 72 cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", tcon->fscache,
72 cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", 73 cifsi->fscache);
73 cifs_sb_tcon(cifs_sb)->fscache, cifsi->fscache);
74} 74}
75 75
76void cifs_fscache_release_inode_cookie(struct inode *inode) 76void cifs_fscache_release_inode_cookie(struct inode *inode)
@@ -118,7 +118,7 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
118 fscache_relinquish_cookie(cifsi->fscache, 1); 118 fscache_relinquish_cookie(cifsi->fscache, 1);
119 119
120 cifsi->fscache = fscache_acquire_cookie( 120 cifsi->fscache = fscache_acquire_cookie(
121 cifs_sb_tcon(cifs_sb)->fscache, 121 cifs_sb_master_tcon(cifs_sb)->fscache,
122 &cifs_fscache_inode_object_def, 122 &cifs_fscache_inode_object_def,
123 cifsi); 123 cifsi);
124 cFYI(1, "CIFS: new cookie 0x%p oldcookie 0x%p", 124 cFYI(1, "CIFS: new cookie 0x%p oldcookie 0x%p",
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index dce2d598927e..da716d96dae6 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -52,7 +52,7 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)
52 52
53 53
54 /* check if server can support readpages */ 54 /* check if server can support readpages */
55 if (cifs_sb_tcon(cifs_sb)->ses->server->maxBuf < 55 if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf <
56 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) 56 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
57 inode->i_data.a_ops = &cifs_addr_ops_smallbuf; 57 inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
58 else 58 else
@@ -476,6 +476,8 @@ static void
476cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, 476cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
477 struct cifs_sb_info *cifs_sb, bool adjust_tz) 477 struct cifs_sb_info *cifs_sb, bool adjust_tz)
478{ 478{
479 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
480
479 memset(fattr, 0, sizeof(*fattr)); 481 memset(fattr, 0, sizeof(*fattr));
480 fattr->cf_cifsattrs = le32_to_cpu(info->Attributes); 482 fattr->cf_cifsattrs = le32_to_cpu(info->Attributes);
481 if (info->DeletePending) 483 if (info->DeletePending)
@@ -490,8 +492,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
490 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); 492 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
491 493
492 if (adjust_tz) { 494 if (adjust_tz) {
493 fattr->cf_ctime.tv_sec += cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; 495 fattr->cf_ctime.tv_sec += tcon->ses->server->timeAdj;
494 fattr->cf_mtime.tv_sec += cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; 496 fattr->cf_mtime.tv_sec += tcon->ses->server->timeAdj;
495 } 497 }
496 498
497 fattr->cf_eof = le64_to_cpu(info->EndOfFile); 499 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 int pplen = cifs_sb->prepathlen; 700 int pplen = cifs_sb->prepathlen;
699 int dfsplen; 701 int dfsplen;
700 char *full_path = NULL; 702 char *full_path = NULL;
703 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
701 704
702 /* if no prefix path, simply set path to the root of share to "" */ 705 /* if no prefix path, simply set path to the root of share to "" */
703 if (pplen == 0) { 706 if (pplen == 0) {
@@ -707,8 +710,8 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
707 return full_path; 710 return full_path;
708 } 711 }
709 712
710 if (cifs_sb_tcon(cifs_sb) && (cifs_sb_tcon(cifs_sb)->Flags & SMB_SHARE_IS_IN_DFS)) 713 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
711 dfsplen = strnlen(cifs_sb_tcon(cifs_sb)->treeName, MAX_TREE_SIZE + 1); 714 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
712 else 715 else
713 dfsplen = 0; 716 dfsplen = 0;
714 717
@@ -717,7 +720,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
717 return full_path; 720 return full_path;
718 721
719 if (dfsplen) { 722 if (dfsplen) {
720 strncpy(full_path, cifs_sb_tcon(cifs_sb)->treeName, dfsplen); 723 strncpy(full_path, tcon->treeName, dfsplen);
721 /* switch slash direction in prepath depending on whether 724 /* switch slash direction in prepath depending on whether
722 * windows or posix style path names 725 * windows or posix style path names
723 */ 726 */
@@ -831,18 +834,18 @@ retry_iget5_locked:
831struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino) 834struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
832{ 835{
833 int xid; 836 int xid;
834 struct cifs_sb_info *cifs_sb; 837 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
835 struct inode *inode = NULL; 838 struct inode *inode = NULL;
836 long rc; 839 long rc;
837 char *full_path; 840 char *full_path;
841 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
838 842
839 cifs_sb = CIFS_SB(sb);
840 full_path = cifs_build_path_to_root(cifs_sb); 843 full_path = cifs_build_path_to_root(cifs_sb);
841 if (full_path == NULL) 844 if (full_path == NULL)
842 return ERR_PTR(-ENOMEM); 845 return ERR_PTR(-ENOMEM);
843 846
844 xid = GetXid(); 847 xid = GetXid();
845 if (cifs_sb_tcon(cifs_sb)->unix_ext) 848 if (tcon->unix_ext)
846 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); 849 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
847 else 850 else
848 rc = cifs_get_inode_info(&inode, full_path, NULL, sb, 851 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 856
854#ifdef CONFIG_CIFS_FSCACHE 857#ifdef CONFIG_CIFS_FSCACHE
855 /* populate tcon->resource_id */ 858 /* populate tcon->resource_id */
856 cifs_sb_tcon(cifs_sb)->resource_id = CIFS_I(inode)->uniqueid; 859 tcon->resource_id = CIFS_I(inode)->uniqueid;
857#endif 860#endif
858 861
859 if (rc && cifs_sb_tcon(cifs_sb)->ipc) { 862 if (rc && tcon->ipc) {
860 cFYI(1, "ipc connection - fake read inode"); 863 cFYI(1, "ipc connection - fake read inode");
861 inode->i_mode |= S_IFDIR; 864 inode->i_mode |= S_IFDIR;
862 inode->i_nlink = 2; 865 inode->i_nlink = 2;
@@ -1661,7 +1664,7 @@ int cifs_revalidate_dentry(struct dentry *dentry)
1661 "jiffies %ld", full_path, inode, inode->i_count.counter, 1664 "jiffies %ld", full_path, inode, inode->i_count.counter,
1662 dentry, dentry->d_time, jiffies); 1665 dentry, dentry->d_time, jiffies);
1663 1666
1664 if (cifs_sb_tcon(CIFS_SB(sb))->unix_ext) 1667 if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
1665 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); 1668 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
1666 else 1669 else
1667 rc = cifs_get_inode_info(&inode, full_path, NULL, sb, 1670 rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
@@ -2087,7 +2090,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs)
2087{ 2090{
2088 struct inode *inode = direntry->d_inode; 2091 struct inode *inode = direntry->d_inode;
2089 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2092 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
2090 struct cifsTconInfo *pTcon = cifs_sb_tcon(cifs_sb); 2093 struct cifsTconInfo *pTcon = cifs_sb_master_tcon(cifs_sb);
2091 2094
2092 if (pTcon->unix_ext) 2095 if (pTcon->unix_ext)
2093 return cifs_setattr_unix(direntry, attrs); 2096 return cifs_setattr_unix(direntry, attrs);
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index c5cbfdb2a58b..252f2768db84 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -729,6 +729,6 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
729 "properly. Hardlinks will not be recognized on this " 729 "properly. Hardlinks will not be recognized on this "
730 "mount. Consider mounting with the \"noserverino\" " 730 "mount. Consider mounting with the \"noserverino\" "
731 "option to silence this message.", 731 "option to silence this message.",
732 cifs_sb_tcon(cifs_sb)->treeName); 732 cifs_sb_master_tcon(cifs_sb)->treeName);
733 } 733 }
734} 734}
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 3efc2424964f..887a7e230376 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -102,7 +102,7 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
102 return NULL; 102 return NULL;
103 } 103 }
104 104
105 if (cifs_sb_tcon(CIFS_SB(sb))->nocase) 105 if (cifs_sb_master_tcon(CIFS_SB(sb))->nocase)
106 dentry->d_op = &cifs_ci_dentry_ops; 106 dentry->d_op = &cifs_ci_dentry_ops;
107 else 107 else
108 dentry->d_op = &cifs_dentry_ops; 108 dentry->d_op = &cifs_dentry_ops;
@@ -171,7 +171,7 @@ static void
171cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info, 171cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info,
172 struct cifs_sb_info *cifs_sb) 172 struct cifs_sb_info *cifs_sb)
173{ 173{
174 int offset = cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; 174 int offset = cifs_sb_master_tcon(cifs_sb)->ses->server->timeAdj;
175 175
176 memset(fattr, 0, sizeof(*fattr)); 176 memset(fattr, 0, sizeof(*fattr));
177 fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate, 177 fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate,