Skip to content

Commit

Permalink
cifs: multichannel: move channel selection in function
Browse files Browse the repository at this point in the history
This commit moves channel picking code in separate function.

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
aaptel authored and Steve French committed Jun 2, 2020
1 parent bbbf9ea commit 5f68ea4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ extern int cifs_call_async(struct TCP_Server_Info *server,
mid_receive_t *receive, mid_callback_t *callback,
mid_handle_t *handle, void *cbdata, const int flags,
const struct cifs_credits *exist_credits);
extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
struct smb_rqst *rqst, int *resp_buf_type,
const int flags, struct kvec *resp_iov);
Expand Down
38 changes: 27 additions & 11 deletions fs/cifs/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,32 @@ cifs_cancelled_callback(struct mid_q_entry *mid)
DeleteMidQEntry(mid);
}

/*
* Return a channel (master if none) of @ses that can be used to send
* regular requests.
*
* If we are currently binding a new channel (negprot/sess.setup),
* return the new incomplete channel.
*/
struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)
{
uint index = 0;

if (!ses)
return NULL;

if (!ses->binding) {
/* round robin */
if (ses->chan_count > 1) {
index = (uint)atomic_inc_return(&ses->chan_seq);
index %= ses->chan_count;
}
return ses->chans[index].server;
} else {
return cifs_ses_server(ses);
}
}

int
compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
const int flags, const int num_rqst, struct smb_rqst *rqst,
Expand All @@ -1017,17 +1043,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
return -EIO;
}

if (!ses->binding) {
uint index = 0;

if (ses->chan_count > 1) {
index = (uint)atomic_inc_return(&ses->chan_seq);
index %= ses->chan_count;
}
server = ses->chans[index].server;
} else {
server = cifs_ses_server(ses);
}
server = cifs_pick_channel(ses);

if (server->tcpStatus == CifsExiting)
return -ENOENT;
Expand Down

0 comments on commit 5f68ea4

Please sign in to comment.