diff mbox series

[for-6.11,14/29] NFS: Add tracepoints for nfs_local_enable and nfs_local_disable

Message ID 20240607142646.20924-15-snitzer@kernel.org (mailing list archive)
State New
Headers show
Series nfs/nfsd: add support for localio bypass | expand

Commit Message

Mike Snitzer June 7, 2024, 2:26 p.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

Allow tracing of when local I/O begins and ends.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
 fs/nfs/localio.c  |  5 ++---
 fs/nfs/nfstrace.h | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index 5c69eb0fe7b6..5939ca2216be 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -195,7 +195,6 @@  nfs_local_put_lookup_ctx(void)
 		spin_unlock(&ctx->lock);
 		if (fn)
 			symbol_put(nfsd_open_local_fh);
-		dprintk("destroy lookup context\n");
 	}
 }
 
@@ -206,8 +205,8 @@  void
 nfs_local_enable(struct nfs_client *clp)
 {
 	if (nfs_local_get_lookup_ctx()) {
-		dprintk("enabled local i/o\n");
 		set_bit(NFS_CS_LOCAL_IO, &clp->cl_flags);
+		trace_nfs_local_enable(clp);
 	}
 }
 EXPORT_SYMBOL_GPL(nfs_local_enable);
@@ -219,7 +218,7 @@  void
 nfs_local_disable(struct nfs_client *clp)
 {
 	if (test_and_clear_bit(NFS_CS_LOCAL_IO, &clp->cl_flags)) {
-		dprintk("disabled local i/o\n");
+		trace_nfs_local_disable(clp);
 		nfs_local_put_lookup_ctx();
 	}
 }
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 45d4086cdeb1..95a2c19a9172 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -1710,6 +1710,38 @@  TRACE_EVENT(nfs_local_open_fh,
 		)
 );
 
+DECLARE_EVENT_CLASS(nfs_local_client_event,
+		TP_PROTO(
+			const struct nfs_client *clp
+		),
+
+		TP_ARGS(clp),
+
+		TP_STRUCT__entry(
+			__field(unsigned int, protocol)
+			__string(server, clp->cl_hostname)
+		),
+
+		TP_fast_assign(
+			__entry->protocol = clp->rpc_ops->version;
+			__assign_str(server);
+		),
+
+		TP_printk(
+			"server=%s NFSv%u", __get_str(server), __entry->protocol
+		)
+);
+
+#define DEFINE_NFS_LOCAL_CLIENT_EVENT(name) \
+	DEFINE_EVENT(nfs_local_client_event, name, \
+			TP_PROTO( \
+				const struct nfs_client *clp \
+			), \
+			TP_ARGS(clp))
+
+DEFINE_NFS_LOCAL_CLIENT_EVENT(nfs_local_enable);
+DEFINE_NFS_LOCAL_CLIENT_EVENT(nfs_local_disable);
+
 DECLARE_EVENT_CLASS(nfs_xdr_event,
 		TP_PROTO(
 			const struct xdr_stream *xdr,