From: Bharath SM <bharathsm.hsk@gmail.com>
To: linux-cifs@vger.kernel.org, smfrench@gmail.com,
sprasad@microsoft.com, pc@manguebit.com, ematsumiya@suse.de,
henrique.carvalho@suse.com, bharathsm@microsoft.com
Subject: [PATCH 4/4] smb: client: add tracepoints for deferred handle caching
Date: Tue, 14 Apr 2026 21:48:05 +0530 [thread overview]
Message-ID: <20260414161805.233686-4-bharathsm@microsoft.com> (raw)
In-Reply-To: <20260414161805.233686-1-bharathsm@microsoft.com>
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
next prev parent reply other threads:[~2026-04-14 16:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-04-14 23:10 ` [PATCH 1/4] smb: client: add tracepoints for lock operations Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260414161805.233686-4-bharathsm@microsoft.com \
--to=bharathsm.hsk@gmail.com \
--cc=bharathsm@microsoft.com \
--cc=ematsumiya@suse.de \
--cc=henrique.carvalho@suse.com \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox