Skip to content

Commit f780bd3

Browse files
aaptelsmfrench
authored andcommitted
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: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent bcc8880 commit f780bd3

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

fs/cifs/cifsglob.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ struct smb_version_operations {
230230
bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
231231
/* setup request: allocate mid, sign message */
232232
struct mid_q_entry *(*setup_request)(struct cifs_ses *,
233-
struct smb_rqst *);
233+
struct TCP_Server_Info *,
234+
struct smb_rqst *);
234235
/* setup async request: allocate mid, sign message */
235236
struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *,
236237
struct smb_rqst *);

fs/cifs/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
109109
extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
110110
char *in_buf, int flags);
111111
extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *,
112+
struct TCP_Server_Info *,
112113
struct smb_rqst *);
113114
extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *,
114115
struct smb_rqst *);

fs/cifs/smb2proto.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *);
4646
extern int smb2_check_receive(struct mid_q_entry *mid,
4747
struct TCP_Server_Info *server, bool log_error);
4848
extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
49-
struct smb_rqst *rqst);
49+
struct TCP_Server_Info *,
50+
struct smb_rqst *rqst);
5051
extern struct mid_q_entry *smb2_setup_async_request(
5152
struct TCP_Server_Info *server, struct smb_rqst *rqst);
5253
extern struct cifs_ses *smb2_find_smb_ses(struct TCP_Server_Info *server,

fs/cifs/smb2transport.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,18 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
610610
}
611611

612612
static int
613-
smb2_get_mid_entry(struct cifs_ses *ses, struct smb2_sync_hdr *shdr,
614-
struct mid_q_entry **mid)
613+
smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
614+
struct smb2_sync_hdr *shdr, struct mid_q_entry **mid)
615615
{
616-
if (ses->server->tcpStatus == CifsExiting)
616+
if (server->tcpStatus == CifsExiting)
617617
return -ENOENT;
618618

619-
if (ses->server->tcpStatus == CifsNeedReconnect) {
619+
if (server->tcpStatus == CifsNeedReconnect) {
620620
cifs_dbg(FYI, "tcp session dead - return to caller to retry\n");
621621
return -EAGAIN;
622622
}
623623

624-
if (ses->server->tcpStatus == CifsNeedNegotiate &&
624+
if (server->tcpStatus == CifsNeedNegotiate &&
625625
shdr->Command != SMB2_NEGOTIATE)
626626
return -EAGAIN;
627627

@@ -638,11 +638,11 @@ smb2_get_mid_entry(struct cifs_ses *ses, struct smb2_sync_hdr *shdr,
638638
/* else ok - we are shutting down the session */
639639
}
640640

641-
*mid = smb2_mid_entry_alloc(shdr, ses->server);
641+
*mid = smb2_mid_entry_alloc(shdr, server);
642642
if (*mid == NULL)
643643
return -ENOMEM;
644644
spin_lock(&GlobalMid_Lock);
645-
list_add_tail(&(*mid)->qhead, &ses->server->pending_mid_q);
645+
list_add_tail(&(*mid)->qhead, &server->pending_mid_q);
646646
spin_unlock(&GlobalMid_Lock);
647647

648648
return 0;
@@ -675,24 +675,25 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
675675
}
676676

677677
struct mid_q_entry *
678-
smb2_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
678+
smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
679+
struct smb_rqst *rqst)
679680
{
680681
int rc;
681682
struct smb2_sync_hdr *shdr =
682683
(struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
683684
struct mid_q_entry *mid;
684685

685-
smb2_seq_num_into_buf(ses->server, shdr);
686+
smb2_seq_num_into_buf(server, shdr);
686687

687-
rc = smb2_get_mid_entry(ses, shdr, &mid);
688+
rc = smb2_get_mid_entry(ses, server, shdr, &mid);
688689
if (rc) {
689-
revert_current_mid_from_hdr(ses->server, shdr);
690+
revert_current_mid_from_hdr(server, shdr);
690691
return ERR_PTR(rc);
691692
}
692693

693-
rc = smb2_sign_rqst(rqst, ses->server);
694+
rc = smb2_sign_rqst(rqst, server);
694695
if (rc) {
695-
revert_current_mid_from_hdr(ses->server, shdr);
696+
revert_current_mid_from_hdr(server, shdr);
696697
cifs_delete_mid(mid);
697698
return ERR_PTR(rc);
698699
}

fs/cifs/transport.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
936936
}
937937

938938
struct mid_q_entry *
939-
cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
939+
cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *ignored,
940+
struct smb_rqst *rqst)
940941
{
941942
int rc;
942943
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,
10531054
}
10541055

10551056
for (i = 0; i < num_rqst; i++) {
1056-
midQ[i] = server->ops->setup_request(ses, &rqst[i]);
1057+
midQ[i] = server->ops->setup_request(ses, server, &rqst[i]);
10571058
if (IS_ERR(midQ[i])) {
10581059
revert_current_mid(server, i);
10591060
for (j = 0; j < i; j++)

0 commit comments

Comments
 (0)