* [PATCH 1/4] smb: client: add tracepoints for lock operations
@ 2026-04-14 16:18 Bharath SM
2026-04-14 16:18 ` [PATCH 2/4] smb: client: add tracepoint for local lock conflicts Bharath SM
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Bharath SM @ 2026-04-14 16:18 UTC (permalink / raw)
To: linux-cifs, smfrench, sprasad, pc, ematsumiya, henrique.carvalho,
bharathsm
Add tracepoints when lock operations are sent to the
server with details including lock offset, length, and flags.
smb3_lock_enter: before sending lock request
smb3_lock_done: lock acquired successfully
smb3_lock_err: lock request failed
smb3_lock_cached: lock granted from local cache (no server roundtrip)
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
---
fs/smb/client/file.c | 10 +++++--
fs/smb/client/smb2pdu.c | 15 ++++++++++-
fs/smb/client/trace.h | 58 ++++++++++++++++++++++++++++++++++++++++-
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 5d5b49468aff..66a678a0e89f 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1712,7 +1712,7 @@ cifs_lock_add(struct cifsFileInfo *cfile, struct cifsLockInfo *lock)
*/
static int
cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock,
- bool wait)
+ bool wait, unsigned int xid)
{
struct cifsLockInfo *conf_lock;
struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
@@ -1727,7 +1727,13 @@ cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock,
lock->type, lock->flags, &conf_lock,
CIFS_LOCK_OP);
if (!exist && cinode->can_cache_brlcks) {
+ struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
+
list_add_tail(&lock->llist, &cfile->llist->locks);
+ trace_smb3_lock_cached(xid, cfile->fid.persistent_fid,
+ tcon->tid, tcon->ses->Suid,
+ lock->offset, lock->length,
+ lock->type, 1, 0);
up_write(&cinode->lock_sem);
return rc;
}
@@ -2342,7 +2348,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
if (!lock)
return -ENOMEM;
- rc = cifs_lock_add_if(cfile, lock, wait_flag);
+ rc = cifs_lock_add_if(cfile, lock, wait_flag, xid);
if (rc < 0) {
kfree(lock);
return rc;
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 5188218c25be..61bae531959a 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -6277,6 +6277,11 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
smb2_set_replay(server, &rqst);
}
+ trace_smb3_lock_enter(xid, persist_fid, tcon->tid, tcon->ses->Suid,
+ le64_to_cpu(buf[0].Offset),
+ le64_to_cpu(buf[0].Length),
+ le32_to_cpu(buf[0].Flags), num_lock, 0);
+
rc = cifs_send_recv(xid, tcon->ses, server,
&rqst, &resp_buf_type, flags,
&rsp_iov);
@@ -6285,7 +6290,15 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
cifs_dbg(FYI, "Send error in smb2_lockv = %d\n", rc);
cifs_stats_fail_inc(tcon, SMB2_LOCK_HE);
trace_smb3_lock_err(xid, persist_fid, tcon->tid,
- tcon->ses->Suid, rc);
+ tcon->ses->Suid,
+ le64_to_cpu(buf[0].Offset),
+ le64_to_cpu(buf[0].Length),
+ le32_to_cpu(buf[0].Flags), num_lock, rc);
+ } else {
+ trace_smb3_lock_done(xid, persist_fid, tcon->tid, tcon->ses->Suid,
+ le64_to_cpu(buf[0].Offset),
+ le64_to_cpu(buf[0].Length),
+ le32_to_cpu(buf[0].Flags), num_lock, 0);
}
if (is_replayable_error(rc) &&
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index acfbb63086ea..242c9da0283e 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -670,9 +670,65 @@ DEFINE_EVENT(smb3_fd_err_class, smb3_##name, \
TP_ARGS(xid, fid, tid, sesid, rc))
DEFINE_SMB3_FD_ERR_EVENT(flush_err);
-DEFINE_SMB3_FD_ERR_EVENT(lock_err);
DEFINE_SMB3_FD_ERR_EVENT(close_err);
+DECLARE_EVENT_CLASS(smb3_lock_class,
+ TP_PROTO(unsigned int xid,
+ __u64 fid,
+ __u32 tid,
+ __u64 sesid,
+ __u64 offset,
+ __u64 len,
+ __u32 flags,
+ __u32 num_lock,
+ int rc),
+ TP_ARGS(xid, fid, tid, sesid, offset, len, flags, num_lock, rc),
+ TP_STRUCT__entry(
+ __field(unsigned int, xid)
+ __field(__u64, fid)
+ __field(__u32, tid)
+ __field(__u64, sesid)
+ __field(__u64, offset)
+ __field(__u64, len)
+ __field(__u32, flags)
+ __field(__u32, num_lock)
+ __field(int, rc)
+ ),
+ TP_fast_assign(
+ __entry->xid = xid;
+ __entry->fid = fid;
+ __entry->tid = tid;
+ __entry->sesid = sesid;
+ __entry->offset = offset;
+ __entry->len = len;
+ __entry->flags = flags;
+ __entry->num_lock = num_lock;
+ __entry->rc = rc;
+ ),
+ TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%llx flags=0x%x num_lock=%u rc=%d",
+ __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
+ __entry->offset, __entry->len, __entry->flags, __entry->num_lock,
+ __entry->rc)
+)
+
+#define DEFINE_SMB3_LOCK_EVENT(name) \
+DEFINE_EVENT(smb3_lock_class, smb3_##name, \
+ TP_PROTO(unsigned int xid, \
+ __u64 fid, \
+ __u32 tid, \
+ __u64 sesid, \
+ __u64 offset, \
+ __u64 len, \
+ __u32 flags, \
+ __u32 num_lock, \
+ int rc), \
+ TP_ARGS(xid, fid, tid, sesid, offset, len, flags, num_lock, rc))
+
+DEFINE_SMB3_LOCK_EVENT(lock_enter);
+DEFINE_SMB3_LOCK_EVENT(lock_done);
+DEFINE_SMB3_LOCK_EVENT(lock_err);
+DEFINE_SMB3_LOCK_EVENT(lock_cached);
+
/*
* For handle based query/set info calls
*/
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] smb: client: add tracepoint for local lock conflicts
2026-04-14 16:18 [PATCH 1/4] smb: client: add tracepoints for lock operations Bharath SM
@ 2026-04-14 16:18 ` Bharath SM
2026-04-14 16:18 ` [PATCH 3/4] smb: client: add oplock level to smb3_open_done tracepoint Bharath SM
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Bharath SM @ 2026-04-14 16:18 UTC (permalink / raw)
To: linux-cifs, smfrench, sprasad, pc, ematsumiya, henrique.carvalho,
bharathsm
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>
---
fs/smb/client/file.c | 3 +++
fs/smb/client/trace.h | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 66a678a0e89f..4662592801b0 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -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;
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index 242c9da0283e..cb5ce1316eba 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -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
*/
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] smb: client: add oplock level to smb3_open_done tracepoint
2026-04-14 16:18 [PATCH 1/4] smb: client: add tracepoints for lock operations Bharath SM
2026-04-14 16:18 ` [PATCH 2/4] smb: client: add tracepoint for local lock conflicts Bharath SM
@ 2026-04-14 16:18 ` Bharath SM
2026-04-14 16:18 ` [PATCH 4/4] smb: client: add tracepoints for deferred handle caching Bharath SM
2026-04-14 23:10 ` [PATCH 1/4] smb: client: add tracepoints for lock operations Steve French
3 siblings, 0 replies; 5+ messages in thread
From: Bharath SM @ 2026-04-14 16:18 UTC (permalink / raw)
To: linux-cifs, smfrench, sprasad, pc, ematsumiya, henrique.carvalho,
bharathsm
Add an oplock field to the smb3_open_done_class trace event to
show the granted oplock/lease level. Move the trace_smb3_open_done
call after smb2_parse_contexts() so the oplock value reflects
the parsed lease state (R/W/H flags).
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
---
fs/smb/client/smb2pdu.c | 10 ++++++----
fs/smb/client/trace.h | 16 ++++++++++------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 61bae531959a..96140f6d30b5 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -3044,7 +3044,8 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
}
trace_smb3_posix_mkdir_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
- CREATE_NOT_FILE, FILE_WRITE_ATTRIBUTES);
+ CREATE_NOT_FILE, FILE_WRITE_ATTRIBUTES,
+ rsp->OplockLevel);
SMB2_close(xid, tcon, rsp->PersistentFileId, rsp->VolatileFileId);
@@ -3321,9 +3322,6 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
goto creat_exit;
} else if (rsp == NULL) /* unlikely to happen, but safer to check */
goto creat_exit;
- else
- trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
- oparms->create_options, oparms->desired_access);
atomic_inc(&tcon->num_remote_opens);
oparms->fid->persistent_fid = rsp->PersistentFileId;
@@ -3348,6 +3346,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
rc = smb2_parse_contexts(server, &rsp_iov, &oparms->fid->epoch,
oparms->fid->lease_key, oplock, buf, posix);
+
+ trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
+ oparms->create_options, oparms->desired_access,
+ *oplock);
creat_exit:
SMB2_open_free(&rqst);
free_rsp_buf(resp_buftype, rsp);
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index cb5ce1316eba..57abf5fca26c 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -1321,8 +1321,9 @@ DECLARE_EVENT_CLASS(smb3_open_done_class,
__u32 tid,
__u64 sesid,
int create_options,
- int desired_access),
- TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
+ int desired_access,
+ __u8 oplock),
+ TP_ARGS(xid, fid, tid, sesid, create_options, desired_access, oplock),
TP_STRUCT__entry(
__field(unsigned int, xid)
__field(__u64, fid)
@@ -1330,6 +1331,7 @@ DECLARE_EVENT_CLASS(smb3_open_done_class,
__field(__u64, sesid)
__field(int, create_options)
__field(int, desired_access)
+ __field(__u8, oplock)
),
TP_fast_assign(
__entry->xid = xid;
@@ -1338,10 +1340,11 @@ DECLARE_EVENT_CLASS(smb3_open_done_class,
__entry->sesid = sesid;
__entry->create_options = create_options;
__entry->desired_access = desired_access;
+ __entry->oplock = oplock;
),
- TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
+ TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x oplock=0x%x",
__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
- __entry->create_options, __entry->desired_access)
+ __entry->create_options, __entry->desired_access, __entry->oplock)
)
#define DEFINE_SMB3_OPEN_DONE_EVENT(name) \
@@ -1351,8 +1354,9 @@ DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
__u32 tid, \
__u64 sesid, \
int create_options, \
- int desired_access), \
- TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
+ int desired_access, \
+ __u8 oplock), \
+ TP_ARGS(xid, fid, tid, sesid, create_options, desired_access, oplock))
DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] smb: client: add tracepoints for deferred handle caching
2026-04-14 16:18 [PATCH 1/4] smb: client: add tracepoints for lock operations Bharath SM
2026-04-14 16:18 ` [PATCH 2/4] smb: client: add tracepoint for local lock conflicts Bharath SM
2026-04-14 16:18 ` [PATCH 3/4] smb: client: add oplock level to smb3_open_done tracepoint Bharath SM
@ 2026-04-14 16:18 ` Bharath SM
2026-04-14 23:10 ` [PATCH 1/4] smb: client: add tracepoints for lock operations Steve French
3 siblings, 0 replies; 5+ messages in thread
From: Bharath SM @ 2026-04-14 16:18 UTC (permalink / raw)
To: linux-cifs, smfrench, sprasad, pc, ematsumiya, henrique.carvalho,
bharathsm
Add tracepoints to observe handle caching behavior.
smb3_open_cached: emitted when an open reuses a cached handle from
a previous deferred close, avoiding a network round-trip
smb3_close_cached: emitted when a close is deferred (handle cached
for potential reuse by subsequent opens)
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
---
fs/smb/client/file.c | 8 +++++++
fs/smb/client/trace.h | 51 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 4662592801b0..79819241ebfd 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1083,6 +1083,9 @@ int cifs_open(struct inode *inode, struct file *file)
rc = cfile ? 0 : -ENOENT;
}
if (rc == 0) {
+ trace_smb3_open_cached(xid, tcon->tid, tcon->ses->Suid,
+ cfile->fid.persistent_fid,
+ file->f_flags, cfile->f_flags);
file->private_data = cfile;
spin_lock(&CIFS_I(inode)->deferred_lock);
cifs_del_deferred_close(cfile);
@@ -1442,6 +1445,7 @@ int cifs_close(struct inode *inode, struct file *file)
struct cifsInodeInfo *cinode = CIFS_I(inode);
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct cifs_deferred_close *dclose;
+ struct cifs_tcon *tcon;
cifs_fscache_unuse_inode_cookie(inode, file->f_mode & FMODE_WRITE);
@@ -1468,6 +1472,10 @@ int cifs_close(struct inode *inode, struct file *file)
cifsFileInfo_get(cfile);
} else {
/* Deferred close for files */
+ tcon = tlink_tcon(cfile->tlink);
+ trace_smb3_close_cached(tcon->tid, tcon->ses->Suid,
+ cfile->fid.persistent_fid,
+ cifs_sb->ctx->closetimeo);
queue_delayed_work(deferredclose_wq,
&cfile->deferred, cifs_sb->ctx->closetimeo);
cfile->deferred_close_scheduled = true;
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index 57abf5fca26c..b99ec5a417fa 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -1361,6 +1361,57 @@ DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
+TRACE_EVENT(smb3_open_cached,
+ TP_PROTO(unsigned int xid,
+ __u32 tid,
+ __u64 sesid,
+ __u64 fid,
+ unsigned int oflags,
+ unsigned int cflags),
+ TP_ARGS(xid, tid, sesid, fid, oflags, cflags),
+ TP_STRUCT__entry(
+ __field(unsigned int, xid)
+ __field(__u32, tid)
+ __field(__u64, sesid)
+ __field(__u64, fid)
+ __field(unsigned int, oflags)
+ __field(unsigned int, cflags)
+ ),
+ TP_fast_assign(
+ __entry->xid = xid;
+ __entry->tid = tid;
+ __entry->sesid = sesid;
+ __entry->fid = fid;
+ __entry->oflags = oflags;
+ __entry->cflags = cflags;
+ ),
+ TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx oflags=0x%x cflags=0x%x",
+ __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
+ __entry->oflags, __entry->cflags)
+);
+
+TRACE_EVENT(smb3_close_cached,
+ TP_PROTO(__u32 tid,
+ __u64 sesid,
+ __u64 fid,
+ unsigned long delay_jiffies),
+ TP_ARGS(tid, sesid, fid, delay_jiffies),
+ TP_STRUCT__entry(
+ __field(__u32, tid)
+ __field(__u64, sesid)
+ __field(__u64, fid)
+ __field(unsigned long, delay_jiffies)
+ ),
+ TP_fast_assign(
+ __entry->tid = tid;
+ __entry->sesid = sesid;
+ __entry->fid = fid;
+ __entry->delay_jiffies = delay_jiffies;
+ ),
+ TP_printk("sid=0x%llx tid=0x%x fid=0x%llx delay_jiffies=%lu",
+ __entry->sesid, __entry->tid, __entry->fid, __entry->delay_jiffies)
+);
+
DECLARE_EVENT_CLASS(smb3_lease_done_class,
TP_PROTO(__u32 lease_state,
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/4] smb: client: add tracepoints for lock operations
2026-04-14 16:18 [PATCH 1/4] smb: client: add tracepoints for lock operations Bharath SM
` (2 preceding siblings ...)
2026-04-14 16:18 ` [PATCH 4/4] smb: client: add tracepoints for deferred handle caching Bharath SM
@ 2026-04-14 23:10 ` Steve French
3 siblings, 0 replies; 5+ messages in thread
From: Steve French @ 2026-04-14 23:10 UTC (permalink / raw)
To: Bharath SM
Cc: linux-cifs, sprasad, pc, ematsumiya, henrique.carvalho, bharathsm
merged into cifs-2.6.git for-next
On Tue, Apr 14, 2026 at 11:18 AM Bharath SM <bharathsm.hsk@gmail.com> wrote:
>
> Add tracepoints when lock operations are sent to the
> server with details including lock offset, length, and flags.
>
> smb3_lock_enter: before sending lock request
> smb3_lock_done: lock acquired successfully
> smb3_lock_err: lock request failed
> smb3_lock_cached: lock granted from local cache (no server roundtrip)
>
> Signed-off-by: Bharath SM <bharathsm@microsoft.com>
> ---
> fs/smb/client/file.c | 10 +++++--
> fs/smb/client/smb2pdu.c | 15 ++++++++++-
> fs/smb/client/trace.h | 58 ++++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 79 insertions(+), 4 deletions(-)
>
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 5d5b49468aff..66a678a0e89f 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -1712,7 +1712,7 @@ cifs_lock_add(struct cifsFileInfo *cfile, struct cifsLockInfo *lock)
> */
> static int
> cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock,
> - bool wait)
> + bool wait, unsigned int xid)
> {
> struct cifsLockInfo *conf_lock;
> struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
> @@ -1727,7 +1727,13 @@ cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock,
> lock->type, lock->flags, &conf_lock,
> CIFS_LOCK_OP);
> if (!exist && cinode->can_cache_brlcks) {
> + struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
> +
> list_add_tail(&lock->llist, &cfile->llist->locks);
> + trace_smb3_lock_cached(xid, cfile->fid.persistent_fid,
> + tcon->tid, tcon->ses->Suid,
> + lock->offset, lock->length,
> + lock->type, 1, 0);
> up_write(&cinode->lock_sem);
> return rc;
> }
> @@ -2342,7 +2348,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
> if (!lock)
> return -ENOMEM;
>
> - rc = cifs_lock_add_if(cfile, lock, wait_flag);
> + rc = cifs_lock_add_if(cfile, lock, wait_flag, xid);
> if (rc < 0) {
> kfree(lock);
> return rc;
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 5188218c25be..61bae531959a 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -6277,6 +6277,11 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
> smb2_set_replay(server, &rqst);
> }
>
> + trace_smb3_lock_enter(xid, persist_fid, tcon->tid, tcon->ses->Suid,
> + le64_to_cpu(buf[0].Offset),
> + le64_to_cpu(buf[0].Length),
> + le32_to_cpu(buf[0].Flags), num_lock, 0);
> +
> rc = cifs_send_recv(xid, tcon->ses, server,
> &rqst, &resp_buf_type, flags,
> &rsp_iov);
> @@ -6285,7 +6290,15 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
> cifs_dbg(FYI, "Send error in smb2_lockv = %d\n", rc);
> cifs_stats_fail_inc(tcon, SMB2_LOCK_HE);
> trace_smb3_lock_err(xid, persist_fid, tcon->tid,
> - tcon->ses->Suid, rc);
> + tcon->ses->Suid,
> + le64_to_cpu(buf[0].Offset),
> + le64_to_cpu(buf[0].Length),
> + le32_to_cpu(buf[0].Flags), num_lock, rc);
> + } else {
> + trace_smb3_lock_done(xid, persist_fid, tcon->tid, tcon->ses->Suid,
> + le64_to_cpu(buf[0].Offset),
> + le64_to_cpu(buf[0].Length),
> + le32_to_cpu(buf[0].Flags), num_lock, 0);
> }
>
> if (is_replayable_error(rc) &&
> diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
> index acfbb63086ea..242c9da0283e 100644
> --- a/fs/smb/client/trace.h
> +++ b/fs/smb/client/trace.h
> @@ -670,9 +670,65 @@ DEFINE_EVENT(smb3_fd_err_class, smb3_##name, \
> TP_ARGS(xid, fid, tid, sesid, rc))
>
> DEFINE_SMB3_FD_ERR_EVENT(flush_err);
> -DEFINE_SMB3_FD_ERR_EVENT(lock_err);
> DEFINE_SMB3_FD_ERR_EVENT(close_err);
>
> +DECLARE_EVENT_CLASS(smb3_lock_class,
> + TP_PROTO(unsigned int xid,
> + __u64 fid,
> + __u32 tid,
> + __u64 sesid,
> + __u64 offset,
> + __u64 len,
> + __u32 flags,
> + __u32 num_lock,
> + int rc),
> + TP_ARGS(xid, fid, tid, sesid, offset, len, flags, num_lock, rc),
> + TP_STRUCT__entry(
> + __field(unsigned int, xid)
> + __field(__u64, fid)
> + __field(__u32, tid)
> + __field(__u64, sesid)
> + __field(__u64, offset)
> + __field(__u64, len)
> + __field(__u32, flags)
> + __field(__u32, num_lock)
> + __field(int, rc)
> + ),
> + TP_fast_assign(
> + __entry->xid = xid;
> + __entry->fid = fid;
> + __entry->tid = tid;
> + __entry->sesid = sesid;
> + __entry->offset = offset;
> + __entry->len = len;
> + __entry->flags = flags;
> + __entry->num_lock = num_lock;
> + __entry->rc = rc;
> + ),
> + TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%llx flags=0x%x num_lock=%u rc=%d",
> + __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
> + __entry->offset, __entry->len, __entry->flags, __entry->num_lock,
> + __entry->rc)
> +)
> +
> +#define DEFINE_SMB3_LOCK_EVENT(name) \
> +DEFINE_EVENT(smb3_lock_class, smb3_##name, \
> + TP_PROTO(unsigned int xid, \
> + __u64 fid, \
> + __u32 tid, \
> + __u64 sesid, \
> + __u64 offset, \
> + __u64 len, \
> + __u32 flags, \
> + __u32 num_lock, \
> + int rc), \
> + TP_ARGS(xid, fid, tid, sesid, offset, len, flags, num_lock, rc))
> +
> +DEFINE_SMB3_LOCK_EVENT(lock_enter);
> +DEFINE_SMB3_LOCK_EVENT(lock_done);
> +DEFINE_SMB3_LOCK_EVENT(lock_err);
> +DEFINE_SMB3_LOCK_EVENT(lock_cached);
> +
> /*
> * For handle based query/set info calls
> */
> --
> 2.48.1
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-14 23:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 16:18 [PATCH 1/4] smb: client: add tracepoints for lock operations Bharath SM
2026-04-14 16:18 ` [PATCH 2/4] smb: client: add tracepoint for local lock conflicts Bharath SM
2026-04-14 16:18 ` [PATCH 3/4] smb: client: add oplock level to smb3_open_done tracepoint Bharath SM
2026-04-14 16:18 ` [PATCH 4/4] smb: client: add tracepoints for deferred handle caching Bharath SM
2026-04-14 23:10 ` [PATCH 1/4] smb: client: add tracepoints for lock operations Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox