Commit 2e6e02ab authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Move protocol specific tcon/tdis code to ops struct

and rename variables around the code changes.
Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 58c45c58
...@@ -160,6 +160,7 @@ struct mid_q_entry; ...@@ -160,6 +160,7 @@ struct mid_q_entry;
struct TCP_Server_Info; struct TCP_Server_Info;
struct cifsFileInfo; struct cifsFileInfo;
struct cifs_ses; struct cifs_ses;
struct cifs_tcon;
struct smb_version_operations { struct smb_version_operations {
int (*send_cancel)(struct TCP_Server_Info *, void *, int (*send_cancel)(struct TCP_Server_Info *, void *,
...@@ -201,6 +202,11 @@ struct smb_version_operations { ...@@ -201,6 +202,11 @@ struct smb_version_operations {
const struct nls_table *); const struct nls_table *);
/* close smb session */ /* close smb session */
int (*logoff)(const unsigned int, struct cifs_ses *); int (*logoff)(const unsigned int, struct cifs_ses *);
/* connect to a server share */
int (*tree_connect)(const unsigned int, struct cifs_ses *, const char *,
struct cifs_tcon *, const struct nls_table *);
/* close tree connecion */
int (*tree_disconnect)(const unsigned int, struct cifs_tcon *);
}; };
struct smb_version_values { struct smb_version_values {
......
...@@ -184,9 +184,9 @@ extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, ...@@ -184,9 +184,9 @@ extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
struct nls_table *nls_info); struct nls_table *nls_info);
extern int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses); extern int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses);
extern int CIFSTCon(unsigned int xid, struct cifs_ses *ses, extern int CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
const char *tree, struct cifs_tcon *tcon, const char *tree, struct cifs_tcon *tcon,
const struct nls_table *); const struct nls_table *);
extern int CIFSFindFirst(const int xid, struct cifs_tcon *tcon, extern int CIFSFindFirst(const int xid, struct cifs_tcon *tcon,
const char *searchName, const struct nls_table *nls_codepage, const char *searchName, const struct nls_table *nls_codepage,
...@@ -389,7 +389,7 @@ extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, ...@@ -389,7 +389,7 @@ extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
const loff_t start_offset, const __u64 len, const loff_t start_offset, const __u64 len,
struct file_lock *, const __u16 lock_type, struct file_lock *, const __u16 lock_type,
const bool waitFlag); const bool waitFlag);
extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon); extern int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
extern int CIFSSMBEcho(struct TCP_Server_Info *server); extern int CIFSSMBEcho(struct TCP_Server_Info *server);
extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses); extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
......
...@@ -694,7 +694,7 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses) ...@@ -694,7 +694,7 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses)
} }
int int
CIFSSMBTDis(const int xid, struct cifs_tcon *tcon) CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon)
{ {
struct smb_hdr *smb_buffer; struct smb_hdr *smb_buffer;
int rc = 0; int rc = 0;
......
...@@ -2542,7 +2542,7 @@ cifs_find_tcon(struct cifs_ses *ses, const char *unc) ...@@ -2542,7 +2542,7 @@ cifs_find_tcon(struct cifs_ses *ses, const char *unc)
static void static void
cifs_put_tcon(struct cifs_tcon *tcon) cifs_put_tcon(struct cifs_tcon *tcon)
{ {
int xid; unsigned int xid;
struct cifs_ses *ses = tcon->ses; struct cifs_ses *ses = tcon->ses;
cFYI(1, "%s: tc_count=%d", __func__, tcon->tc_count); cFYI(1, "%s: tc_count=%d", __func__, tcon->tc_count);
...@@ -2556,7 +2556,8 @@ cifs_put_tcon(struct cifs_tcon *tcon) ...@@ -2556,7 +2556,8 @@ cifs_put_tcon(struct cifs_tcon *tcon)
spin_unlock(&cifs_tcp_ses_lock); spin_unlock(&cifs_tcp_ses_lock);
xid = GetXid(); xid = GetXid();
CIFSSMBTDis(xid, tcon); if (ses->server->ops->tree_disconnect)
ses->server->ops->tree_disconnect(xid, tcon);
_FreeXid(xid); _FreeXid(xid);
cifs_fscache_release_super_cookie(tcon); cifs_fscache_release_super_cookie(tcon);
...@@ -2581,6 +2582,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) ...@@ -2581,6 +2582,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
return tcon; return tcon;
} }
if (!ses->server->ops->tree_connect) {
rc = -ENOSYS;
goto out_fail;
}
tcon = tconInfoAlloc(); tcon = tconInfoAlloc();
if (tcon == NULL) { if (tcon == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
...@@ -2603,13 +2609,15 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) ...@@ -2603,13 +2609,15 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
goto out_fail; goto out_fail;
} }
/* BB Do we need to wrap session_mutex around /*
* this TCon call and Unix SetFS as * BB Do we need to wrap session_mutex around this TCon call and Unix
* we do on SessSetup and reconnect? */ * SetFS as we do on SessSetup and reconnect?
*/
xid = GetXid(); xid = GetXid();
rc = CIFSTCon(xid, ses, volume_info->UNC, tcon, volume_info->local_nls); rc = ses->server->ops->tree_connect(xid, ses, volume_info->UNC, tcon,
volume_info->local_nls);
FreeXid(xid); FreeXid(xid);
cFYI(1, "CIFS Tcon rc = %d", rc); cFYI(1, "Tcon rc = %d", rc);
if (rc) if (rc)
goto out_fail; goto out_fail;
...@@ -2618,10 +2626,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) ...@@ -2618,10 +2626,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
cFYI(1, "DFS disabled (%d)", tcon->Flags); cFYI(1, "DFS disabled (%d)", tcon->Flags);
} }
tcon->seal = volume_info->seal; tcon->seal = volume_info->seal;
/* we can have only one retry value for a connection /*
to a share so for resources mounted more than once * We can have only one retry value for a connection to a share so for
to the same server share the last value passed in * resources mounted more than once to the same server share the last
for the retry flag is used */ * value passed in for the retry flag is used.
*/
tcon->retry = volume_info->retry; tcon->retry = volume_info->retry;
tcon->nocase = volume_info->nocase; tcon->nocase = volume_info->nocase;
tcon->local_lease = volume_info->local_lease; tcon->local_lease = volume_info->local_lease;
...@@ -2755,37 +2764,41 @@ cifs_match_super(struct super_block *sb, void *data) ...@@ -2755,37 +2764,41 @@ cifs_match_super(struct super_block *sb, void *data)
} }
int int
get_dfs_path(int xid, struct cifs_ses *pSesInfo, const char *old_path, get_dfs_path(int xid, struct cifs_ses *ses, const char *old_path,
const struct nls_table *nls_codepage, unsigned int *pnum_referrals, const struct nls_table *nls_codepage, unsigned int *num_referrals,
struct dfs_info3_param **preferrals, int remap) struct dfs_info3_param **referrals, int remap)
{ {
char *temp_unc; char *temp_unc;
int rc = 0; int rc = 0;
*pnum_referrals = 0; if (!ses->server->ops->tree_connect)
*preferrals = NULL; return -ENOSYS;
*num_referrals = 0;
*referrals = NULL;
if (pSesInfo->ipc_tid == 0) { if (ses->ipc_tid == 0) {
temp_unc = kmalloc(2 /* for slashes */ + temp_unc = kmalloc(2 /* for slashes */ +
strnlen(pSesInfo->serverName, strnlen(ses->serverName, SERVER_NAME_LEN_WITH_NULL * 2)
SERVER_NAME_LEN_WITH_NULL * 2) + 1 + 4 /* slash IPC$ */ + 2, GFP_KERNEL);
+ 1 + 4 /* slash IPC$ */ + 2,
GFP_KERNEL);
if (temp_unc == NULL) if (temp_unc == NULL)
return -ENOMEM; return -ENOMEM;
temp_unc[0] = '\\'; temp_unc[0] = '\\';
temp_unc[1] = '\\'; temp_unc[1] = '\\';
strcpy(temp_unc + 2, pSesInfo->serverName); strcpy(temp_unc + 2, ses->serverName);
strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); strcpy(temp_unc + 2 + strlen(ses->serverName), "\\IPC$");
rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); rc = ses->server->ops->tree_connect(xid, ses, temp_unc, NULL,
cFYI(1, "CIFS Tcon rc = %d ipc_tid = %d", rc, pSesInfo->ipc_tid); nls_codepage);
cFYI(1, "Tcon rc = %d ipc_tid = %d", rc, ses->ipc_tid);
kfree(temp_unc); kfree(temp_unc);
} }
if (rc == 0) if (rc == 0)
rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals, rc = CIFSGetDFSRefer(xid, ses, old_path, referrals,
pnum_referrals, nls_codepage, remap); num_referrals, nls_codepage, remap);
/* BB map targetUNCs to dfs_info3 structures, here or /*
in CIFSGetDFSRefer BB */ * BB - map targetUNCs to dfs_info3 structures, here or in
* CIFSGetDFSRefer.
*/
return rc; return rc;
} }
...@@ -3777,7 +3790,7 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) ...@@ -3777,7 +3790,7 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
* pointer may be NULL. * pointer may be NULL.
*/ */
int int
CIFSTCon(unsigned int xid, struct cifs_ses *ses, CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
const char *tree, struct cifs_tcon *tcon, const char *tree, struct cifs_tcon *tcon,
const struct nls_table *nls_codepage) const struct nls_table *nls_codepage)
{ {
......
...@@ -432,6 +432,8 @@ struct smb_version_operations smb1_operations = { ...@@ -432,6 +432,8 @@ struct smb_version_operations smb1_operations = {
.negotiate = cifs_negotiate, .negotiate = cifs_negotiate,
.sess_setup = CIFS_SessSetup, .sess_setup = CIFS_SessSetup,
.logoff = CIFSSMBLogoff, .logoff = CIFSSMBLogoff,
.tree_connect = CIFSTCon,
.tree_disconnect = CIFSSMBTDis,
}; };
struct smb_version_values smb1_values = { struct smb_version_values smb1_values = {
......
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