]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: client: add tracepoint for local lock conflicts
authorBharath SM <bharathsm@microsoft.com>
Tue, 14 Apr 2026 16:18:03 +0000 (21:48 +0530)
committerSteve French <stfrench@microsoft.com>
Tue, 14 Apr 2026 18:04:21 +0000 (13:04 -0500)
Add smb3_lock_conflict tracepoint that fires when a byte-range
lock request conflicts with an existing cached lock. This helps
debug lock contention issues when locks are cached locally due
to oplocks/leases.

The trace includes both the requested and conflicting lock details:
- Requested: offset, length, type
- Conflicting: offset, length, type, pid (lock holder)

Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/file.c
fs/smb/client/trace.h

index 66a678a0e89f48ca92465a06badd76d76b60f4f0..4662592801b06d921e72a411c5789e75087de083 100644 (file)
@@ -1631,6 +1631,9 @@ cifs_find_fid_lock_conflict(struct cifs_fid_locks *fdlocks, __u64 offset,
                        continue;
                if (conf_lock)
                        *conf_lock = li;
+               trace_smb3_lock_conflict(cfile->fid.persistent_fid,
+                                        offset, length, type,
+                                        li->offset, li->length, li->type, li->pid);
                return true;
        }
        return false;
index 242c9da0283ea94c682b5c0586d22c172e36866f..cb5ce1316eba6bef15dc78512f507f0db92d557e 100644 (file)
@@ -729,6 +729,41 @@ DEFINE_SMB3_LOCK_EVENT(lock_done);
 DEFINE_SMB3_LOCK_EVENT(lock_err);
 DEFINE_SMB3_LOCK_EVENT(lock_cached);
 
+TRACE_EVENT(smb3_lock_conflict,
+       TP_PROTO(__u64 fid,
+               __u64 req_offset,
+               __u64 req_len,
+               __u8 req_type,
+               __u64 conf_offset,
+               __u64 conf_len,
+               __u16 conf_type,
+               __u32 conf_pid),
+       TP_ARGS(fid, req_offset, req_len, req_type, conf_offset, conf_len, conf_type, conf_pid),
+       TP_STRUCT__entry(
+               __field(__u64, fid)
+               __field(__u64, req_offset)
+               __field(__u64, req_len)
+               __field(__u8, req_type)
+               __field(__u64, conf_offset)
+               __field(__u64, conf_len)
+               __field(__u16, conf_type)
+               __field(__u32, conf_pid)
+       ),
+       TP_fast_assign(
+               __entry->fid = fid;
+               __entry->req_offset = req_offset;
+               __entry->req_len = req_len;
+               __entry->req_type = req_type;
+               __entry->conf_offset = conf_offset;
+               __entry->conf_len = conf_len;
+               __entry->conf_type = conf_type;
+               __entry->conf_pid = conf_pid;
+       ),
+       TP_printk("fid=0x%llx req=[0x%llx:0x%llx] type=0x%x conflicts with [0x%llx:0x%llx] type=0x%x pid=%u",
+               __entry->fid, __entry->req_offset, __entry->req_len, __entry->req_type,
+               __entry->conf_offset, __entry->conf_len, __entry->conf_type, __entry->conf_pid)
+);
+
 /*
  * For handle based query/set info calls
  */