summaryrefslogtreecommitdiffstats
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-02 15:08:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-02 15:08:29 -0500
commitcacf02df4b84d261d76db3d290ccb6b951df28c0 (patch)
tree5f0655ff89210626854c747566b934e2e562830a /fs/cifs/misc.c
parent74673fc50babc9be22b32c4ce697fceb51c7671a (diff)
parentfea170804b4dc44cd79f8cb1ce236f3a824951cd (diff)
Merge tag '4.21-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs updates from Steve French: - four fixes for stable - improvements to DFS including allowing failover to alternate targets - some small performance improvements * tag '4.21-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: (39 commits) cifs: update internal module version number cifs: we can not use small padding iovs together with encryption cifs: Minor Kconfig clarification cifs: Always resolve hostname before reconnecting cifs: Add support for failover in cifs_reconnect_tcon() cifs: Add support for failover in smb2_reconnect() cifs: Only free DFS target list if we actually got one cifs: start DFS cache refresher in cifs_mount() cifs: Use GFP_ATOMIC when a lock is held in cifs_mount() cifs: Add support for failover in cifs_reconnect() cifs: Add support for failover in cifs_mount() cifs: remove set but not used variable 'sep' cifs: Make use of DFS cache to get new DFS referrals cifs: minor updates to documentation cifs: check kzalloc return cifs: remove set but not used variable 'server' cifs: Use kzfree() to free password cifs: Fix to use kmem_cache_free() instead of kfree() cifs: update for current_kernel_time64() removal cifs: Add DFS cache routines ...
Diffstat (limited to 'fs/cifs/misc.c')
-rw-r--r--fs/cifs/misc.c68
1 files changed, 52 insertions, 16 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 8a41f4eba726..bee203055b30 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -111,21 +111,27 @@ struct cifs_tcon *
111tconInfoAlloc(void) 111tconInfoAlloc(void)
112{ 112{
113 struct cifs_tcon *ret_buf; 113 struct cifs_tcon *ret_buf;
114 ret_buf = kzalloc(sizeof(struct cifs_tcon), GFP_KERNEL); 114
115 if (ret_buf) { 115 ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL);
116 atomic_inc(&tconInfoAllocCount); 116 if (!ret_buf)
117 ret_buf->tidStatus = CifsNew; 117 return NULL;
118 ++ret_buf->tc_count; 118 ret_buf->crfid.fid = kzalloc(sizeof(*ret_buf->crfid.fid), GFP_KERNEL);
119 INIT_LIST_HEAD(&ret_buf->openFileList); 119 if (!ret_buf->crfid.fid) {
120 INIT_LIST_HEAD(&ret_buf->tcon_list); 120 kfree(ret_buf);
121 spin_lock_init(&ret_buf->open_file_lock); 121 return NULL;
122 mutex_init(&ret_buf->crfid.fid_mutex);
123 ret_buf->crfid.fid = kzalloc(sizeof(struct cifs_fid),
124 GFP_KERNEL);
125 spin_lock_init(&ret_buf->stat_lock);
126 atomic_set(&ret_buf->num_local_opens, 0);
127 atomic_set(&ret_buf->num_remote_opens, 0);
128 } 122 }
123
124 atomic_inc(&tconInfoAllocCount);
125 ret_buf->tidStatus = CifsNew;
126 ++ret_buf->tc_count;
127 INIT_LIST_HEAD(&ret_buf->openFileList);
128 INIT_LIST_HEAD(&ret_buf->tcon_list);
129 spin_lock_init(&ret_buf->open_file_lock);
130 mutex_init(&ret_buf->crfid.fid_mutex);
131 spin_lock_init(&ret_buf->stat_lock);
132 atomic_set(&ret_buf->num_local_opens, 0);
133 atomic_set(&ret_buf->num_remote_opens, 0);
134
129 return ret_buf; 135 return ret_buf;
130} 136}
131 137
@@ -140,6 +146,9 @@ tconInfoFree(struct cifs_tcon *buf_to_free)
140 kfree(buf_to_free->nativeFileSystem); 146 kfree(buf_to_free->nativeFileSystem);
141 kzfree(buf_to_free->password); 147 kzfree(buf_to_free->password);
142 kfree(buf_to_free->crfid.fid); 148 kfree(buf_to_free->crfid.fid);
149#ifdef CONFIG_CIFS_DFS_UPCALL
150 kfree(buf_to_free->dfs_path);
151#endif
143 kfree(buf_to_free); 152 kfree(buf_to_free);
144} 153}
145 154
@@ -525,9 +534,17 @@ void
525cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb) 534cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
526{ 535{
527 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 536 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
537 struct cifs_tcon *tcon = NULL;
538
539 if (cifs_sb->master_tlink)
540 tcon = cifs_sb_master_tcon(cifs_sb);
541
528 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 542 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
529 cifs_dbg(VFS, "Autodisabling the use of server inode numbers on %s. This server doesn't seem to support them properly. Hardlinks will not be recognized on this mount. Consider mounting with the \"noserverino\" option to silence this message.\n", 543 cifs_dbg(VFS, "Autodisabling the use of server inode numbers on %s.\n",
530 cifs_sb_master_tcon(cifs_sb)->treeName); 544 tcon ? tcon->treeName : "new server");
545 cifs_dbg(VFS, "The server doesn't seem to support them properly or the files might be on different servers (DFS).\n");
546 cifs_dbg(VFS, "Hardlinks will not be recognized on this mount. Consider mounting with the \"noserverino\" option to silence this message.\n");
547
531 } 548 }
532} 549}
533 550
@@ -732,6 +749,8 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
732 goto parse_DFS_referrals_exit; 749 goto parse_DFS_referrals_exit;
733 } 750 }
734 751
752 node->ttl = le32_to_cpu(ref->TimeToLive);
753
735 ref++; 754 ref++;
736 } 755 }
737 756
@@ -933,3 +952,20 @@ void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
933 else if (page == 0) 952 else if (page == 0)
934 *len = rqst->rq_pagesz - rqst->rq_offset; 953 *len = rqst->rq_pagesz - rqst->rq_offset;
935} 954}
955
956void extract_unc_hostname(const char *unc, const char **h, size_t *len)
957{
958 const char *end;
959
960 /* skip initial slashes */
961 while (*unc && (*unc == '\\' || *unc == '/'))
962 unc++;
963
964 end = unc;
965
966 while (*end && !(*end == '\\' || *end == '/'))
967 end++;
968
969 *h = unc;
970 *len = end - unc;
971}