Commit f780bd3f authored by Aurelien Aptel's avatar Aurelien Aptel Committed by Steve French

cifs: add server param

As we get down to the transport layer, plenty of functions are passed
the session pointer and assume the transport to use is ses->server.

Instead we modify those functions to pass (ses, server) so that we
can decouple the session from the server.
Signed-off-by: default avatarAurelien Aptel <aaptel@suse.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent bcc88801
...@@ -230,6 +230,7 @@ struct smb_version_operations { ...@@ -230,6 +230,7 @@ struct smb_version_operations {
bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *); bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
/* setup request: allocate mid, sign message */ /* setup request: allocate mid, sign message */
struct mid_q_entry *(*setup_request)(struct cifs_ses *, struct mid_q_entry *(*setup_request)(struct cifs_ses *,
struct TCP_Server_Info *,
struct smb_rqst *); struct smb_rqst *);
/* setup async request: allocate mid, sign message */ /* setup async request: allocate mid, sign message */
struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *, struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *,
......
...@@ -109,6 +109,7 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, ...@@ -109,6 +109,7 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
char *in_buf, int flags); char *in_buf, int flags);
extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *, extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *,
struct TCP_Server_Info *,
struct smb_rqst *); struct smb_rqst *);
extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *, extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *,
struct smb_rqst *); struct smb_rqst *);
......
...@@ -46,6 +46,7 @@ extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *); ...@@ -46,6 +46,7 @@ extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *);
extern int smb2_check_receive(struct mid_q_entry *mid, extern int smb2_check_receive(struct mid_q_entry *mid,
struct TCP_Server_Info *server, bool log_error); struct TCP_Server_Info *server, bool log_error);
extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses, extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
struct TCP_Server_Info *,
struct smb_rqst *rqst); struct smb_rqst *rqst);
extern struct mid_q_entry *smb2_setup_async_request( extern struct mid_q_entry *smb2_setup_async_request(
struct TCP_Server_Info *server, struct smb_rqst *rqst); struct TCP_Server_Info *server, struct smb_rqst *rqst);
......
...@@ -610,18 +610,18 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr, ...@@ -610,18 +610,18 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
} }
static int static int
smb2_get_mid_entry(struct cifs_ses *ses, struct smb2_sync_hdr *shdr, smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
struct mid_q_entry **mid) struct smb2_sync_hdr *shdr, struct mid_q_entry **mid)
{ {
if (ses->server->tcpStatus == CifsExiting) if (server->tcpStatus == CifsExiting)
return -ENOENT; return -ENOENT;
if (ses->server->tcpStatus == CifsNeedReconnect) { if (server->tcpStatus == CifsNeedReconnect) {
cifs_dbg(FYI, "tcp session dead - return to caller to retry\n"); cifs_dbg(FYI, "tcp session dead - return to caller to retry\n");
return -EAGAIN; return -EAGAIN;
} }
if (ses->server->tcpStatus == CifsNeedNegotiate && if (server->tcpStatus == CifsNeedNegotiate &&
shdr->Command != SMB2_NEGOTIATE) shdr->Command != SMB2_NEGOTIATE)
return -EAGAIN; return -EAGAIN;
...@@ -638,11 +638,11 @@ smb2_get_mid_entry(struct cifs_ses *ses, struct smb2_sync_hdr *shdr, ...@@ -638,11 +638,11 @@ smb2_get_mid_entry(struct cifs_ses *ses, struct smb2_sync_hdr *shdr,
/* else ok - we are shutting down the session */ /* else ok - we are shutting down the session */
} }
*mid = smb2_mid_entry_alloc(shdr, ses->server); *mid = smb2_mid_entry_alloc(shdr, server);
if (*mid == NULL) if (*mid == NULL)
return -ENOMEM; return -ENOMEM;
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
list_add_tail(&(*mid)->qhead, &ses->server->pending_mid_q); list_add_tail(&(*mid)->qhead, &server->pending_mid_q);
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
return 0; return 0;
...@@ -675,24 +675,25 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, ...@@ -675,24 +675,25 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
} }
struct mid_q_entry * struct mid_q_entry *
smb2_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst) smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
struct smb_rqst *rqst)
{ {
int rc; int rc;
struct smb2_sync_hdr *shdr = struct smb2_sync_hdr *shdr =
(struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
struct mid_q_entry *mid; struct mid_q_entry *mid;
smb2_seq_num_into_buf(ses->server, shdr); smb2_seq_num_into_buf(server, shdr);
rc = smb2_get_mid_entry(ses, shdr, &mid); rc = smb2_get_mid_entry(ses, server, shdr, &mid);
if (rc) { if (rc) {
revert_current_mid_from_hdr(ses->server, shdr); revert_current_mid_from_hdr(server, shdr);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
rc = smb2_sign_rqst(rqst, ses->server); rc = smb2_sign_rqst(rqst, server);
if (rc) { if (rc) {
revert_current_mid_from_hdr(ses->server, shdr); revert_current_mid_from_hdr(server, shdr);
cifs_delete_mid(mid); cifs_delete_mid(mid);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
......
...@@ -936,7 +936,8 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, ...@@ -936,7 +936,8 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
} }
struct mid_q_entry * struct mid_q_entry *
cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst) cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *ignored,
struct smb_rqst *rqst)
{ {
int rc; int rc;
struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base; struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
...@@ -1053,7 +1054,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -1053,7 +1054,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
} }
for (i = 0; i < num_rqst; i++) { for (i = 0; i < num_rqst; i++) {
midQ[i] = server->ops->setup_request(ses, &rqst[i]); midQ[i] = server->ops->setup_request(ses, server, &rqst[i]);
if (IS_ERR(midQ[i])) { if (IS_ERR(midQ[i])) {
revert_current_mid(server, i); revert_current_mid(server, i);
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
......
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