aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-05-25 03:11:39 -0400
committerSteve French <smfrench@gmail.com>2012-07-24 11:25:06 -0400
commit2e6e02ab6ddbd539fd7e092973daf057adbd53dc (patch)
tree124ff8e0a300962e01c07a3cf9d8e660d404dec0 /fs/cifs/connect.c
parent58c45c58a1cbc8d2e1d07839820bf745fb3e7f41 (diff)
CIFS: Move protocol specific tcon/tdis code to ops struct
and rename variables around the code changes. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c73
1 files changed, 43 insertions, 30 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 444243d9232b..fcf20d1b58b9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2542,7 +2542,7 @@ cifs_find_tcon(struct cifs_ses *ses, const char *unc)
2542static void 2542static void
2543cifs_put_tcon(struct cifs_tcon *tcon) 2543cifs_put_tcon(struct cifs_tcon *tcon)
2544{ 2544{
2545 int xid; 2545 unsigned int xid;
2546 struct cifs_ses *ses = tcon->ses; 2546 struct cifs_ses *ses = tcon->ses;
2547 2547
2548 cFYI(1, "%s: tc_count=%d", __func__, tcon->tc_count); 2548 cFYI(1, "%s: tc_count=%d", __func__, tcon->tc_count);
@@ -2556,7 +2556,8 @@ cifs_put_tcon(struct cifs_tcon *tcon)
2556 spin_unlock(&cifs_tcp_ses_lock); 2556 spin_unlock(&cifs_tcp_ses_lock);
2557 2557
2558 xid = GetXid(); 2558 xid = GetXid();
2559 CIFSSMBTDis(xid, tcon); 2559 if (ses->server->ops->tree_disconnect)
2560 ses->server->ops->tree_disconnect(xid, tcon);
2560 _FreeXid(xid); 2561 _FreeXid(xid);
2561 2562
2562 cifs_fscache_release_super_cookie(tcon); 2563 cifs_fscache_release_super_cookie(tcon);
@@ -2581,6 +2582,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
2581 return tcon; 2582 return tcon;
2582 } 2583 }
2583 2584
2585 if (!ses->server->ops->tree_connect) {
2586 rc = -ENOSYS;
2587 goto out_fail;
2588 }
2589
2584 tcon = tconInfoAlloc(); 2590 tcon = tconInfoAlloc();
2585 if (tcon == NULL) { 2591 if (tcon == NULL) {
2586 rc = -ENOMEM; 2592 rc = -ENOMEM;
@@ -2603,13 +2609,15 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
2603 goto out_fail; 2609 goto out_fail;
2604 } 2610 }
2605 2611
2606 /* BB Do we need to wrap session_mutex around 2612 /*
2607 * this TCon call and Unix SetFS as 2613 * BB Do we need to wrap session_mutex around this TCon call and Unix
2608 * we do on SessSetup and reconnect? */ 2614 * SetFS as we do on SessSetup and reconnect?
2615 */
2609 xid = GetXid(); 2616 xid = GetXid();
2610 rc = CIFSTCon(xid, ses, volume_info->UNC, tcon, volume_info->local_nls); 2617 rc = ses->server->ops->tree_connect(xid, ses, volume_info->UNC, tcon,
2618 volume_info->local_nls);
2611 FreeXid(xid); 2619 FreeXid(xid);
2612 cFYI(1, "CIFS Tcon rc = %d", rc); 2620 cFYI(1, "Tcon rc = %d", rc);
2613 if (rc) 2621 if (rc)
2614 goto out_fail; 2622 goto out_fail;
2615 2623
@@ -2618,10 +2626,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
2618 cFYI(1, "DFS disabled (%d)", tcon->Flags); 2626 cFYI(1, "DFS disabled (%d)", tcon->Flags);
2619 } 2627 }
2620 tcon->seal = volume_info->seal; 2628 tcon->seal = volume_info->seal;
2621 /* we can have only one retry value for a connection 2629 /*
2622 to a share so for resources mounted more than once 2630 * We can have only one retry value for a connection to a share so for
2623 to the same server share the last value passed in 2631 * resources mounted more than once to the same server share the last
2624 for the retry flag is used */ 2632 * value passed in for the retry flag is used.
2633 */
2625 tcon->retry = volume_info->retry; 2634 tcon->retry = volume_info->retry;
2626 tcon->nocase = volume_info->nocase; 2635 tcon->nocase = volume_info->nocase;
2627 tcon->local_lease = volume_info->local_lease; 2636 tcon->local_lease = volume_info->local_lease;
@@ -2755,37 +2764,41 @@ out:
2755} 2764}
2756 2765
2757int 2766int
2758get_dfs_path(int xid, struct cifs_ses *pSesInfo, const char *old_path, 2767get_dfs_path(int xid, struct cifs_ses *ses, const char *old_path,
2759 const struct nls_table *nls_codepage, unsigned int *pnum_referrals, 2768 const struct nls_table *nls_codepage, unsigned int *num_referrals,
2760 struct dfs_info3_param **preferrals, int remap) 2769 struct dfs_info3_param **referrals, int remap)
2761{ 2770{
2762 char *temp_unc; 2771 char *temp_unc;
2763 int rc = 0; 2772 int rc = 0;
2764 2773
2765 *pnum_referrals = 0; 2774 if (!ses->server->ops->tree_connect)
2766 *preferrals = NULL; 2775 return -ENOSYS;
2776
2777 *num_referrals = 0;
2778 *referrals = NULL;
2767 2779
2768 if (pSesInfo->ipc_tid == 0) { 2780 if (ses->ipc_tid == 0) {
2769 temp_unc = kmalloc(2 /* for slashes */ + 2781 temp_unc = kmalloc(2 /* for slashes */ +
2770 strnlen(pSesInfo->serverName, 2782 strnlen(ses->serverName, SERVER_NAME_LEN_WITH_NULL * 2)
2771 SERVER_NAME_LEN_WITH_NULL * 2) 2783 + 1 + 4 /* slash IPC$ */ + 2, GFP_KERNEL);
2772 + 1 + 4 /* slash IPC$ */ + 2,
2773 GFP_KERNEL);
2774 if (temp_unc == NULL) 2784 if (temp_unc == NULL)
2775 return -ENOMEM; 2785 return -ENOMEM;
2776 temp_unc[0] = '\\'; 2786 temp_unc[0] = '\\';
2777 temp_unc[1] = '\\'; 2787 temp_unc[1] = '\\';
2778 strcpy(temp_unc + 2, pSesInfo->serverName); 2788 strcpy(temp_unc + 2, ses->serverName);
2779 strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); 2789 strcpy(temp_unc + 2 + strlen(ses->serverName), "\\IPC$");
2780 rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); 2790 rc = ses->server->ops->tree_connect(xid, ses, temp_unc, NULL,
2781 cFYI(1, "CIFS Tcon rc = %d ipc_tid = %d", rc, pSesInfo->ipc_tid); 2791 nls_codepage);
2792 cFYI(1, "Tcon rc = %d ipc_tid = %d", rc, ses->ipc_tid);
2782 kfree(temp_unc); 2793 kfree(temp_unc);
2783 } 2794 }
2784 if (rc == 0) 2795 if (rc == 0)
2785 rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals, 2796 rc = CIFSGetDFSRefer(xid, ses, old_path, referrals,
2786 pnum_referrals, nls_codepage, remap); 2797 num_referrals, nls_codepage, remap);
2787 /* BB map targetUNCs to dfs_info3 structures, here or 2798 /*
2788 in CIFSGetDFSRefer BB */ 2799 * BB - map targetUNCs to dfs_info3 structures, here or in
2800 * CIFSGetDFSRefer.
2801 */
2789 2802
2790 return rc; 2803 return rc;
2791} 2804}
@@ -3777,7 +3790,7 @@ out:
3777 * pointer may be NULL. 3790 * pointer may be NULL.
3778 */ 3791 */
3779int 3792int
3780CIFSTCon(unsigned int xid, struct cifs_ses *ses, 3793CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
3781 const char *tree, struct cifs_tcon *tcon, 3794 const char *tree, struct cifs_tcon *tcon,
3782 const struct nls_table *nls_codepage) 3795 const struct nls_table *nls_codepage)
3783{ 3796{