cifs: client: allow changing multichannel mount options on remount
Subsystems (2)
PATCH 1/1 cifs: client: allow changing multichannel mount options on remount
From: Rajasi Mandal <[email protected]>
Previously, the client did not update a session's channel state when multichannel or max_channels mount options were changed via remount. This led to inconsistent behavior and prevented enabling or disabling multichannel support without a full unmount/remount cycle.
Enable dynamic reconfiguration of multichannel and max_channels during remount by:
- Introducing smb3_sync_ses_chan_max(), a centralized function for channel updates which synchronizes the session's channels with the updated configuration.
- Replacing cifs_disable_secondary_channels() with cifs_decrease_secondary_channels(), which accepts a from_reconfigure flag to support targeted cleanup during reconfiguration.
- Updating remount logic to detect changes in multichannel or max_channels and trigger appropriate session/channel updates.
Current limitation:
- The query_interfaces worker runs even when max_channels=1 so that multichannel can be enabled later via remount without requiring an unmount. This is a temporary approach and may be refined in the future.
Users can safely modify multichannel and max_channels on an existing mount. The client will correctly adjust the session's channel state to match the new configuration, preserving durability where possible and avoiding unnecessary disconnects.
--- fs/smb/client/cifsproto.h | 4 ++- fs/smb/client/connect.c | 4 ++- fs/smb/client/fs_context.c | 50 +++++++++++++++++++++++++++++++++- fs/smb/client/sess.c | 32 ++++++++++++++++------ fs/smb/client/smb2pdu.c | 56 ++++++++++++++++++++++++++++---------- 5 files changed, 120 insertions(+), 26 deletions(-)
fs/smb/client/cifsproto.h +3 -1
@@ -649,6 +649,8 @@ int cifs_alloc_hash(const char *name, struct shash_desc **sdesc);void cifs_free_hash (struct shash_desc **sdesc);int cifs_try_adding_channels (struct cifs_ses *ses); +int smb3_update_ses_channels (struct cifs_ses *ses,struct TCP_Server_Info *server, +bool from_reconnect,bool from_reconfigure);bool is_ses_using_iface (struct cifs_ses *ses,struct cifs_server_iface *iface);void cifs_ses_mark_for_reconnect (struct cifs_ses *ses);
@@ -674,7 +676,7 @@ bool cifs_chan_is_iface_active(struct cifs_ses *ses, struct TCP_Server_Info *server);void -cifs_disable_secondary_channels (struct cifs_ses *ses); +cifs_decrease_secondary_channels (struct cifs_ses *ses,bool from_reconfigure);void cifs_chan_update_iface (struct cifs_ses *ses,struct TCP_Server_Info *server);int
fs/smb/client/connect.c +3 -1
@@ -3927,7 +3927,9 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) ctx->prepath =NULL ; out: -cifs_try_adding_channels (mnt_ctx.ses); +smb3_update_ses_channels (mnt_ctx.ses, mnt_ctx.server, + false/* from_reconnect */ , + false/* from_reconfigure */ ); rc =mount_setup_tlink (cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);if (rc) goto error;
fs/smb/client/fs_context.c +49 -1
68 lines not on this page · raw message
fs/smb/client/sess.c +23 -9
@@ -265,12 +265,16 @@ int cifs_try_adding_channels(struct cifs_ses *ses) }/* -* called when multichannel is disabled by the server. -* this always gets called from smb2_reconnect -* and cannot get called in parallel threads. +* cifs_decrease_secondary_channels - Reduce the number of active secondary channels +* @ses: pointer to the CIFS session structure +* @from_reconfigure: if true, only reduce to chan_max; if false, reduce to a single channel +* +* This function disables and cleans up extra secondary channels for a CIFS session. +* If called during reconfiguration, it reduces the channel count to the new maximum (chan_max). +* Otherwise, it disables all but the primary channel. */ void -cifs_disable_secondary_channels (struct cifs_ses *ses) +cifs_decrease_secondary_channels (struct cifs_ses *ses,bool from_reconfigure) {int i, chan_count;struct TCP_Server_Info *server;
@@ -281,12 +285,13 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)if (chan_count ==1 ) goto done; - ses->chan_count =1 ; - -/* for all secondary channels reset the need reconnect bit */ - ses->chans_need_reconnect &=1 ; +/* Update the chan_count to the new maximum */ +if (from_reconfigure) + ses->chan_count = ses->chan_max; +else + ses->chan_count =1 ; -for (i =1 ; i < chan_count; i++) { +for (i = ses->chan_max ; i < chan_count; i++) { iface = ses->chans[i].iface; server = ses->chans[i].server;
@@ -318,6 +323,15 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)spin_lock (&ses->chan_lock); } +/* For extra secondary channels, reset the need reconnect bit */ +if (ses->chan_count ==1 ) { +cifs_dbg (VFS ,"server does not support multichannel anymore. Disable all other channels\n" ); + ses->chans_need_reconnect &=1 ; + }else { +cifs_dbg (VFS ,"Disable extra secondary channels\n" ); + ses->chans_need_reconnect &= ((1UL << ses->chan_max) -1 ); + } + done:spin_unlock (&ses->chan_lock); }
fs/smb/client/smb2pdu.c +42 -14
102 lines not on this page · raw message
Signature · 1 line
2.43.0