cifs: change_conf needs to be called for session setup
Subsystems (3)
PATCH v2 1/7 cifs: change_conf needs to be called for session setup
From: Shyam Prasad N <[email protected]>
Today we skip calling change_conf for negotiates and session setup requests. This can be a problem for mchan as the immediate next call after session setup could be due to an I/O that is made on the mount point. For single channel, this is not a problem as there will be several calls after setting up session.
This change enforces calling change_conf for the last session setup response, so that echoes and oplocks are not disabled before the first request to the server. So if that first request is an open, it does not need to disable requesting leases.
--- fs/smb/client/smb2ops.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/smb/client/smb2ops.c +9 -0
@@ -111,10 +111,19 @@ smb2_add_credits(struct TCP_Server_Info *server, cifs_trace_rw_credits_zero_in_flight); } server->in_flight--; + +/* +* Rebalance credits when an op drains in_flight. For session setup, +* do this only when the server actually granted positive credits (>2) so a +* newly established secondary channel can reserve echo/oplock credits. +*/ if (server->in_flight ==0 && ((optype &CIFS_OP_MASK ) !=CIFS_NEG_OP ) && ((optype &CIFS_OP_MASK ) !=CIFS_SESS_OP )) rc =change_conf (server); +else if (server->in_flight ==0 && + ((optype &CIFS_OP_MASK ) ==CIFS_SESS_OP ) && add >2 ) + rc =change_conf (server);/* * Sometimes server returns 0 credits on oplock break ack - we need to * rebalance credits in this case.
Signature · 1 line
2.43.0
PATCH v2 2/7 cifs: abort open_cached_dir if we don't request leases
From: Shyam Prasad N <[email protected]>
It is possible that SMB2_open_init may not set lease context based on the requested oplock level. This can happen when leases have been temporarily or permanently disabled. When this happens, we will have open_cached_dir making an open without lease context and the response will anyway be rejected by open_cached_dir (thereby forcing a close to discard this open). That's unnecessary two round-trips to the server.
This change adds a check before making the open request to the server to make sure that SMB2_open_init did add the expected lease context to the open in open_cached_dir.
--- fs/smb/client/cached_dir.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/smb/client/cached_dir.c +7 -0
@@ -286,6 +286,13 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, &rqst[0], &oplock, &oparms, utf16_path);if (rc) goto oshr_free; + +if (oplock !=SMB2_OPLOCK_LEVEL_II ) { + rc = -EINVAL ; +cifs_dbg (FYI ,"unexpected oplock level %d for cached directory\n" , oplock); + goto oshr_free; + } +smb2_set_next_command (tcon, &rqst[0 ]);memset (&qi_iov,0 ,sizeof (qi_iov));
Signature · 1 line
2.43.0
Re: [PATCH v2 2/7] cifs: abort open_cached_dir if we don't request leases
Quoted 25 lines · On Mon, Apr 20, 2026 at 11:40 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
It is possible that
SMB2_open_initmay not set lease context based on the requested oplock level. This can happen when leases have been temporarily or permanently disabled. When this happens, we will haveopen_cached_dirmaking an open without lease context and the response will anyway be rejected byopen_cached_dir(thereby forcing a close to discard this open). That's unnecessary two round-trips to the server.This change adds a check before making the open request to the server to make sure that
SMB2_open_initdid add the expected lease context to the open inopen_cached_dir.Cc <[email protected]>Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/cached_dir.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/smb/client/cached_dir.c +0
-0
fs/smb/client/cached_dir.c int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, · line 292
Quoted 7 lines
fs/smb/client/cached_dir.c +4
-0@@ -286,6 +286,13 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, &rqst[0], &oplock, &oparms, utf16_path);if (rc) goto oshr_free; + +if (oplock !=SMB2_OPLOCK_LEVEL_II ) { + rc = -EINVAL ; +cifs_dbg (FYI ,"unexpected oplock level %d for cached directory\n" , oplock);
Should we reword the log from "'unexpected' oplock level for cached directory" to something like
lease not available for cached dir.? Considering the client itself might be disabling oplock temporarily.
"unexpected" might look misleading.
fs/smb/client/cached_dir.c int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, · line 298
Quoted 6 lines
fs/smb/client/cached_dir.c +3
-0+ goto oshr_free; + } +smb2_set_next_command (tcon, &rqst[0 ]);memset (&qi_iov,0 ,sizeof (qi_iov));
Other than the above minor comment, Changes look good to me.
Re: [PATCH v2 2/7] cifs: abort open_cached_dir if we don't request leases
Quoted 31 lines · Bharath SM
Quoted 29 lines · On Mon, Apr 20, 2026 at 11:40 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
It is possible that
SMB2_open_initmay not set lease context based on the requested oplock level. This can happen when leases have been temporarily or permanently disabled. When this happens, we will haveopen_cached_dirmaking an open without lease context and the response will anyway be rejected byopen_cached_dir(thereby forcing a close to discard this open). That's unnecessary two round-trips to the server.This change adds a check before making the open request to the server to make sure that
SMB2_open_initdid add the expected lease context to the open inopen_cached_dir.Cc <[email protected]>Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/cached_dir.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/smb/client/cached_dir.c +1
-0@@ -286,6 +286,13 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, &rqst[0], &oplock, &oparms, utf16_path);if (rc) goto oshr_free; +
Quoted 8 lines
fs/smb/client/cached_dir.c int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, · line 292
Quoted 3 lines
fs/smb/client/cached_dir.c +3
-0+if (oplock !=SMB2_OPLOCK_LEVEL_II ) { + rc = -EINVAL ; +cifs_dbg (FYI ,"unexpected oplock level %d for cached directory\n" , oplock);Should we reword the log from "'unexpected' oplock level for cached directory" to something like
lease not available for cached dir.? Considering the client itself might be disabling oplock temporarily.
"unexpected" might look misleading.
Hi Bharath,
Thanks for the review. Will make the change.
Quoted 10 lines
fs/smb/client/cached_dir.c int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, · line 298
Quoted 7 lines
fs/smb/client/cached_dir.c +3
-0+ goto oshr_free; + } +smb2_set_next_command (tcon, &rqst[0 ]);memset (&qi_iov,0 ,sizeof (qi_iov));Other than the above minor comment, Changes look good to me.
Reviewed-by Bharath SM <[email protected]>
Signature · 2 lines
Regards, Shyam
PATCH v2 3/7 cifs: invalidate cfid on unlink/rename/rmdir
In reply to [email protected]From: Shyam Prasad N <[email protected]>
Today we do not invalidate the cached_dirent or the entire parent cfid when a dentry in a dir has been removed/moved.
This change invalidates the parent cfid so that we don't serve directory contents from the cache.
--- fs/smb/client/inode.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
fs/smb/client/inode.c +38 -2
@@ -28,6 +28,23 @@#include "cached_dir.h" #include "reparse.h" +static void cifs_invalidate_cached_dir (struct cifs_tcon *tcon, +struct dentry *parent) +{ +struct cached_fid *parent_cfid =NULL ; + +if (!tcon || !parent) +return ; + +if (!open_cached_dir_by_dentry (tcon, parent, &parent_cfid)) { +mutex_lock (&parent_cfid->dirents.de_mutex); + parent_cfid->dirents.is_valid = false; + parent_cfid->dirents.is_failed = true; +mutex_unlock (&parent_cfid->dirents.de_mutex); +close_cached_dir (parent_cfid); + } +} +/* * Set parameters for the netfs library */
@@ -322,7 +339,7 @@ cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info, fattr->cf_uid = uid; } } - + fattr->cf_gid = cifs_sb->ctx->linux_gid;if (!(sbflags &CIFS_MOUNT_OVERR_GID )) {u64 id =le64_to_cpu (info->Gid);
@@ -2067,6 +2084,9 @@ static int __cifs_unlink(struct inode *dir, struct dentry *dentry, bool sillyrencifs_set_file_info (inode, attrs, xid, full_path, origattr); out_reval: +if (!rc && dentry->d_parent) +cifs_invalidate_cached_dir (tcon, dentry->d_parent); +if (inode) { cifs_inode =CIFS_I (inode); cifs_inode->time =0 ;/* will force revalidate to get info
@@ -2378,7 +2398,6 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) } rc = server->ops->rmdir (xid, tcon, full_path, cifs_sb); -cifs_put_tlink (tlink); cifsInode =CIFS_I (d_inode (direntry));
@@ -2388,6 +2407,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)i_size_write (d_inode (direntry),0 );clear_nlink (d_inode (direntry));spin_unlock (&d_inode (direntry)->i_lock); +if (direntry->d_parent) +cifs_invalidate_cached_dir (tcon, direntry->d_parent); }/* force revalidate to go get info when needed */
@@ -2402,6 +2423,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)inode_set_ctime_current (d_inode (direntry));inode_set_mtime_to_ts (inode,inode_set_ctime_current (inode)); +cifs_put_tlink (tlink); rmdir_exit:free_dentry_path (page);
@@ -2501,6 +2523,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,struct cifs_sb_info *cifs_sb;struct tcon_link *tlink;struct cifs_tcon *tcon; +struct dentry *source_parent; +struct dentry *target_parent;bool rehash = false;unsigned int xid;int rc, tmprc;
@@ -2532,6 +2556,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,if (IS_ERR (tlink))return PTR_ERR (tlink); tcon =tlink_tcon (tlink); + source_parent = source_dentry->d_parent ?dget (source_dentry->d_parent) :NULL ; + target_parent = target_dentry->d_parent ?dget (target_dentry->d_parent) :NULL ; server = tcon->ses->server; page1 =alloc_dentry_path ();
@@ -2668,11 +2694,21 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir, }/* force revalidate to go get info when needed */ +if (!rc) { +cifs_invalidate_cached_dir (tcon, source_parent); +if (target_parent != source_parent) +cifs_invalidate_cached_dir (tcon, target_parent); + } +CIFS_I (source_dir)->time =CIFS_I (target_dir)->time =0 ; cifs_rename_exit:if (rehash)d_rehash (target_dentry); +if (target_parent) +dput (target_parent); +if (source_parent) +dput (source_parent);kfree (info_buf_source);free_dentry_path (page2);free_dentry_path (page1);
Signature · 1 line
2.43.0
PATCH v2 4/7 cifs: define variable sized buffer for querydir responses
In reply to [email protected]From: Shyam Prasad N <[email protected]>
QueryDirectory responses today are stored in one of two fixed sized buffers: smallbuf (448 bytes) or bigbuf (16KB). These are borrowed from server struct and are not sufficient for large-sized query dir operations.
With this change we will now define a new buffer type specifically for cifs_search_info to hold variable sized responses. These will be allocated by kmalloc and freed by kfree.
--- fs/smb/client/cifsglob.h | 2 ++ fs/smb/client/file.c | 2 ++ fs/smb/client/readdir.c | 2 ++ fs/smb/client/smb2pdu.c | 14 +++++++++++--- 4 files changed, 17 insertions(+), 3 deletions(-)
fs/smb/client/cifsglob.h +2 -0
@@ -1394,6 +1394,7 @@ struct cifs_search_info { bool emptyDir:1; bool unicode:1; bool smallBuf:1; /* so we know which buf_release function to call */ + bool is_dynamic_buf:1; /* dynamically allocated buffer - can be variable size */ };#define ACL_NO_MODE ((umode_t)(-1))
@@ -1907,6 +1908,7 @@ enum cifs_find_flags {#define CIFS_NO_BUFFER 0/* Response buffer not returned */ #define CIFS_SMALL_BUFFER 1#define CIFS_LARGE_BUFFER 2 +#define CIFS_DYNAMIC_BUFFER 3/* Dynamically allocated buffer */ #define CIFS_IOVEC 4/* array of response buffers */ /* Type of Request to SendReceive2 */
fs/smb/client/file.c +2 -0
@@ -1546,6 +1546,8 @@ int cifs_closedir(struct inode *inode, struct file *file) cfile->srch_inf.ntwrk_buf_start =NULL ;if (cfile->srch_inf.smallBuf)cifs_small_buf_release (buf); +else if (cfile->srch_inf.is_dynamic_buf) +kfree (buf);else cifs_buf_release (buf); }
fs/smb/client/readdir.c +2 -0
@@ -732,6 +732,8 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,if (cfile->srch_inf.smallBuf)cifs_small_buf_release (cfile->srch_inf. ntwrk_buf_start); +else if (cfile->srch_inf.is_dynamic_buf) +kfree (cfile->srch_inf.ntwrk_buf_start);else cifs_buf_release (cfile->srch_inf. ntwrk_buf_start);
fs/smb/client/smb2pdu.c +11 -3
@@ -5625,6 +5625,8 @@ smb2_parse_query_directory(struct cifs_tcon *tcon,if (srch_inf->ntwrk_buf_start) {if (srch_inf->smallBuf)cifs_small_buf_release (srch_inf->ntwrk_buf_start); +else if (srch_inf->is_dynamic_buf) +kfree (srch_inf->ntwrk_buf_start);else cifs_buf_release (srch_inf->ntwrk_buf_start); }
@@ -5644,12 +5646,18 @@ smb2_parse_query_directory(struct cifs_tcon *tcon,cifs_dbg (FYI ,"num entries %d last_index %lld srch start %p srch end %p\n" , srch_inf->entries_in_buffer, srch_inf->index_of_last_entry, srch_inf->srch_entries_start, srch_inf->last_entry); -if (resp_buftype ==CIFS_LARGE_BUFFER ) +if (resp_buftype ==CIFS_LARGE_BUFFER ) { srch_inf->smallBuf = false; -else if (resp_buftype ==CIFS_SMALL_BUFFER ) + srch_inf->is_dynamic_buf = false; + }else if (resp_buftype ==CIFS_SMALL_BUFFER ) { srch_inf->smallBuf = true; -else + srch_inf->is_dynamic_buf = false; + }else if (resp_buftype ==CIFS_DYNAMIC_BUFFER ) { + srch_inf->smallBuf = false; + srch_inf->is_dynamic_buf = true; + }else {cifs_tcon_dbg (VFS ,"Invalid search buffer type\n" ); + }return 0 ; }
Signature · 1 line
2.43.0
PATCH v2 5/7 cifs: optimize readdir for small directories
In reply to [email protected]From: Shyam Prasad N <[email protected]>
For small directories (where the entire directory contents could be read in a single QueryDir request), we currently do an extra round-trip just to get a STATUS_NO_MORE_FILES back from the server.
This change avoids doing that by adding another QueryDir to the first compound to the server for readdir. i.e. first request to readdir will correspond to a compound of (OPEN+QD1+QD2). QD2 will request for a smaller size (in anticipation of STATUS_NO_MORE_FILES).
--- fs/smb/client/smb2ops.c | 156 ++++++++++++++++++++++++++++++++++---- fs/smb/client/smb2pdu.c | 19 +++-- fs/smb/client/smb2pdu.h | 11 +++ fs/smb/client/smb2proto.h | 3 +- 4 files changed, 168 insertions(+), 21 deletions(-)
fs/smb/client/smb2ops.c +141 -15
@@ -2448,18 +2448,21 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_search_info *srch_inf) {__le16 *utf16_path; -struct smb_rqst rqst[2 ]; -struct kvec rsp_iov[2 ]; -int resp_buftype[2 ]; +struct smb_rqst rqst[3 ]; +struct kvec rsp_iov[3 ]; +int resp_buftype[3 ];struct kvec open_iov[SMB2_CREATE_IOV_SIZE ]; -struct kvec qd_iov[SMB2_QUERY_DIRECTORY_IOV_SIZE ]; +struct kvec qd_iov[SMB2_QUERY_DIRECTORY_IOV_SIZE +1 ];/* +1 for padding */ +struct kvec qd2_iov[SMB2_QUERY_DIRECTORY_IOV_SIZE +1 ];/* +1 for padding */ int rc, flags =0 ;u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;struct cifs_open_parms oparms;struct smb2_query_directory_rsp *qd_rsp =NULL ; +struct smb2_query_directory_rsp *qd2_rsp =NULL ;struct smb2_create_rsp *op_rsp =NULL ;struct TCP_Server_Info *server;int retries =0 , cur_sleep =0 ; +unsigned int compound_resp_bufsize; replay_again:/* reinitialize for possible replay */
@@ -2474,8 +2477,15 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,if (smb3_encryption_required (tcon)) flags |=CIFS_TRANSFORM_REQ ; +/* +* Clamp compound Create+QD1+QD2 response sizing to a response size +* for suited for one credit even if CIFSMaxBufSize is tuned larger +*/ + compound_resp_bufsize = min_t(unsigned int, CIFSMaxBufSize, +SMB2_MAX_BUFFER_SIZE ); +memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] =CIFS_NO_BUFFER ; + resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov));/* Open */
@@ -2499,7 +2509,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, goto qdf_free;smb2_set_next_command (tcon, &rqst[0 ]); -/* Query directory */ +/* First Query directory */ srch_inf->entries_in_buffer =0 ; srch_inf->index_of_last_entry =2 ;
@@ -2510,11 +2520,27 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, rc =SMB2_query_directory_init (xid, tcon, server, &rqst[1 ],COMPOUND_FID ,COMPOUND_FID , -0 , srch_inf->info_level); +0 , srch_inf->info_level, +SMB2_QD1_OUTPUT_SIZE (compound_resp_bufsize));if (rc) goto qdf_free;smb2_set_related (&rqst[1 ]); +smb2_set_next_command (tcon, &rqst[1 ]); + +/* Second Query directory - minimal size to check if more data exists */ +memset (&qd2_iov,0 ,sizeof (qd2_iov)); + rqst[2 ].rq_iov = qd2_iov; + rqst[2 ].rq_nvec =SMB2_QUERY_DIRECTORY_IOV_SIZE ; + + rc =SMB2_query_directory_init (xid, tcon, server, + &rqst[2 ], +COMPOUND_FID ,COMPOUND_FID , +0 , srch_inf->info_level,SMB2_QD2_RESPONSE_SIZE ); +if (rc) + goto qdf_free; + +smb2_set_related (&rqst[2 ]);if (retries) {/* Back-off before retry */
@@ -2522,10 +2548,11 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,msleep (cur_sleep);smb2_set_replay (server, &rqst[0 ]);smb2_set_replay (server, &rqst[1 ]); +smb2_set_replay (server, &rqst[2 ]); } rc =compound_send_recv (xid, tcon->ses, server, - flags,2 , rqst, + flags,3 , rqst, resp_buftype, rsp_iov);/* If the open failed there is nothing to do */
@@ -2557,14 +2584,111 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, goto qdf_free; } - rc =smb2_parse_query_directory (tcon, &rsp_iov[1 ], resp_buftype[1 ], - srch_inf); -if (rc) { -trace_smb3_query_dir_err (xid, fid->persistent_fid, tcon->tid, - tcon->ses->Suid,0 ,0 , rc); - goto qdf_free; + qd2_rsp = (struct smb2_query_directory_rsp *)rsp_iov[2 ].iov_base; + +/* +* If QD2 has data, combine QD1 and QD2 responses before parsing. +* The server cursor advances past both responses, so we can't discard QD2. +*/ +if (qd2_rsp && qd2_rsp->hdr.Status ==STATUS_SUCCESS && +le32_to_cpu (qd2_rsp->OutputBufferLength) >0 ) { +char *combined_buf; +size_t qd1_data_len, qd2_data_len, combined_len; +u16 qd1_offset, qd2_offset; +struct smb2_query_directory_rsp *combined_rsp; +struct kvec combined_iov; +FILE_DIRECTORY_INFO *last_entry_in_qd1; +char *qd1_entries_start, *qd2_entries_start; +unsigned int next_offset; + + qd1_offset =le16_to_cpu (qd_rsp->OutputBufferOffset); + qd2_offset =le16_to_cpu (qd2_rsp->OutputBufferOffset); + qd1_data_len =le32_to_cpu (qd_rsp->OutputBufferLength); + qd2_data_len =le32_to_cpu (qd2_rsp->OutputBufferLength); + +/* Allocate buffer for: QD1 header + QD1 data + QD2 data */ + combined_len = qd1_offset + qd1_data_len + qd2_data_len; + combined_buf =kmalloc (combined_len,GFP_KERNEL ); +if (!combined_buf) { + rc = -ENOMEM ; + goto qdf_free; + } + +/* Copy QD1 header and data */ +memcpy (combined_buf, qd_rsp, qd1_offset + qd1_data_len); + +/* Append QD2 data (directory entries only, not the header) */ +memcpy (combined_buf + qd1_offset + qd1_data_len, + (char *)qd2_rsp + qd2_offset, qd2_data_len); + +/* Update OutputBufferLength to reflect combined data */ + combined_rsp = (struct smb2_query_directory_rsp *)combined_buf; + combined_rsp->OutputBufferLength =cpu_to_le32 (qd1_data_len + qd2_data_len); + +/* +* Chain QD1 and QD2 entries: find the last entry in QD1 and update +* its NextEntryOffset to point to the first entry in QD2. +*/ +if (qd1_data_len >0 ) { + qd1_entries_start = combined_buf + qd1_offset; + qd2_entries_start = combined_buf + qd1_offset + qd1_data_len; + last_entry_in_qd1 = (FILE_DIRECTORY_INFO *)qd1_entries_start; + +/* Walk QD1 entries to find the last one with bounds checking */ +while (1 ) { +char *end_of_qd1 = qd1_entries_start + qd1_data_len; + + next_offset =le32_to_cpu (last_entry_in_qd1->NextEntryOffset); +if (next_offset ==0 ) +break ;/* Found last entry */ + +/* Bounds check before advancing */ +if ((char *)last_entry_in_qd1 + next_offset >= end_of_qd1) { +cifs_dbg (VFS ,"query_dir_first: invalid NextEntryOffset in QD1\n" ); +kfree (combined_buf); + rc = -EIO ; + goto qdf_free; + } + + last_entry_in_qd1 = (FILE_DIRECTORY_INFO *)((char *)last_entry_in_qd1 + next_offset); + } + +/* Chain last QD1 entry to first QD2 entry */ + last_entry_in_qd1->NextEntryOffset =cpu_to_le32 (qd2_entries_start - (char *)last_entry_in_qd1); + } + +/* Parse the combined buffer */ + combined_iov.iov_base = combined_buf; + combined_iov.iov_len = combined_len; + rc =smb2_parse_query_directory (tcon, &combined_iov,CIFS_DYNAMIC_BUFFER , + srch_inf); +if (rc) { +kfree (combined_buf); +trace_smb3_query_dir_err (xid, fid->persistent_fid, tcon->tid, + tcon->ses->Suid,0 ,0 , rc); + goto qdf_free; + } +/* Ownership of combined_buf transferred to srch_inf->ntwrk_buf_start */ + srch_inf->endOfSearch = false; +cifs_dbg (FYI ,"query_dir_first: combined QD1 and QD2, %d entries\n" , + srch_inf->entries_in_buffer); + }else { +/* No data in QD2, just parse QD1 */ + rc =smb2_parse_query_directory (tcon, &rsp_iov[1 ], resp_buftype[1 ], + srch_inf); +if (rc) { +trace_smb3_query_dir_err (xid, fid->persistent_fid, tcon->tid, + tcon->ses->Suid,0 ,0 , rc); + goto qdf_free; + } + resp_buftype[1 ] =CIFS_NO_BUFFER ; + +/* Check if QD2 indicates end of directory */ +if (qd2_rsp && qd2_rsp->hdr.Status ==STATUS_NO_MORE_FILES ) { + srch_inf->endOfSearch = true; +cifs_dbg (FYI ,"query_dir_first: small directory, all entries read\n" ); + } } - resp_buftype[1 ] =CIFS_NO_BUFFER ;trace_smb3_query_dir_done (xid, fid->persistent_fid, tcon->tid, tcon->ses->Suid,0 , srch_inf->entries_in_buffer);
@@ -2573,8 +2697,10 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,kfree (utf16_path);SMB2_open_free (&rqst[0 ]);SMB2_query_directory_free (&rqst[1 ]); +SMB2_query_directory_free (&rqst[2 ]);free_rsp_buf (resp_buftype[0 ], rsp_iov[0 ].iov_base);free_rsp_buf (resp_buftype[1 ], rsp_iov[1 ].iov_base); +free_rsp_buf (resp_buftype[2 ], rsp_iov[2 ].iov_base);if (is_replayable_error (rc) &&smb2_should_replay (tcon, &retries, &cur_sleep))
fs/smb/client/smb2pdu.c +14 -5
@@ -5504,18 +5504,27 @@ int SMB2_query_directory_init(const unsigned int xid,struct TCP_Server_Info *server, struct smb_rqst *rqst, u64 persistent_fid, u64 volatile_fid, - int index, int info_level) + int index, int info_level, + unsigned int output_size) { struct smb2_query_directory_req *req;unsigned char *bufptr;__le16 asteriks =cpu_to_le16 ('*' ); -unsigned int output_size = CIFSMaxBufSize - -MAX_SMB2_CREATE_RESPONSE_SIZE - -MAX_SMB2_CLOSE_RESPONSE_SIZE ;unsigned int total_len;struct kvec *iov = rqst->rq_iov;int len, rc; +/* +* Use provided output_size, or default to CIFSMaxBufSize calculation. +* The default is for standalone QueryDir (smb2_query_dir_next). +* For compounds, the caller should pass explicit output_size. +*/ +if (output_size ==0 ) { + output_size = CIFSMaxBufSize - +MAX_SMB2_CREATE_RESPONSE_SIZE - +MAX_SMB2_CLOSE_RESPONSE_SIZE ; + } + rc =smb2_plain_req_init (SMB2_QUERY_DIRECTORY , tcon, server, (void **) &req, &total_len);if (rc)
@@ -5697,7 +5706,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, rc =SMB2_query_directory_init (xid, tcon, server, &rqst, persistent_fid, volatile_fid, index, - srch_inf->info_level); + srch_inf->info_level,0 );if (rc) goto qdir_exit;
fs/smb/client/smb2pdu.h +11 -0
@@ -129,6 +129,17 @@ struct share_redirect_error_context_rsp {*/ #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 +/* Size of the minimal QueryDir response for checking if more data exists */ +#define SMB2_QD2_RESPONSE_SIZE 4096 + +/* +* Output buffer size for first QueryDir in Create+QD1+QD2 compound. +* Accounts for shared buffer space needed for all three responses. +*/ +#define SMB2_QD1_OUTPUT_SIZE (bufsize) \ + ((bufsize) - MAX_SMB2_CREATE_RESPONSE_SIZE - \ + sizeof(struct smb2_hdr) - SMB2_QD2_RESPONSE_SIZE) +#define SMB2_LEASE_READ_CACHING_HE 0x01#define SMB2_LEASE_HANDLE_CACHING_HE 0x02#define SMB2_LEASE_WRITE_CACHING_HE 0x04
fs/smb/client/smb2proto.h +2 -1
@@ -194,7 +194,8 @@ int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,int SMB2_query_directory_init (const unsigned int xid,struct cifs_tcon *tcon,struct TCP_Server_Info *server,struct smb_rqst *rqst,u64 persistent_fid, -u64 volatile_fid,int index,int info_level); +u64 volatile_fid,int index,int info_level, +unsigned int output_size);void SMB2_query_directory_free (struct smb_rqst *rqst); int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, u32 pid,
Signature · 1 line
2.43.0
PATCH v2 6/7 cifs: optimize readdir for larger directories
In reply to [email protected]From: Shyam Prasad N <[email protected]>
Today QueryDirectory uses the compound_send_recv infrastructure which is limited to 16KB in size. As a result, readdir of large directories generally take several round trips.
With this change, if the readdir needs a QueryDir after the first round-trip (meaning that there are more dirents to read), then the following QueryDirs will now switch to using larger buffers with MTU credits.
Till now, the only command type that used this flow was SMB2_READ. In case of encrypted response, it becomes challenging to decide if the response is for SMB2_READ or SMB2_READDIR. This change reuses receive_encrypted_read and after decrypting the response decides the handling function based on the command in the resp header. That way, care has been taken to ensure that the read code path modifications on account of this change are kept to a minimum.
--- fs/smb/client/cifsglob.h | 21 +- fs/smb/client/cifsproto.h | 3 + fs/smb/client/readdir.c | 2 +- fs/smb/client/smb1ops.c | 4 +- fs/smb/client/smb2misc.c | 7 +- fs/smb/client/smb2ops.c | 458 ++++++++++++++++++++++++++++++++++++-- fs/smb/client/smb2pdu.c | 185 ++++++++++++++- fs/smb/client/smb2pdu.h | 3 + fs/smb/client/smb2proto.h | 3 + fs/smb/client/trace.h | 1 + fs/smb/client/transport.c | 171 ++++++++++++++ 11 files changed, 823 insertions(+), 35 deletions(-)
fs/smb/client/cifsglob.h +20 -1
@@ -504,7 +504,7 @@ struct smb_version_operations { struct cifs_search_info *);/* continue readdir */ int (*query_dir_next)(const unsigned int ,struct cifs_tcon *, -struct cifs_fid *, +struct cifs_sb_info *,struct cifs_fid *,__u16 ,struct cifs_search_info *srch_inf);/* close dir */ int (*close_dir)(const unsigned int, struct cifs_tcon *,
@@ -1397,6 +1397,25 @@ struct cifs_search_info { bool is_dynamic_buf:1; /* dynamically allocated buffer - can be variable size */ }; +/* Structure for QueryDirectory with multi-credit support */ +struct cifs_query_dir_io { +struct cifs_tcon *tcon; +struct TCP_Server_Info *server; +struct cifs_search_info *srch_inf; +unsigned int xid; +u64 persistent_fid; +u64 volatile_fid; +int index; +struct kvec combined_iov;/* Pre-allocated buffer to hold resp */ +struct completion done; +int result; +struct cifs_credits credits; +bool replay; +unsigned int retries; +unsigned int cur_sleep; +struct kvec iov[2 ];/* For response handling */ +}; +#define ACL_NO_MODE ((umode_t)(-1))struct cifs_open_parms {struct cifs_tcon *tcon;
fs/smb/client/cifsproto.h +3 -0
@@ -336,6 +336,9 @@ struct cifs_ses *cifs_get_smb_ses(struct TCP_Server_Info *server,int cifs_readv_receive (struct TCP_Server_Info *server,struct mid_q_entry *mid); +int cifs_query_dir_receive (struct TCP_Server_Info *server, +struct mid_q_entry *mid); + int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, const unsigned char *path, char *pbuf,
fs/smb/client/readdir.c +1 -1
@@ -760,7 +760,7 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,while ((index_to_find >= cfile->srch_inf.index_of_last_entry) && (rc ==0 ) && !cfile->srch_inf.endOfSearch) {cifs_dbg (FYI ,"calling findnext2\n" ); - rc = server->ops->query_dir_next (xid, tcon, &cfile->fid, + rc = server->ops->query_dir_next (xid, tcon, cifs_sb, &cfile->fid, search_flags, &cfile->srch_inf);if (rc)
fs/smb/client/smb1ops.c +2 -2
@@ -1135,8 +1135,8 @@ cifs_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,static int cifs_query_dir_next (const unsigned int xid,struct cifs_tcon *tcon, -struct cifs_fid *fid,__u16 search_flags, -struct cifs_search_info *srch_inf) +struct cifs_sb_info *cifs_sb,struct cifs_fid *fid, +__u16 search_flags,struct cifs_search_info *srch_inf) {return CIFSFindNext (xid, tcon, fid->netfid, search_flags, srch_inf); }
fs/smb/client/smb2misc.c +6 -1
@@ -12,6 +12,7 @@#include "cifsglob.h" #include "cifsproto.h" #include "smb2proto.h" +#include "smb2pdu.h" #include "cifs_debug.h" #include "cifs_unicode.h" #include "../common/smb2status.h"
@@ -316,7 +317,7 @@ char * smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr) {const int max_off =4096 ; -const int max_len =128 *1024 ; +int max_len =128 *1024 ; *off =0 ; *len =0 ;
@@ -367,6 +368,10 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr) ((struct smb2_query_directory_rsp *)shdr)->OutputBufferOffset); *len =le32_to_cpu ( ((struct smb2_query_directory_rsp *)shdr)->OutputBufferLength); +/* Allow larger buffers for query directory (up to 2MB). +* The actual data is handled separately in cifs_query_dir_receive(). +*/ + max_len =SMB2_MAX_QD_DATABUF_SIZE ;break ;case SMB2_IOCTL : *off = le32_to_cpu(
fs/smb/client/smb2ops.c +434 -24
535 lines not on this page · raw message
fs/smb/client/smb2pdu.c +179 -6
197 lines not on this page · raw message
fs/smb/client/smb2pdu.h +3 -0
@@ -132,6 +132,9 @@ struct share_redirect_error_context_rsp {/* Size of the minimal QueryDir response for checking if more data exists */ #define SMB2_QD2_RESPONSE_SIZE 4096 +/* max query directory data buffer size */ +#define SMB2_MAX_QD_DATABUF_SIZE (2 * 1024 * 1024) +/* * Output buffer size for first QueryDir in Create+QD1+QD2 compound. * Accounts for shared buffer space needed for all three responses.
fs/smb/client/smb2proto.h +3 -0
@@ -46,6 +46,8 @@ __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode, unsigned int oplock);bool smb2_is_valid_oplock_break (char *buffer,struct TCP_Server_Info *server);int smb3_handle_read_data (struct TCP_Server_Info *server,struct mid_q_entry *mid); +int smb2_query_dir_handle_data (struct TCP_Server_Info *server, +struct mid_q_entry *mid); struct inode *smb2_create_reparse_inode(struct cifs_open_info_data *data, struct super_block *sb, const unsigned int xid,
@@ -197,6 +199,7 @@ int SMB2_query_directory_init(const unsigned int xid, struct cifs_tcon *tcon, u64 volatile_fid, int index, int info_level, unsigned int output_size);void SMB2_query_directory_free (struct smb_rqst *rqst); +int SMB2_query_directory_large (struct cifs_query_dir_io *qd_io,unsigned int buf_size);int SMB2_set_eof (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid,u32 pid,loff_t new_eof);
fs/smb/client/trace.h +1 -0
@@ -165,6 +165,7 @@ EM(cifs_trace_rw_credits_write_prepare, "wr-prepare ") \ EM(cifs_trace_rw_credits_write_response_add, "wr-resp-add") \ EM(cifs_trace_rw_credits_write_response_clear, "wr-resp-clr") \ + EM(cifs_trace_rw_credits_query_dir_done, "qd-done ") \ E_(cifs_trace_rw_credits_zero_in_flight, "ZERO-IN-FLT")#define smb3_tcon_ref_traces \
fs/smb/client/transport.c +171 -0
177 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 7/7 cifs: reorganize cached dir helpers
In reply to [email protected]From: Shyam Prasad N <[email protected]>
Currently, we have helper functions for cfid and dirent caching spread across cached_dir.c and readdir.c, with de_mutex locking done inside the calling functions. This change neatly wraps them in helper functions and keeps all such functions in cached_dir.c.
This code also splits the logic of dirent emit into cache and to VFS into different functions.
--- fs/smb/client/cached_dir.c | 207 +++++++++++++++++++++++++++++++++++++ fs/smb/client/cached_dir.h | 18 +++- fs/smb/client/readdir.c | 167 ++---------------------------- 3 files changed, 231 insertions(+), 161 deletions(-)
fs/smb/client/cached_dir.c +207 -0
@@ -23,6 +23,213 @@ struct cached_dir_dentry {struct dentry *dentry; }; +static bool emit_cached_dirents (struct cached_dirents *cde, +struct dir_context *ctx) +{ +struct cached_dirent *dirent; +bool rc; + +lockdep_assert_held (&cde->de_mutex); + +list_for_each_entry (dirent, &cde->entries, entry) { +/* +* Skip all early entries prior to the current lseek() +* position. +*/ +if (ctx->pos > dirent->pos) +continue ; +/* +* We recorded the current ->pos value for the dirent +* when we stored it in the cache. +* However, this sequence of ->pos values may have holes +* in it, for example dot-dirs returned from the server +* are suppressed. +* Handle this by forcing ctx->pos to be the same as the +* ->pos of the current dirent we emit from the cache. +* This means that when we emit these entries from the cache +* we now emit them with the same ->pos value as in the +* initial scan. +*/ + ctx->pos = dirent->pos; + rc =dir_emit (ctx, dirent->name, dirent->namelen, + dirent->fattr.cf_uniqueid, + dirent->fattr.cf_dtype); +if (!rc) +return rc; + ctx->pos++; + } +return true; +} + +static bool add_cached_dirent (struct cached_dirents *cde, +struct dir_context *ctx,const char *name, +int namelen,struct cifs_fattr *fattr, +struct file *file) +{ +struct cached_dirent *de; + +lockdep_assert_held (&cde->de_mutex); + +if (cde->file != file) +return false; +if (cde->is_valid || cde->is_failed) +return false; +if (ctx->pos != cde->pos) { + cde->is_failed =1 ; +return false; + } + de =kzalloc_obj (*de,GFP_KERNEL ); +if (de ==NULL ) { + cde->is_failed =1 ; +return false; + } + de->namelen = namelen; + de->name =kstrndup (name, namelen,GFP_KERNEL ); +if (de->name ==NULL ) { +kfree (de); + cde->is_failed =1 ; +return false; + } + de->pos = ctx->pos; + +memcpy (&de->fattr, fattr,sizeof (struct cifs_fattr )); + +list_add_tail (&de->entry, &cde->entries); +/* update accounting */ + cde->entries_count++; + cde->bytes_used +=sizeof (*de) + (size_t )namelen +1 ; +return true; +} + +bool emit_cached_dir_if_valid (struct cached_fid *cfid, +struct file *file, +struct dir_context *ctx) +{ +if (!cfid) +return false; + +mutex_lock (&cfid->dirents.de_mutex); +/* +* If this was reading from the start of the directory +* we need to initialize scanning and storing the +* directory content. +*/ +if (ctx->pos ==0 && cfid->dirents.file ==NULL ) { + cfid->dirents.file = file; + cfid->dirents.pos =2 ; + } + +if (!cfid->dirents.is_valid) { +mutex_unlock (&cfid->dirents.de_mutex); +return false; + } + +if (dir_emit_dots (file, ctx)) +emit_cached_dirents (&cfid->dirents, ctx); + +mutex_unlock (&cfid->dirents.de_mutex); +return true; +} + +bool add_to_cached_dir (struct cached_fid *cfid, +struct dir_context *ctx, +const char *name, +int namelen, +struct cifs_fattr *fattr, +struct file *file) +{ +size_t delta_bytes; +bool added = false; + +if (!cfid) +return false; + +/* Cost of this entry */ + delta_bytes =sizeof (struct cached_dirent ) + (size_t )namelen +1 ; + +mutex_lock (&cfid->dirents.de_mutex); + added =add_cached_dirent (&cfid->dirents, ctx, name, namelen, + fattr, file); +mutex_unlock (&cfid->dirents.de_mutex); + +if (added) { +/* per-tcon then global for consistency with free path */ +atomic64_add ((long long )delta_bytes, &cfid->cfids->total_dirents_bytes); +atomic_long_inc (&cfid->cfids->total_dirents_entries); +atomic64_add ((long long )delta_bytes, &cifs_dircache_bytes_used); + } + +return added; +} + +static void update_cached_dirents_count (struct cached_dirents *cde, +struct file *file) +{ +if (cde->file != file) +return ; +if (cde->is_valid || cde->is_failed) +return ; + + cde->pos++; +} + +static void finished_cached_dirents_count (struct cached_dirents *cde, +struct dir_context *ctx, +struct file *file) +{ +if (cde->file != file) +return ; +if (cde->is_valid || cde->is_failed) +return ; +if (ctx->pos != cde->pos) +return ; + + cde->is_valid =1 ; +} + +void update_pos_cached_dir (struct cached_fid *cfid, +struct file *file) +{ +if (!cfid) +return ; + +mutex_lock (&cfid->dirents.de_mutex); +update_cached_dirents_count (&cfid->dirents, file); +mutex_unlock (&cfid->dirents.de_mutex); +} + +void complete_cached_dir (struct cached_fid *cfid, +struct dir_context *ctx, +struct file *file) +{ +if (!cfid) +return ; + +mutex_lock (&cfid->dirents.de_mutex); +finished_cached_dirents_count (&cfid->dirents, ctx, file); +mutex_unlock (&cfid->dirents.de_mutex); +} + +struct cached_dirent *lookup_cached_dirent (struct cached_dirents *cde, +const char *name, +unsigned int namelen) +{ +struct cached_dirent *entry; + +if (!cde) +return NULL ; + +lockdep_assert_held (&cde->de_mutex); + +list_for_each_entry (entry, &cde->entries, entry) { +if (entry->namelen == namelen && +memcmp (entry->name, name, namelen) ==0 ) +return entry; + } + +return NULL ; +} + static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids, const char *path, bool lookup_only,
fs/smb/client/cached_dir.h +17 -1
@@ -8,7 +8,6 @@ #ifndef _CACHED_DIR_H #define _CACHED_DIR_H - struct cached_dirent { struct list_head entry; char *name;
@@ -87,6 +86,23 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, const char *path,int open_cached_dir_by_dentry (struct cifs_tcon *tcon,struct dentry *dentry,struct cached_fid **ret_cfid);void close_cached_dir (struct cached_fid *cfid); +bool emit_cached_dir_if_valid (struct cached_fid *cfid, +struct file *file, +struct dir_context *ctx); +bool add_to_cached_dir (struct cached_fid *cfid, +struct dir_context *ctx, +const char *name, +int namelen, +struct cifs_fattr *fattr, +struct file *file); +void update_pos_cached_dir (struct cached_fid *cfid, +struct file *file); +void complete_cached_dir (struct cached_fid *cfid, +struct dir_context *ctx, +struct file *file); +struct cached_dirent *lookup_cached_dirent (struct cached_dirents *cde, +const char *name, +unsigned int namelen);void drop_cached_dir_by_name (const unsigned int xid,struct cifs_tcon *tcon,const char *name,struct cifs_sb_info *cifs_sb);void close_all_cached_dirs (struct cifs_sb_info *cifs_sb);
fs/smb/client/readdir.c +7 -160
205 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 35 lines · On Mon, Apr 20, 2026 at 11:40 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
Today we skip calling
change_conffor negotiates and session setup requests. This can be a problem for mchan as the immediate next call after session setup could be due to an I/O that is made on the mount point. For single channel, this is not a problem as there will be several calls after setting up session.This change enforces calling
change_conffor the last session setup response, so that echoes and oplocks are not disabled before the first request to the server. So if that first request is an open, it does not need to disable requesting leases.Cc <[email protected]>Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2ops.c | 9 +++++++++ 1 file changed, 9 insertions(+)fs/smb/client/smb2ops.c +6
-0@@ -111,10 +111,19 @@ smb2_add_credits(struct TCP_Server_Info *server, cifs_trace_rw_credits_zero_in_flight); } server->in_flight--; + +/* +* Rebalance credits when an op drains in_flight. For session setup, +* do this only when the server actually granted positive credits (>2) so a +* newly established secondary channel can reserve echo/oplock credits. +*/ if (server->in_flight == 0 &&
fs/smb/client/smb2ops.c smb2_add_credits(struct TCP_Server_Info *server,
Quoted 10 lines
fs/smb/client/smb2ops.c +3
-1((optype & CIFS_OP_MASK) != CIFS_NEG_OP) && ((optype & CIFS_OP_MASK) != CIFS_SESS_OP)) rc =change_conf (server); + else if (server->in_flight == 0 && + ((optype & CIFS_OP_MASK) == CIFS_SESS_OP) && add > 2) + rc =change_conf (server);/* * Sometimes server returns 0 credits on oplock break ack - we need to * rebalance credits in this case. --
I think it would be good to add a comment explaining why the ' add > 2' threshold is chosen
here and the assumption that the final session setup response SMB server returns '>2' credits.
Otherwise, Changes look good to me.
Quoted 52 lines · Bharath SM
Quoted 35 lines · On Mon, Apr 20, 2026 at 11:40 PM <[email protected]> wrote:
From: Shyam Prasad N <[email protected]>
Today we skip calling
change_conffor negotiates and session setup requests. This can be a problem for mchan as the immediate next call after session setup could be due to an I/O that is made on the mount point. For single channel, this is not a problem as there will be several calls after setting up session.This change enforces calling
change_conffor the last session setup response, so that echoes and oplocks are not disabled before the first request to the server. So if that first request is an open, it does not need to disable requesting leases.Cc <[email protected]>Signed-off-by Shyam Prasad N <[email protected]>--- fs/smb/client/smb2ops.c | 9 +++++++++ 1 file changed, 9 insertions(+)fs/smb/client/smb2ops.c +6
-0@@ -111,10 +111,19 @@ smb2_add_credits(struct TCP_Server_Info *server, cifs_trace_rw_credits_zero_in_flight); } server->in_flight--; + +/* +* Rebalance credits when an op drains in_flight. For session setup, +* do this only when the server actually granted positive credits (>2) so a +* newly established secondary channel can reserve echo/oplock credits. +*/ if (server->in_flight == 0 &&fs/smb/client/smb2ops.c smb2_add_credits(struct TCP_Server_Info *server,
Quoted 10 lines
fs/smb/client/smb2ops.c +3
-1((optype & CIFS_OP_MASK) != CIFS_NEG_OP) && ((optype & CIFS_OP_MASK) != CIFS_SESS_OP)) rc =change_conf (server); + else if (server->in_flight == 0 && + ((optype & CIFS_OP_MASK) == CIFS_SESS_OP) && add > 2) + rc =change_conf (server);/* * Sometimes server returns 0 credits on oplock break ack - we need to * rebalance credits in this case. -- I think it would be good to add a comment explaining why the ' add > 2' threshold is chosen
here and the assumption that the final session setup response SMB server returns '>2' credits.
Quoted 1 line
Otherwise, Changes look good to me.
Ack. Will add more descriptive comment.
Signature · 2 lines
Regards, Shyam