* [PATCH 1/2] cifs: Corrections to lock ordering notes
@ 2026-01-31 8:02 nspmangalore
2026-01-31 8:02 ` [PATCH 2/2] cifs: Fix locking usage for tcon fields nspmangalore
0 siblings, 1 reply; 6+ messages in thread
From: nspmangalore @ 2026-01-31 8:02 UTC (permalink / raw)
To: linux-cifs, smfrench, pc, bharathsm; +Cc: Shyam Prasad N
From: Shyam Prasad N <sprasad@microsoft.com>
There were a couple of discrepencies in lock ordering for the locks
that were specified in the lock ordering notes. Did an analysis
of the current codebase (using LLM) and found two pairs whose ordering
in these notes were wrong. It also found one lock that was recently
removed, and a few locks that weren't documented here before.
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
---
fs/smb/client/cifsglob.h | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 3eca5bfb70303..d797b953b6cf6 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1943,6 +1943,8 @@ require use of the stronger protocol */
*/
/****************************************************************************
+ * LOCK ORDERING NOTES:
+ ****************************************************************************
* Here are all the locks (spinlock, mutex, semaphore) in cifs.ko, arranged according
* to the locking order. i.e. if two locks are to be held together, the lock that
* appears higher in this list needs to be taken before the other.
@@ -1971,18 +1973,21 @@ require use of the stronger protocol */
* =====================================================================================
* Lock Protects Initialization fn
* =====================================================================================
+ * cifs_mount_mutex mount/unmount operations
* vol_list_lock
* vol_info->ctx_lock vol_info->ctx
* cifs_sb_info->tlink_tree_lock cifs_sb_info->tlink_tree cifs_setup_cifs_sb
* TCP_Server_Info-> TCP_Server_Info cifs_get_tcp_session
* reconnect_mutex
- * TCP_Server_Info->srv_mutex TCP_Server_Info cifs_get_tcp_session
* cifs_ses->session_mutex cifs_ses sesInfoAlloc
+ * TCP_Server_Info->_srv_mutex TCP_Server_Info cifs_get_tcp_session
+ * cifs_tcp_ses_lock cifs_tcp_ses_list sesInfoAlloc
* cifs_tcon->open_file_lock cifs_tcon->openFileList tconInfoAlloc
* cifs_tcon->pending_opens
* cifs_tcon->stat_lock cifs_tcon->bytes_read tconInfoAlloc
* cifs_tcon->bytes_written
- * cifs_tcp_ses_lock cifs_tcp_ses_list sesInfoAlloc
+ * cifs_tcon->fscache_lock cifs_tcon->fscache tconInfoAlloc
+ * cifs_tcon->sb_list_lock cifs_tcon->cifs_sb_list tconInfoAlloc
* GlobalMid_Lock GlobalMaxActiveXid init_cifs
* GlobalCurrentXid
* GlobalTotalActiveXid
@@ -2005,6 +2010,8 @@ require use of the stronger protocol */
* ->chans_in_reconnect
* cifs_tcon->tc_lock (anything that is not protected by another lock and can change)
* tcon_info_alloc
+ * cifs_swnreg_idr_mutex cifs_swnreg_idr cifs_swn.c
+ * (witness service registration, accesses tcon fields under tc_lock)
* inode->i_rwsem, taken by fs/netfs/locking.c e.g. should be taken before cifsInodeInfo locks
* cifsInodeInfo->open_file_lock cifsInodeInfo->openFileList cifs_alloc_inode
* cifsInodeInfo->writers_lock cifsInodeInfo->writers cifsInodeInfo_alloc
@@ -2012,12 +2019,12 @@ require use of the stronger protocol */
* ->can_cache_brlcks
* cifsInodeInfo->deferred_lock cifsInodeInfo->deferred_closes cifsInodeInfo_alloc
* cached_fids->cfid_list_lock cifs_tcon->cfids->entries init_cached_dirs
- * cached_fid->fid_lock (anything that is not protected by another lock and can change)
- * init_cached_dir
+ * cached_fid->dirents.de_mutex cached_fid->dirents alloc_cached_dir
* cifsFileInfo->fh_mutex cifsFileInfo cifs_new_fileinfo
* cifsFileInfo->file_info_lock cifsFileInfo->count cifs_new_fileinfo
* ->invalidHandle initiate_cifs_search
* ->oplock_break_cancelled
+ * smbdirect_mr->mutex RDMA memory region management (SMBDirect only)
* mid_q_entry->mid_lock mid_q_entry->callback alloc_mid
* smb2_mid_entry_alloc
* (Any fields of mid_q_entry that will need protection)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] cifs: Fix locking usage for tcon fields
2026-01-31 8:02 [PATCH 1/2] cifs: Corrections to lock ordering notes nspmangalore
@ 2026-01-31 8:02 ` nspmangalore
2026-01-31 10:07 ` Shyam Prasad N
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: nspmangalore @ 2026-01-31 8:02 UTC (permalink / raw)
To: linux-cifs, smfrench, pc, bharathsm; +Cc: Shyam Prasad N, stable
From: Shyam Prasad N <sprasad@microsoft.com>
We used to use the cifs_tcp_ses_lock to protect a lot of objects
that are not just the server, ses or tcon lists. We later introduced
srv_lock, ses_lock and tc_lock to protect fields within the
corresponding structs. This was done to provide a more granular
protection and avoid unnecessary serialization.
There were still a couple of uses of cifs_tcp_ses_lock to provide
tcon fields. In this patch, I've replaced them with tc_lock.
Cc: stable@vger.kernel.org
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
---
fs/smb/client/cached_dir.c | 4 ++--
fs/smb/client/smb2misc.c | 6 +++---
fs/smb/client/smb2ops.c | 8 +++-----
fs/smb/client/smb2pdu.c | 2 ++
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 1db7ab6c2529c..84c3aea18a1a7 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -788,11 +788,11 @@ static void cfids_laundromat_worker(struct work_struct *work)
cfid->dentry = NULL;
if (cfid->is_open) {
- spin_lock(&cifs_tcp_ses_lock);
+ spin_lock(&tcon->tc_lock);
++cfid->tcon->tc_count;
trace_smb3_tcon_ref(cfid->tcon->debug_id, cfid->tcon->tc_count,
netfs_trace_tcon_ref_get_cached_laundromat);
- spin_unlock(&cifs_tcp_ses_lock);
+ spin_unlock(&tcon->tc_lock);
queue_work(serverclose_wq, &cfid->close_work);
} else
/*
diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
index f3cb62d914502..0871b9f1f86a6 100644
--- a/fs/smb/client/smb2misc.c
+++ b/fs/smb/client/smb2misc.c
@@ -820,14 +820,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
int rc;
cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count);
- spin_lock(&cifs_tcp_ses_lock);
+ spin_lock(&tcon->tc_lock);
if (tcon->tc_count <= 0) {
struct TCP_Server_Info *server = NULL;
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
netfs_trace_tcon_ref_see_cancelled_close);
WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
- spin_unlock(&cifs_tcp_ses_lock);
+ spin_unlock(&tcon->tc_lock);
if (tcon->ses) {
server = tcon->ses->server;
@@ -841,7 +841,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
tcon->tc_count++;
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
netfs_trace_tcon_ref_get_cancelled_close);
- spin_unlock(&cifs_tcp_ses_lock);
+ spin_unlock(&tcon->tc_lock);
rc = __smb2_handle_cancelled_cmd(tcon, SMB2_CLOSE_HE, 0,
persistent_fid, volatile_fid);
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index c1aaf77e187b6..6f930d6c78adb 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -3091,7 +3091,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
struct cifs_tcon,
tcon_list);
if (tcon) {
+ spin_lock(&tcon->tc_lock);
tcon->tc_count++;
+ spin_unlock(&tcon->tc_lock);
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
netfs_trace_tcon_ref_get_dfs_refer);
}
@@ -3160,13 +3162,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
out:
if (tcon && !tcon->ipc) {
/* ipc tcons are not refcounted */
- spin_lock(&cifs_tcp_ses_lock);
- tcon->tc_count--;
+ cifs_put_tcon(tcon);
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
netfs_trace_tcon_ref_dec_dfs_refer);
- /* tc_count can never go negative */
- WARN_ON(tcon->tc_count < 0);
- spin_unlock(&cifs_tcp_ses_lock);
}
kfree(utf16_path);
kfree(dfs_req);
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 5d57c895ca37a..c7e086dfb1765 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -4239,7 +4239,9 @@ void smb2_reconnect_server(struct work_struct *work)
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
if (tcon->need_reconnect || tcon->need_reopen_files) {
+ spin_lock(&tcon->tc_lock);
tcon->tc_count++;
+ spin_unlock(&tcon->tc_lock);
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
netfs_trace_tcon_ref_get_reconnect_server);
list_add_tail(&tcon->rlist, &tmp_list);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] cifs: Fix locking usage for tcon fields
2026-01-31 8:02 ` [PATCH 2/2] cifs: Fix locking usage for tcon fields nspmangalore
@ 2026-01-31 10:07 ` Shyam Prasad N
2026-01-31 14:58 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Shyam Prasad N @ 2026-01-31 10:07 UTC (permalink / raw)
To: linux-cifs, smfrench, pc, bharathsm; +Cc: Shyam Prasad N, stable
On Sat, Jan 31, 2026 at 1:33 PM <nspmangalore@gmail.com> wrote:
>
> From: Shyam Prasad N <sprasad@microsoft.com>
>
> We used to use the cifs_tcp_ses_lock to protect a lot of objects
> that are not just the server, ses or tcon lists. We later introduced
> srv_lock, ses_lock and tc_lock to protect fields within the
> corresponding structs. This was done to provide a more granular
> protection and avoid unnecessary serialization.
>
> There were still a couple of uses of cifs_tcp_ses_lock to provide
> tcon fields. In this patch, I've replaced them with tc_lock.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
> ---
> fs/smb/client/cached_dir.c | 4 ++--
> fs/smb/client/smb2misc.c | 6 +++---
> fs/smb/client/smb2ops.c | 8 +++-----
> fs/smb/client/smb2pdu.c | 2 ++
> 4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
> index 1db7ab6c2529c..84c3aea18a1a7 100644
> --- a/fs/smb/client/cached_dir.c
> +++ b/fs/smb/client/cached_dir.c
> @@ -788,11 +788,11 @@ static void cfids_laundromat_worker(struct work_struct *work)
> cfid->dentry = NULL;
>
> if (cfid->is_open) {
> - spin_lock(&cifs_tcp_ses_lock);
> + spin_lock(&tcon->tc_lock);
> ++cfid->tcon->tc_count;
> trace_smb3_tcon_ref(cfid->tcon->debug_id, cfid->tcon->tc_count,
> netfs_trace_tcon_ref_get_cached_laundromat);
> - spin_unlock(&cifs_tcp_ses_lock);
> + spin_unlock(&tcon->tc_lock);
> queue_work(serverclose_wq, &cfid->close_work);
> } else
> /*
> diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
> index f3cb62d914502..0871b9f1f86a6 100644
> --- a/fs/smb/client/smb2misc.c
> +++ b/fs/smb/client/smb2misc.c
> @@ -820,14 +820,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
> int rc;
>
> cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count);
> - spin_lock(&cifs_tcp_ses_lock);
> + spin_lock(&tcon->tc_lock);
> if (tcon->tc_count <= 0) {
> struct TCP_Server_Info *server = NULL;
>
> trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
> netfs_trace_tcon_ref_see_cancelled_close);
> WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
> - spin_unlock(&cifs_tcp_ses_lock);
> + spin_unlock(&tcon->tc_lock);
>
> if (tcon->ses) {
> server = tcon->ses->server;
> @@ -841,7 +841,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
> tcon->tc_count++;
> trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
> netfs_trace_tcon_ref_get_cancelled_close);
> - spin_unlock(&cifs_tcp_ses_lock);
> + spin_unlock(&tcon->tc_lock);
>
> rc = __smb2_handle_cancelled_cmd(tcon, SMB2_CLOSE_HE, 0,
> persistent_fid, volatile_fid);
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index c1aaf77e187b6..6f930d6c78adb 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -3091,7 +3091,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
> struct cifs_tcon,
> tcon_list);
> if (tcon) {
> + spin_lock(&tcon->tc_lock);
> tcon->tc_count++;
> + spin_unlock(&tcon->tc_lock);
> trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
> netfs_trace_tcon_ref_get_dfs_refer);
> }
> @@ -3160,13 +3162,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
> out:
> if (tcon && !tcon->ipc) {
> /* ipc tcons are not refcounted */
> - spin_lock(&cifs_tcp_ses_lock);
> - tcon->tc_count--;
> + cifs_put_tcon(tcon);
> trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
> netfs_trace_tcon_ref_dec_dfs_refer);
> - /* tc_count can never go negative */
> - WARN_ON(tcon->tc_count < 0);
> - spin_unlock(&cifs_tcp_ses_lock);
> }
> kfree(utf16_path);
> kfree(dfs_req);
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 5d57c895ca37a..c7e086dfb1765 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -4239,7 +4239,9 @@ void smb2_reconnect_server(struct work_struct *work)
>
> list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
> if (tcon->need_reconnect || tcon->need_reopen_files) {
> + spin_lock(&tcon->tc_lock);
> tcon->tc_count++;
> + spin_unlock(&tcon->tc_lock);
> trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
> netfs_trace_tcon_ref_get_reconnect_server);
> list_add_tail(&tcon->rlist, &tmp_list);
> --
> 2.43.0
>
Please ignore this. I'll send a v2 soon.
--
Regards,
Shyam
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] cifs: Fix locking usage for tcon fields
2026-01-31 8:02 ` [PATCH 2/2] cifs: Fix locking usage for tcon fields nspmangalore
2026-01-31 10:07 ` Shyam Prasad N
@ 2026-01-31 14:58 ` kernel test robot
2026-01-31 15:50 ` kernel test robot
2026-01-31 15:54 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-01-31 14:58 UTC (permalink / raw)
To: nspmangalore, linux-cifs, smfrench, pc, bharathsm
Cc: oe-kbuild-all, Shyam Prasad N, stable
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on cifs/for-next]
[also build test ERROR on linus/master v6.19-rc7 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/nspmangalore-gmail-com/cifs-Fix-locking-usage-for-tcon-fields/20260131-160419
base: git://git.samba.org/sfrench/cifs-2.6.git for-next
patch link: https://lore.kernel.org/r/20260131080239.943483-2-sprasad%40microsoft.com
patch subject: [PATCH 2/2] cifs: Fix locking usage for tcon fields
config: x86_64-randconfig-004-20260131 (https://download.01.org/0day-ci/archive/20260131/202601312208.PzE9vcRG-lkp@intel.com/config)
compiler: gcc-13 (Debian 13.3.0-16) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260131/202601312208.PzE9vcRG-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601312208.PzE9vcRG-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/smb/client/smb2ops.c: In function 'smb2_get_dfs_refer':
>> fs/smb/client/smb2ops.c:3178:17: error: too few arguments to function 'cifs_put_tcon'
3178 | cifs_put_tcon(tcon);
| ^~~~~~~~~~~~~
In file included from fs/smb/client/smb2ops.c:20:
fs/smb/client/cifsproto.h:273:6: note: declared here
273 | void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
| ^~~~~~~~~~~~~
--
fs/smb/client/cached_dir.c: In function 'cfids_laundromat_worker':
>> fs/smb/client/cached_dir.c:795:36: error: 'tcon' undeclared (first use in this function)
795 | spin_lock(&tcon->tc_lock);
| ^~~~
fs/smb/client/cached_dir.c:795:36: note: each undeclared identifier is reported only once for each function it appears in
vim +/cifs_put_tcon +3178 fs/smb/client/smb2ops.c
3078
3079 static int
3080 smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
3081 const char *search_name,
3082 struct dfs_info3_param **target_nodes,
3083 unsigned int *num_of_nodes,
3084 const struct nls_table *nls_codepage, int remap)
3085 {
3086 int rc;
3087 __le16 *utf16_path = NULL;
3088 int utf16_path_len = 0;
3089 struct cifs_tcon *tcon;
3090 struct fsctl_get_dfs_referral_req *dfs_req = NULL;
3091 struct get_dfs_referral_rsp *dfs_rsp = NULL;
3092 u32 dfs_req_size = 0, dfs_rsp_size = 0;
3093 int retry_once = 0;
3094
3095 cifs_dbg(FYI, "%s: path: %s\n", __func__, search_name);
3096
3097 /*
3098 * Try to use the IPC tcon, otherwise just use any
3099 */
3100 tcon = ses->tcon_ipc;
3101 if (tcon == NULL) {
3102 spin_lock(&cifs_tcp_ses_lock);
3103 tcon = list_first_entry_or_null(&ses->tcon_list,
3104 struct cifs_tcon,
3105 tcon_list);
3106 if (tcon) {
3107 spin_lock(&tcon->tc_lock);
3108 tcon->tc_count++;
3109 spin_unlock(&tcon->tc_lock);
3110 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
3111 netfs_trace_tcon_ref_get_dfs_refer);
3112 }
3113 spin_unlock(&cifs_tcp_ses_lock);
3114 }
3115
3116 if (tcon == NULL) {
3117 cifs_dbg(VFS, "session %p has no tcon available for a dfs referral request\n",
3118 ses);
3119 rc = -ENOTCONN;
3120 goto out;
3121 }
3122
3123 utf16_path = cifs_strndup_to_utf16(search_name, PATH_MAX,
3124 &utf16_path_len,
3125 nls_codepage, remap);
3126 if (!utf16_path) {
3127 rc = -ENOMEM;
3128 goto out;
3129 }
3130
3131 dfs_req_size = sizeof(*dfs_req) + utf16_path_len;
3132 dfs_req = kzalloc(dfs_req_size, GFP_KERNEL);
3133 if (!dfs_req) {
3134 rc = -ENOMEM;
3135 goto out;
3136 }
3137
3138 /* Highest DFS referral version understood */
3139 dfs_req->MaxReferralLevel = DFS_VERSION;
3140
3141 /* Path to resolve in an UTF-16 null-terminated string */
3142 memcpy(dfs_req->RequestFileName, utf16_path, utf16_path_len);
3143
3144 for (;;) {
3145 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
3146 FSCTL_DFS_GET_REFERRALS,
3147 (char *)dfs_req, dfs_req_size, CIFSMaxBufSize,
3148 (char **)&dfs_rsp, &dfs_rsp_size);
3149 if (fatal_signal_pending(current)) {
3150 rc = -EINTR;
3151 break;
3152 }
3153 if (!is_retryable_error(rc) || retry_once++)
3154 break;
3155 usleep_range(512, 2048);
3156 }
3157
3158 if (!rc && !dfs_rsp)
3159 rc = smb_EIO(smb_eio_trace_dfsref_no_rsp);
3160 if (rc) {
3161 if (!is_retryable_error(rc) && rc != -ENOENT && rc != -EOPNOTSUPP)
3162 cifs_tcon_dbg(FYI, "%s: ioctl error: rc=%d\n", __func__, rc);
3163 goto out;
3164 }
3165
3166 rc = parse_dfs_referrals(dfs_rsp, dfs_rsp_size,
3167 num_of_nodes, target_nodes,
3168 nls_codepage, remap, search_name,
3169 true /* is_unicode */);
3170 if (rc && rc != -ENOENT) {
3171 cifs_tcon_dbg(VFS, "%s: failed to parse DFS referral %s: %d\n",
3172 __func__, search_name, rc);
3173 }
3174
3175 out:
3176 if (tcon && !tcon->ipc) {
3177 /* ipc tcons are not refcounted */
> 3178 cifs_put_tcon(tcon);
3179 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
3180 netfs_trace_tcon_ref_dec_dfs_refer);
3181 }
3182 kfree(utf16_path);
3183 kfree(dfs_req);
3184 kfree(dfs_rsp);
3185 return rc;
3186 }
3187
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] cifs: Fix locking usage for tcon fields
2026-01-31 8:02 ` [PATCH 2/2] cifs: Fix locking usage for tcon fields nspmangalore
2026-01-31 10:07 ` Shyam Prasad N
2026-01-31 14:58 ` kernel test robot
@ 2026-01-31 15:50 ` kernel test robot
2026-01-31 15:54 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-01-31 15:50 UTC (permalink / raw)
To: nspmangalore, linux-cifs, smfrench, pc, bharathsm
Cc: oe-kbuild-all, Shyam Prasad N, stable
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on cifs/for-next]
[also build test ERROR on linus/master v6.19-rc7 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/nspmangalore-gmail-com/cifs-Fix-locking-usage-for-tcon-fields/20260131-160419
base: git://git.samba.org/sfrench/cifs-2.6.git for-next
patch link: https://lore.kernel.org/r/20260131080239.943483-2-sprasad%40microsoft.com
patch subject: [PATCH 2/2] cifs: Fix locking usage for tcon fields
config: microblaze-defconfig (https://download.01.org/0day-ci/archive/20260131/202601312343.JPu2GSIi-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260131/202601312343.JPu2GSIi-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601312343.JPu2GSIi-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/smb/client/smb2ops.c: In function 'smb2_get_dfs_refer':
>> fs/smb/client/smb2ops.c:3178:17: error: too few arguments to function 'cifs_put_tcon'; expected 2, have 1
3178 | cifs_put_tcon(tcon);
| ^~~~~~~~~~~~~
In file included from fs/smb/client/smb2ops.c:20:
fs/smb/client/cifsproto.h:273:6: note: declared here
273 | void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
| ^~~~~~~~~~~~~
vim +/cifs_put_tcon +3178 fs/smb/client/smb2ops.c
3078
3079 static int
3080 smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
3081 const char *search_name,
3082 struct dfs_info3_param **target_nodes,
3083 unsigned int *num_of_nodes,
3084 const struct nls_table *nls_codepage, int remap)
3085 {
3086 int rc;
3087 __le16 *utf16_path = NULL;
3088 int utf16_path_len = 0;
3089 struct cifs_tcon *tcon;
3090 struct fsctl_get_dfs_referral_req *dfs_req = NULL;
3091 struct get_dfs_referral_rsp *dfs_rsp = NULL;
3092 u32 dfs_req_size = 0, dfs_rsp_size = 0;
3093 int retry_once = 0;
3094
3095 cifs_dbg(FYI, "%s: path: %s\n", __func__, search_name);
3096
3097 /*
3098 * Try to use the IPC tcon, otherwise just use any
3099 */
3100 tcon = ses->tcon_ipc;
3101 if (tcon == NULL) {
3102 spin_lock(&cifs_tcp_ses_lock);
3103 tcon = list_first_entry_or_null(&ses->tcon_list,
3104 struct cifs_tcon,
3105 tcon_list);
3106 if (tcon) {
3107 spin_lock(&tcon->tc_lock);
3108 tcon->tc_count++;
3109 spin_unlock(&tcon->tc_lock);
3110 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
3111 netfs_trace_tcon_ref_get_dfs_refer);
3112 }
3113 spin_unlock(&cifs_tcp_ses_lock);
3114 }
3115
3116 if (tcon == NULL) {
3117 cifs_dbg(VFS, "session %p has no tcon available for a dfs referral request\n",
3118 ses);
3119 rc = -ENOTCONN;
3120 goto out;
3121 }
3122
3123 utf16_path = cifs_strndup_to_utf16(search_name, PATH_MAX,
3124 &utf16_path_len,
3125 nls_codepage, remap);
3126 if (!utf16_path) {
3127 rc = -ENOMEM;
3128 goto out;
3129 }
3130
3131 dfs_req_size = sizeof(*dfs_req) + utf16_path_len;
3132 dfs_req = kzalloc(dfs_req_size, GFP_KERNEL);
3133 if (!dfs_req) {
3134 rc = -ENOMEM;
3135 goto out;
3136 }
3137
3138 /* Highest DFS referral version understood */
3139 dfs_req->MaxReferralLevel = DFS_VERSION;
3140
3141 /* Path to resolve in an UTF-16 null-terminated string */
3142 memcpy(dfs_req->RequestFileName, utf16_path, utf16_path_len);
3143
3144 for (;;) {
3145 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
3146 FSCTL_DFS_GET_REFERRALS,
3147 (char *)dfs_req, dfs_req_size, CIFSMaxBufSize,
3148 (char **)&dfs_rsp, &dfs_rsp_size);
3149 if (fatal_signal_pending(current)) {
3150 rc = -EINTR;
3151 break;
3152 }
3153 if (!is_retryable_error(rc) || retry_once++)
3154 break;
3155 usleep_range(512, 2048);
3156 }
3157
3158 if (!rc && !dfs_rsp)
3159 rc = smb_EIO(smb_eio_trace_dfsref_no_rsp);
3160 if (rc) {
3161 if (!is_retryable_error(rc) && rc != -ENOENT && rc != -EOPNOTSUPP)
3162 cifs_tcon_dbg(FYI, "%s: ioctl error: rc=%d\n", __func__, rc);
3163 goto out;
3164 }
3165
3166 rc = parse_dfs_referrals(dfs_rsp, dfs_rsp_size,
3167 num_of_nodes, target_nodes,
3168 nls_codepage, remap, search_name,
3169 true /* is_unicode */);
3170 if (rc && rc != -ENOENT) {
3171 cifs_tcon_dbg(VFS, "%s: failed to parse DFS referral %s: %d\n",
3172 __func__, search_name, rc);
3173 }
3174
3175 out:
3176 if (tcon && !tcon->ipc) {
3177 /* ipc tcons are not refcounted */
> 3178 cifs_put_tcon(tcon);
3179 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
3180 netfs_trace_tcon_ref_dec_dfs_refer);
3181 }
3182 kfree(utf16_path);
3183 kfree(dfs_req);
3184 kfree(dfs_rsp);
3185 return rc;
3186 }
3187
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] cifs: Fix locking usage for tcon fields
2026-01-31 8:02 ` [PATCH 2/2] cifs: Fix locking usage for tcon fields nspmangalore
` (2 preceding siblings ...)
2026-01-31 15:50 ` kernel test robot
@ 2026-01-31 15:54 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-01-31 15:54 UTC (permalink / raw)
To: nspmangalore, linux-cifs, smfrench, pc, bharathsm
Cc: oe-kbuild-all, Shyam Prasad N, stable
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on cifs/for-next]
[also build test ERROR on linus/master v6.19-rc7 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/nspmangalore-gmail-com/cifs-Fix-locking-usage-for-tcon-fields/20260131-160419
base: git://git.samba.org/sfrench/cifs-2.6.git for-next
patch link: https://lore.kernel.org/r/20260131080239.943483-2-sprasad%40microsoft.com
patch subject: [PATCH 2/2] cifs: Fix locking usage for tcon fields
config: s390-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260131/202601311634.9WVpg186-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260131/202601311634.9WVpg186-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601311634.9WVpg186-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/smb/client/smb2ops.c: In function 'smb2_get_dfs_refer':
>> fs/smb/client/smb2ops.c:3178:17: error: too few arguments to function 'cifs_put_tcon'; expected 2, have 1
3178 | cifs_put_tcon(tcon);
| ^~~~~~~~~~~~~
In file included from fs/smb/client/smb2ops.c:20:
fs/smb/client/cifsproto.h:273:6: note: declared here
273 | void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
| ^~~~~~~~~~~~~
vim +/cifs_put_tcon +3178 fs/smb/client/smb2ops.c
3078
3079 static int
3080 smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
3081 const char *search_name,
3082 struct dfs_info3_param **target_nodes,
3083 unsigned int *num_of_nodes,
3084 const struct nls_table *nls_codepage, int remap)
3085 {
3086 int rc;
3087 __le16 *utf16_path = NULL;
3088 int utf16_path_len = 0;
3089 struct cifs_tcon *tcon;
3090 struct fsctl_get_dfs_referral_req *dfs_req = NULL;
3091 struct get_dfs_referral_rsp *dfs_rsp = NULL;
3092 u32 dfs_req_size = 0, dfs_rsp_size = 0;
3093 int retry_once = 0;
3094
3095 cifs_dbg(FYI, "%s: path: %s\n", __func__, search_name);
3096
3097 /*
3098 * Try to use the IPC tcon, otherwise just use any
3099 */
3100 tcon = ses->tcon_ipc;
3101 if (tcon == NULL) {
3102 spin_lock(&cifs_tcp_ses_lock);
3103 tcon = list_first_entry_or_null(&ses->tcon_list,
3104 struct cifs_tcon,
3105 tcon_list);
3106 if (tcon) {
3107 spin_lock(&tcon->tc_lock);
3108 tcon->tc_count++;
3109 spin_unlock(&tcon->tc_lock);
3110 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
3111 netfs_trace_tcon_ref_get_dfs_refer);
3112 }
3113 spin_unlock(&cifs_tcp_ses_lock);
3114 }
3115
3116 if (tcon == NULL) {
3117 cifs_dbg(VFS, "session %p has no tcon available for a dfs referral request\n",
3118 ses);
3119 rc = -ENOTCONN;
3120 goto out;
3121 }
3122
3123 utf16_path = cifs_strndup_to_utf16(search_name, PATH_MAX,
3124 &utf16_path_len,
3125 nls_codepage, remap);
3126 if (!utf16_path) {
3127 rc = -ENOMEM;
3128 goto out;
3129 }
3130
3131 dfs_req_size = sizeof(*dfs_req) + utf16_path_len;
3132 dfs_req = kzalloc(dfs_req_size, GFP_KERNEL);
3133 if (!dfs_req) {
3134 rc = -ENOMEM;
3135 goto out;
3136 }
3137
3138 /* Highest DFS referral version understood */
3139 dfs_req->MaxReferralLevel = DFS_VERSION;
3140
3141 /* Path to resolve in an UTF-16 null-terminated string */
3142 memcpy(dfs_req->RequestFileName, utf16_path, utf16_path_len);
3143
3144 for (;;) {
3145 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
3146 FSCTL_DFS_GET_REFERRALS,
3147 (char *)dfs_req, dfs_req_size, CIFSMaxBufSize,
3148 (char **)&dfs_rsp, &dfs_rsp_size);
3149 if (fatal_signal_pending(current)) {
3150 rc = -EINTR;
3151 break;
3152 }
3153 if (!is_retryable_error(rc) || retry_once++)
3154 break;
3155 usleep_range(512, 2048);
3156 }
3157
3158 if (!rc && !dfs_rsp)
3159 rc = smb_EIO(smb_eio_trace_dfsref_no_rsp);
3160 if (rc) {
3161 if (!is_retryable_error(rc) && rc != -ENOENT && rc != -EOPNOTSUPP)
3162 cifs_tcon_dbg(FYI, "%s: ioctl error: rc=%d\n", __func__, rc);
3163 goto out;
3164 }
3165
3166 rc = parse_dfs_referrals(dfs_rsp, dfs_rsp_size,
3167 num_of_nodes, target_nodes,
3168 nls_codepage, remap, search_name,
3169 true /* is_unicode */);
3170 if (rc && rc != -ENOENT) {
3171 cifs_tcon_dbg(VFS, "%s: failed to parse DFS referral %s: %d\n",
3172 __func__, search_name, rc);
3173 }
3174
3175 out:
3176 if (tcon && !tcon->ipc) {
3177 /* ipc tcons are not refcounted */
> 3178 cifs_put_tcon(tcon);
3179 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
3180 netfs_trace_tcon_ref_dec_dfs_refer);
3181 }
3182 kfree(utf16_path);
3183 kfree(dfs_req);
3184 kfree(dfs_rsp);
3185 return rc;
3186 }
3187
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-31 15:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 8:02 [PATCH 1/2] cifs: Corrections to lock ordering notes nspmangalore
2026-01-31 8:02 ` [PATCH 2/2] cifs: Fix locking usage for tcon fields nspmangalore
2026-01-31 10:07 ` Shyam Prasad N
2026-01-31 14:58 ` kernel test robot
2026-01-31 15:50 ` kernel test robot
2026-01-31 15:54 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox