diff mbox series

[v3] NFSv4: add tracepoint to referral events

Message ID 20240710103854.1387-1-chenhx.fnst@fujitsu.com (mailing list archive)
State New
Headers show
Series [v3] NFSv4: add tracepoint to referral events | expand

Commit Message

Chen Hanxiao July 10, 2024, 10:38 a.m. UTC
Trace new locations when hitting a referral:

  nfs4_referral_location: referral_host=192.168.122.210 referral_path=/share12

Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
---
v3:
    fit one parameter style of __assign_str

 fs/nfs/nfs4namespace.c |  3 +++
 fs/nfs/nfs4trace.h     | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 9a98595bb160..fca9fb801bc2 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -24,6 +24,7 @@ 
 #include "nfs4_fs.h"
 #include "nfs.h"
 #include "dns_resolve.h"
+#include "nfs4trace.h"
 
 #define NFSDBG_FACILITY		NFSDBG_VFS
 
@@ -351,6 +352,8 @@  static int try_location(struct fs_context *fc,
 		p += ctx->nfs_server.export_path_len;
 		*p = 0;
 
+		trace_nfs4_referral_location(ctx->nfs_server.hostname,
+			ctx->nfs_server.export_path);
 		ret = nfs4_get_referral_tree(fc);
 		if (ret == 0)
 			return 0;
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index 4de8780a7c48..ad0af7addcb0 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -2600,6 +2600,31 @@  DEFINE_NFS4_XATTR_EVENT(nfs4_setxattr);
 DEFINE_NFS4_XATTR_EVENT(nfs4_removexattr);
 
 DEFINE_NFS4_INODE_EVENT(nfs4_listxattr);
+
+TRACE_EVENT(nfs4_referral_location,
+		TP_PROTO(
+			const char *hostname,
+			const char *path
+		),
+
+		TP_ARGS(hostname, path),
+
+		TP_STRUCT__entry(
+			__string(referral_hostname, hostname)
+			__string(referral_path, path)
+		),
+
+		TP_fast_assign(
+			__assign_str(referral_hostname);
+			__assign_str(referral_path);
+		),
+
+		TP_printk(
+			"referral_host=%s referral_path=%s",
+			__get_str(referral_hostname),
+			__get_str(referral_path)
+		)
+);
 #endif /* CONFIG_NFS_V4_2 */
 
 #endif /* CONFIG_NFS_V4_1 */