Skip to content

Commit

Permalink
cifs: multichannel: use pointer for binding channel
Browse files Browse the repository at this point in the history
Add a cifs_chan pointer in struct cifs_ses that points to the channel
currently being bound if ses->binding is true.

Previously it was always the channel past the established count.

This will make reconnecting (and rebinding) a channel easier later on.

Signed-off-by: Aurelien Aptel <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
aaptel authored and Steve French committed Jun 4, 2020
1 parent edb1613 commit 8eec795
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1030,30 +1030,39 @@ struct cifs_ses {

#define CIFS_MAX_CHANNELS 16
struct cifs_chan chans[CIFS_MAX_CHANNELS];
struct cifs_chan *binding_chan;
size_t chan_count;
size_t chan_max;
atomic_t chan_seq; /* round robin state */
};

/*
* When binding a new channel, we need to access the channel which isn't fully
* established yet (one past the established count)
* established yet.
*/

static inline
struct cifs_chan *cifs_ses_binding_channel(struct cifs_ses *ses)
{
if (ses->binding)
return &ses->chans[ses->chan_count];
return ses->binding_chan;
else
return NULL;
}

/*
* Returns the server pointer of the session. When binding a new
* channel this returns the last channel which isn't fully established
* yet.
*
* This function should be use for negprot/sess.setup codepaths. For
* the other requests see cifs_pick_channel().
*/
static inline
struct TCP_Server_Info *cifs_ses_server(struct cifs_ses *ses)
{
if (ses->binding)
return ses->chans[ses->chan_count].server;
return ses->binding_chan->server;
else
return ses->server;
}
Expand Down
3 changes: 2 additions & 1 deletion fs/cifs/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)

mutex_lock(&ses->session_mutex);

chan = &ses->chans[ses->chan_count];
chan = ses->binding_chan = &ses->chans[ses->chan_count];
chan->server = cifs_get_tcp_session(&vol);
if (IS_ERR(chan->server)) {
rc = PTR_ERR(chan->server);
Expand Down Expand Up @@ -276,6 +276,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
atomic_set(&ses->chan_seq, 0);
out:
ses->binding = false;
ses->binding_chan = NULL;
mutex_unlock(&ses->session_mutex);

if (rc && chan->server)
Expand Down

0 comments on commit 8eec795

Please sign in to comment.