cifs: handle servers that still advertise multichannel after disabling
Subsystems (2)
PATCH 1/7 cifs: handle servers that still advertise multichannel after disabling
From: Shyam Prasad N <[email protected]>
Some servers like Azure SMB servers always advertise multichannel capability in server capabilities list. Such servers return error STATUS_NOT_IMPLEMENTED for ioctl calls to query server interfaces, and expect clients to consider that as a sign that they do not support multichannel.
We already handled this at mount time. Soon after the tree connect, we query server interfaces. And when server returned STATUS_NOT_IMPLEMENTED, we kept interface list as empty. When cifs_try_adding_channels gets called, it would not find any interfaces, so will not add channels.
For the case where an active multichannel mount exists, and multichannel is disabled by such a server, this change will now allow the client to disable secondary channels on the mount. It will check the return status of query server interfaces call soon after a tree reconnect. If the return status is EOPNOTSUPP, then instead of the check to add more channels, we'll disable the secondary channels instead.
For better code reuse, this change also moves the common code for disabling multichannel to a helper function.
--- fs/smb/client/smb2pdu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/smb/client/smb2pdu.c +3 -4
@@ -167,7 +167,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,if (SERVER_IS_CHAN (server)) {cifs_dbg (VFS , -"server %s does not support multichannel anymore. Skip secondary channel\n" , +"server %s does not support multichannel anymore. Skip secondary channel\n" , ses->server->hostname);spin_lock (&ses->chan_lock);
@@ -195,15 +195,13 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, pserver = server->primary_server;cifs_signal_cifsd_for_reconnect (pserver, false); skip_terminate: -mutex_unlock (&ses->session_mutex);return -EHOSTDOWN ; }cifs_server_dbg (VFS , -"server does not support multichannel anymore. Disable all other channels\n" ); +"server does not support multichannel anymore. Disable all other channels\n" );cifs_disable_secondary_channels (ses); -return 0 ; }
@@ -441,6 +439,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, } skip_add_channels: +skip_add_channels:if (smb2_command !=SMB2_INTERNAL_CMD )mod_delayed_work (cifsiod_wq, &server->reconnect,0 );
Signature · 1 line
2.34.1
PATCH 2/7 cifs: cifs_pick_channel should try selecting active channels
From: Shyam Prasad N <[email protected]>
cifs_pick_channel today just selects a channel based on the policy of least loaded channel. However, it does not take into account if the channel needs reconnect. As a result, we can have failures in send that can be completely avoided.
This change doesn't make a channel a candidate for this selection if it needs reconnect.
--- fs/smb/client/transport.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/transport.c +3 -0
@@ -1026,6 +1026,9 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)if (!server || server->terminate)continue ; +if (CIFS_CHAN_NEEDS_RECONNECT (ses, i)) +continue ; +/* * strictly speaking, we should pick up req_lock to read * server->in_flight. But it shouldn't matter much here if we
Signature · 1 line
2.34.1
PATCH 3/7 cifs: smb2_close_getattr should also update i_size
In reply to [email protected]From: Shyam Prasad N <[email protected]>
SMB2 CLOSE command with SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB flag set is already used by the code for SMB3+. smb2_close_getattr is the function that uses this to update the inode attributes.
However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response.
This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale i_blocks value. Fixed that here too.
--- fs/smb/client/smb2ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/client/smb2ops.c +3 -3
@@ -1433,9 +1433,9 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,* but instead 512 byte (2**9) size is required for * calculating num blocks. */ -if (le64_to_cpu (file_inf.AllocationSize) >4096 ) - inode->i_blocks = - (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + inode->i_blocks = (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + + inode->i_size =le64_to_cpu (file_inf.EndOfFile);/* End of file and Attributes should not have to be updated on close */ spin_unlock (&inode->i_lock);
Signature · 1 line
2.34.1
Re: [PATCH 3/7] cifs: smb2_close_getattr should also update i_size
Quoted 42 lines · On Sun, Jan 21, 2024 at 9:03 AM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
SMB2 CLOSE command with
SMB2_CLOSE_FLAG_POSTQUERY_ATTRIBflag set is already used by the code for SMB3+.smb2_close_getattris the function that uses this to update the inode attributes.However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response.
This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale
i_blocksvalue. Fixed that here too.Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/smb/client/smb2ops.c +3
-4@@ -1433,9 +1433,9 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,* but instead 512 byte (2**9) size is required for * calculating num blocks. */ -if (le64_to_cpu (file_inf.AllocationSize) >4096 ) - inode->i_blocks = - (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + inode->i_blocks = (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + + inode->i_size =le64_to_cpu (file_inf.EndOfFile);/* End of file and Attributes should not have to be updated on close */ spin_unlock (&inode->i_lock); --
Quoted 2 lines
2.34.1
Noticed a couple of things in other places in the code:
1. i_size_write() should be called instead of updating i_size directly.
2. There's a server_eof field that is generally maintained in sync with i_size. Need to check how that needs to be done here.
I'll submit a v2 of this patch soon.
Signature · 2 lines
Regards, Shyam
Re: [PATCH 3/7] cifs: smb2_close_getattr should also update i_size
Quoted 51 lines · Shyam Prasad N
Quoted 42 lines · On Sun, Jan 21, 2024 at 9:03 AM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
SMB2 CLOSE command with
SMB2_CLOSE_FLAG_POSTQUERY_ATTRIBflag set is already used by the code for SMB3+.smb2_close_getattris the function that uses this to update the inode attributes.However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response.
This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale
i_blocksvalue. Fixed that here too.Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/smb/client/smb2ops.c +3
-4@@ -1433,9 +1433,9 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,* but instead 512 byte (2**9) size is required for * calculating num blocks. */ -if (le64_to_cpu (file_inf.AllocationSize) >4096 ) - inode->i_blocks = - (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + inode->i_blocks = (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + + inode->i_size =le64_to_cpu (file_inf.EndOfFile);/* End of file and Attributes should not have to be updated on close */ spin_unlock (&inode->i_lock); --Quoted 2 lines
2.34.1
Noticed a couple of things in other places in the code:
1.i_size_write()should be called instead of updatingi_sizedirectly.
2. There's aserver_eoffield that is generally maintained in sync withi_size. Need to check how that needs to be done here.
Quoted 5 lines
I'll submit a v2 of this patch soon.
--
Regards,
Shyam
Attached updated patch.
Signature · 2 lines
Regards, Shyam
From e470df39e5eca4f29413b60421c207d625fe5bf7 Mon Sep 17 00:00:00 2001
From: Shyam Prasad N <[email protected]>
Date: Sun, 21 Jan 2024 03:32:44 +0000
Subject: [PATCH] cifs: smb2_close_getattr should also update i_size
SMB2 CLOSE command with SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB flag set is already used by the code for SMB3+. smb2_close_getattr is the function that uses this to update the inode attributes.
However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response.
This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale i_blocks value. Fixed that here too.
--- fs/smb/client/smb2ops.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/smb/client/smb2ops.c +4 -3
@@ -1433,9 +1433,10 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,* but instead 512 byte (2**9) size is required for * calculating num blocks. */ -if (le64_to_cpu (file_inf.AllocationSize) >4096 ) - inode->i_blocks = - (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + inode->i_blocks = (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + +CIFS_I (inode)->server_eof =le64_to_cpu (file_inf.EndOfFile); +i_size_write (inode,CIFS_I (inode)->server_eof);/* End of file and Attributes should not have to be updated on close */ spin_unlock (&inode->i_lock);
Signature · 1 line
2.34.1
Re: [PATCH 3/7] cifs: smb2_close_getattr should also update i_size
This was the patch that was causing test generic/074 to regress so I took it out of for-next temporarily till we can fix it. The version of the patch I was using is attached
Quoted 64 lines · Shyam Prasad N
Quoted 51 lines · Shyam Prasad N
Quoted 42 lines · On Sun, Jan 21, 2024 at 9:03 AM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
SMB2 CLOSE command with
SMB2_CLOSE_FLAG_POSTQUERY_ATTRIBflag set is already used by the code for SMB3+.smb2_close_getattris the function that uses this to update the inode attributes.However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response.
This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale
i_blocksvalue. Fixed that here too.Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/smb/client/smb2ops.c +3
-4@@ -1433,9 +1433,9 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,* but instead 512 byte (2**9) size is required for * calculating num blocks. */ -if (le64_to_cpu (file_inf.AllocationSize) >4096 ) - inode->i_blocks = - (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + inode->i_blocks = (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + + inode->i_size =le64_to_cpu (file_inf.EndOfFile);/* End of file and Attributes should not have to be updated on close */ spin_unlock (&inode->i_lock); --Quoted 2 lines
2.34.1
Noticed a couple of things in other places in the code:
1.i_size_write()should be called instead of updatingi_sizedirectly.
2. There's aserver_eoffield that is generally maintained in sync withi_size. Need to check how that needs to be done here.Quoted 5 lines
I'll submit a v2 of this patch soon.
--
Regards,
ShyamAttached updated patch.
--
Regards,
Shyam
Signature · 3 lines
Thanks, Steve
From 3665f29562a6fefefd36a601d478854a6b672255 Mon Sep 17 00:00:00 2001
From: Shyam Prasad N <[email protected]>
Date: Sun, 21 Jan 2024 03:32:44 +0000
Subject: [PATCH 1/6] cifs: smb2_close_getattr should also update i_size
SMB2 CLOSE command with SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB flag set is already used by the code for SMB3+. smb2_close_getattr is the function that uses this to update the inode attributes.
However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response.
This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale i_blocks value. Fixed that here too.
--- fs/smb/client/smb2ops.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/smb/client/smb2ops.c +4 -3
@@ -1433,9 +1433,10 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,* but instead 512 byte (2**9) size is required for * calculating num blocks. */ -if (le64_to_cpu (file_inf.AllocationSize) >4096 ) - inode->i_blocks = - (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + inode->i_blocks = (512 -1 +le64_to_cpu (file_inf.AllocationSize)) >>9 ; + +CIFS_I (inode)->netfs.remote_i_size =le64_to_cpu (file_inf.EndOfFile); +i_size_write (inode,CIFS_I (inode)->netfs.remote_i_size);/* End of file and Attributes should not have to be updated on close */ spin_unlock (&inode->i_lock);
Signature · 1 line
2.40.1
PATCH 4/7 cifs: translate network errors on send to -ECONNABORTED
In reply to [email protected]From: Shyam Prasad N <[email protected]>
When the network stack returns various errors, we today bubble up the error to the user (in case of soft mounts).
This change translates all network errors except -EINTR and -EAGAIN to -ECONNABORTED. A similar approach is taken when we receive network errors when reading from the socket.
The change also forces the cifsd thread to reconnect during it's next activity.
--- fs/smb/client/transport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/smb/client/transport.c +9 -2
@@ -400,10 +400,17 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, server->conn_id, server->hostname); } smbd_done: -if (rc <0 && rc != -EINTR ) +/* +* there's hardly any use for the layers above to know the +* actual error code here. All they should do at this point is +* to retry the connection and hope it goes away. +*/ +if (rc <0 && rc != -EINTR && rc != -EAGAIN ) {cifs_server_dbg (VFS ,"Error %d sending data on socket to server\n" , rc); -else if (rc >0 ) + rc = -ECONNABORTED ; +cifs_signal_cifsd_for_reconnect (server, false); + }else if (rc >0 ) rc =0 ; out:cifs_in_send_dec (server);
Signature · 1 line
2.34.1
PATCH 5/7 cifs: helper function to check replayable error codes
In reply to [email protected]From: Shyam Prasad N <[email protected]>
The code to check for replay is not just -EAGAIN. In some cases, the send request or receive response may result in network errors, which we're now mapping to -ECONNABORTED.
This change introduces a helper function which checks if the error returned in one of the above two errors. And all checks for replays will now use this helper.
--- fs/smb/client/cached_dir.c | 1 + fs/smb/client/cifsglob.h | 7 +++++++ 2 files changed, 8 insertions(+)
fs/smb/client/cached_dir.c +1 -0
@@ -367,6 +367,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,atomic_inc (&tcon->num_remote_opens); }kfree (utf16_path); +return rc; }
fs/smb/client/cifsglob.h +7 -0
@@ -1831,6 +1831,13 @@ static inline bool is_retryable_error(int error)return false; } +static inline bool is_replayable_error (int error) +{ +if (error == -EAGAIN || error == -ECONNABORTED ) +return true; +return false; +} +/* cifs_get_writable_file() flags */ #define FIND_WR_ANY 0
Signature · 1 line
2.34.1
PATCH 6/7 cifs: commands that are retried should have replay flag set
In reply to [email protected]From: Shyam Prasad N <[email protected]>
MS-SMB2 states that the header flag SMB2_FLAGS_REPLAY_OPERATION needs to be set when a command needs to be retried, so that the server is aware that this is a replay for an operation that appeared before.
This can be very important, for example, for state changing operations and opens which get retried following a reconnect; since the client maybe unaware of the status of the previous open.
This is particularly important for multichannel scenario, since disconnection of one connection does not mean that the session is lost. The requests can be replayed on another channel.
This change also makes use of exponential back-off before replays and also limits the number of retries to "retrans" mount option value.
Also, this change does not modify the read/write codepath.
--- fs/smb/client/cached_dir.c | 23 +++- fs/smb/client/cifsglob.h | 5 + fs/smb/client/smb2inode.c | 33 ++++- fs/smb/client/smb2ops.c | 123 ++++++++++++++++-- fs/smb/client/smb2pdu.c | 260 +++++++++++++++++++++++++++++++++---- fs/smb/client/smb2proto.h | 5 + 6 files changed, 404 insertions(+), 45 deletions(-)
fs/smb/client/cached_dir.c +19 -4
@@ -145,21 +145,27 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,struct cached_fid *cfid;struct cached_fids *cfids;const char *npath; +int retries =0 , cur_sleep =1 ;if (tcon ==NULL || tcon->cfids ==NULL || tcon->nohandlecache ||is_smb1_server (tcon->ses->server) || (dir_cache_timeout ==0 ))return -EOPNOTSUPP ; ses = tcon->ses; - server =cifs_pick_channel (ses); cfids = tcon->cfids; -if (!server->ops->new_lease_key) -return -EIO ; -if (cifs_sb->root ==NULL )return -ENOENT ; +replay_again: +/* reinitialize for possible replay */ + flags =0 ; + oplock =SMB2_OPLOCK_LEVEL_II ; + server =cifs_pick_channel (ses); + +if (!server->ops->new_lease_key) +return -EIO ; + utf16_path =cifs_convert_path_to_utf16 (path, cifs_sb);if (!utf16_path)return -ENOMEM ;
@@ -268,6 +274,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,*/ cfid->has_lease = true; +if (retries) { +smb2_set_replay (server, &rqst[0 ]); +smb2_set_replay (server, &rqst[1 ]); + } + rc =compound_send_recv (xid, ses, server, flags,2 , rqst, resp_buftype, rsp_iov);
@@ -368,6 +379,10 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, }kfree (utf16_path); +if (is_replayable_error (rc) && +smb2_should_replay (tcon, &retries, &cur_sleep)) + goto replay_again; +return rc; }
fs/smb/client/cifsglob.h +5 -0
@@ -49,6 +49,11 @@*/ #define CIFS_DEF_ACTIMEO (1 * HZ) +/* +* max sleep time before retry to server +*/ +#define CIFS_MAX_SLEEP 2000 +/* * max attribute cache timeout (jiffies) - 2^30 */
fs/smb/client/smb2inode.c +27 -6
@@ -120,6 +120,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,unsigned int size[2 ];void *data[2 ];int len; +int retries =0 , cur_sleep =1 ; + +replay_again: +/* reinitialize for possible replay */ + flags =0 ; + oplock =SMB2_OPLOCK_LEVEL_NONE ; + num_rqst =0 ; + server =cifs_pick_channel (ses); vars =kzalloc (sizeof (*vars),GFP_ATOMIC );if (vars ==NULL )
@@ -127,8 +135,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, rqst = &vars->rqst[0 ]; rsp_iov = &vars->rsp_iov[0 ]; - server =cifs_pick_channel (ses); -if (smb3_encryption_required (tcon)) flags |=CIFS_TRANSFORM_REQ ;
@@ -463,15 +469,24 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, num_rqst++;if (cfile) { +if (retries) +for (i =1 ; i < num_rqst -2 ; i++) +smb2_set_replay (server, &rqst[i]); + rc =compound_send_recv (xid, ses, server, flags, num_rqst -2 , &rqst[1 ], &resp_buftype[1 ], &rsp_iov[1 ]); - }else + }else { +if (retries) +for (i =0 ; i < num_rqst; i++) +smb2_set_replay (server, &rqst[i]); + rc =compound_send_recv (xid, ses, server, flags, num_rqst, rqst, resp_buftype, rsp_iov); + } finished: num_rqst =0 ;
@@ -620,9 +635,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, }SMB2_close_free (&rqst[num_rqst]); -if (cfile) -cifsFileInfo_put (cfile); - num_cmds +=2 ;if (out_iov && out_buftype) {memcpy (out_iov, rsp_iov, num_cmds *sizeof (*out_iov));
@@ -632,7 +644,16 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,for (i =0 ; i < num_cmds; i++)free_rsp_buf (resp_buftype[i], rsp_iov[i].iov_base); } + num_cmds -=2 ;/* correct num_cmds as there could be a retry */ kfree (vars); + +if (is_replayable_error (rc) && +smb2_should_replay (tcon, &retries, &cur_sleep)) + goto replay_again; + +if (cfile) +cifsFileInfo_put (cfile); +return rc; }
fs/smb/client/smb2ops.c +114 -9
229 lines not on this page · raw message
fs/smb/client/smb2pdu.c +234 -26
589 lines not on this page · raw message
fs/smb/client/smb2proto.h +5 -0
@@ -122,6 +122,11 @@ extern unsigned long smb_rqst_len(struct TCP_Server_Info *server,extern void smb2_set_next_command (struct cifs_tcon *tcon,struct smb_rqst *rqst);extern void smb2_set_related (struct smb_rqst *rqst); +extern void smb2_set_replay (struct TCP_Server_Info *server, +struct smb_rqst *rqst); +extern bool smb2_should_replay (struct cifs_tcon *tcon, +int *pretries, +int *pcur_sleep);/* * SMB2 Worker functions - most of protocol specific implementation details
Signature · 1 line
2.34.1
PATCH 7/7 cifs: set replay flag for retries of write command
In reply to [email protected]From: Shyam Prasad N <[email protected]>
Similar to the rest of the commands, this is a change to add replay flags on retry. This one does not add a back-off, considering that we may want to flush a write ASAP to the server. Considering that this will be a flush of cached pages, the retrans value is also not honoured.
--- fs/smb/client/cifsglob.h | 1 + fs/smb/client/file.c | 1 + fs/smb/client/smb2pdu.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-)
fs/smb/client/cifsglob.h +1 -0
@@ -1506,6 +1506,7 @@ struct cifs_writedata {struct smbd_mr *mr;#endif struct cifs_credits credits; +bool replay; };/*
fs/smb/client/file.c +1 -0
@@ -3300,6 +3300,7 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list,if (wdata->cfile->invalidHandle) rc = -EAGAIN ;else { + wdata->replay = true;#ifdef CONFIG_CIFS_SMB_DIRECT if (wdata->mr) { wdata->mr->need_invalidate = true;
fs/smb/client/smb2pdu.c +3 -1
@@ -4770,7 +4770,7 @@ smb2_async_writev(struct cifs_writedata *wdata,struct cifs_io_parms *io_parms =NULL ;int credit_request; -if (!wdata->server) +if (!wdata->server || wdata->replay) server = wdata->server =cifs_pick_channel (tcon->ses);/*
@@ -4855,6 +4855,8 @@ smb2_async_writev(struct cifs_writedata *wdata, rqst.rq_nvec =1 ; rqst.rq_iter = wdata->iter; rqst.rq_iter_size =iov_iter_count (&rqst.rq_iter); +if (wdata->replay) +smb2_set_replay (server, &rqst);#ifdef CONFIG_CIFS_SMB_DIRECT if (wdata->mr) iov[0 ].iov_len +=sizeof (struct smbd_buffer_descriptor_v1 );
Signature · 1 line
2.34.1
Re: [PATCH 7/7] cifs: set replay flag for retries of write command
tentatively merged to cifs-2.6.git for-next pending review and testing (after correcting the duplicate label problem with patch 1)
Quoted 66 lines · On Sat, Jan 20, 2024 at 9:33 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
Similar to the rest of the commands, this is a change to add replay flags on retry. This one does not add a back-off, considering that we may want to flush a write ASAP to the server. Considering that this will be a flush of cached pages, the retrans value is also not honoured.
Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/cifsglob.h | 1 + fs/smb/client/file.c | 1 + fs/smb/client/smb2pdu.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-)fs/smb/client/cifsglob.h +1
-0@@ -1506,6 +1506,7 @@ struct cifs_writedata {struct smbd_mr *mr;#endif struct cifs_credits credits; +bool replay; };/* fs/smb/client/file.c +1
-0@@ -3300,6 +3300,7 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list,if (wdata->cfile->invalidHandle) rc = -EAGAIN ;else { + wdata->replay = true;#ifdef CONFIG_CIFS_SMB_DIRECT if (wdata->mr) { wdata->mr->need_invalidate = true;fs/smb/client/smb2pdu.c +3
-2@@ -4770,7 +4770,7 @@ smb2_async_writev(struct cifs_writedata *wdata,struct cifs_io_parms *io_parms =NULL ;int credit_request; -if (!wdata->server) +if (!wdata->server || wdata->replay) server = wdata->server =cifs_pick_channel (tcon->ses);/* @@ -4855,6 +4855,8 @@ smb2_async_writev(struct cifs_writedata *wdata, rqst.rq_nvec =1 ; rqst.rq_iter = wdata->iter; rqst.rq_iter_size =iov_iter_count (&rqst.rq_iter); +if (wdata->replay) +smb2_set_replay (server, &rqst);#ifdef CONFIG_CIFS_SMB_DIRECT if (wdata->mr) iov[0 ].iov_len +=sizeof (struct smbd_buffer_descriptor_v1 ); --2.34.1
Signature · 3 lines
Thanks, Steve
Has a duplicate label warning that I corrected by removing the following part of patch 1
@@ -441,6 +439,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
}
skip_add_channels:
+skip_add_channels:
if (smb2_command != SMB2_INTERNAL_CMD)
mod_delayed_work(cifsiod_wq, &server->reconnect, 0);Quoted 70 lines · On Sat, Jan 20, 2024 at 9:33 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
Some servers like Azure SMB servers always advertise multichannel capability in server capabilities list. Such servers return error
STATUS_NOT_IMPLEMENTEDfor ioctl calls to query server interfaces, and expect clients to consider that as a sign that they do not support multichannel.We already handled this at mount time. Soon after the tree connect, we query server interfaces. And when server returned
STATUS_NOT_IMPLEMENTED, we kept interface list as empty. Whencifs_try_adding_channelsgets called, it would not find any interfaces, so will not add channels.For the case where an active multichannel mount exists, and multichannel is disabled by such a server, this change will now allow the client to disable secondary channels on the mount. It will check the return status of query server interfaces call soon after a tree reconnect. If the return status is EOPNOTSUPP, then instead of the check to add more channels, we'll disable the secondary channels instead.
For better code reuse, this change also moves the common code for disabling multichannel to a helper function.
Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2pdu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)fs/smb/client/smb2pdu.c +3
-5@@ -167,7 +167,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,if (SERVER_IS_CHAN (server)) {cifs_dbg (VFS , -"server %s does not support multichannel anymore. Skip secondary channel\n" , +"server %s does not support multichannel anymore. Skip secondary channel\n" , ses->server->hostname);spin_lock (&ses->chan_lock);@@ -195,15 +195,13 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, pserver = server->primary_server;cifs_signal_cifsd_for_reconnect (pserver, false); skip_terminate: -mutex_unlock (&ses->session_mutex);return -EHOSTDOWN ; }cifs_server_dbg (VFS , -"server does not support multichannel anymore. Disable all other channels\n" ); +"server does not support multichannel anymore. Disable all other channels\n" );cifs_disable_secondary_channels (ses); -return 0 ; }@@ -441,6 +439,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, } skip_add_channels: +skip_add_channels:if (smb2_command !=SMB2_INTERNAL_CMD )mod_delayed_work (cifsiod_wq, &server->reconnect,0 ); --2.34.1
Signature · 3 lines
Thanks, Steve
Quoted 88 lines · Steve French
Has a duplicate label warning that I corrected by removing the following part of patch 1
fs/smb/client/smb2pdu.c +1
-0@@ -441,6 +439,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, } skip_add_channels: +skip_add_channels:if (smb2_command !=SMB2_INTERNAL_CMD )mod_delayed_work (cifsiod_wq, &server->reconnect,0 );Quoted 68 lines · On Sat, Jan 20, 2024 at 9:33 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
Some servers like Azure SMB servers always advertise multichannel capability in server capabilities list. Such servers return error
STATUS_NOT_IMPLEMENTEDfor ioctl calls to query server interfaces, and expect clients to consider that as a sign that they do not support multichannel.We already handled this at mount time. Soon after the tree connect, we query server interfaces. And when server returned
STATUS_NOT_IMPLEMENTED, we kept interface list as empty. Whencifs_try_adding_channelsgets called, it would not find any interfaces, so will not add channels.For the case where an active multichannel mount exists, and multichannel is disabled by such a server, this change will now allow the client to disable secondary channels on the mount. It will check the return status of query server interfaces call soon after a tree reconnect. If the return status is EOPNOTSUPP, then instead of the check to add more channels, we'll disable the secondary channels instead.
For better code reuse, this change also moves the common code for disabling multichannel to a helper function.
Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2pdu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)fs/smb/client/smb2pdu.c +3
-5@@ -167,7 +167,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses,if (SERVER_IS_CHAN (server)) {cifs_dbg (VFS , -"server %s does not support multichannel anymore. Skip secondary channel\n" , +"server %s does not support multichannel anymore. Skip secondary channel\n" , ses->server->hostname);spin_lock (&ses->chan_lock);@@ -195,15 +195,13 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, pserver = server->primary_server;cifs_signal_cifsd_for_reconnect (pserver, false); skip_terminate: -mutex_unlock (&ses->session_mutex);return -EHOSTDOWN ; }cifs_server_dbg (VFS , -"server does not support multichannel anymore. Disable all other channels\n" ); +"server does not support multichannel anymore. Disable all other channels\n" );cifs_disable_secondary_channels (ses); -return 0 ; }@@ -441,6 +439,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, } skip_add_channels: +skip_add_channels:if (smb2_command !=SMB2_INTERNAL_CMD )mod_delayed_work (cifsiod_wq, &server->reconnect,0 ); --Quoted 2 lines
2.34.1
--
Thanks,
Quoted 1 line
Steve
Please ignore this one. I'll send an updated patch.
Signature · 2 lines
Regards, Shyam