Skip to content

Commit 0dc7314

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
nfs_common: add nfs_localio trace events
The nfs_localio.ko now exposes /sys/kernel/tracing/events/nfs_localio with nfs_localio_enable_client and nfs_localio_disable_client events. Signed-off-by: Mike Snitzer <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 0858041 commit 0dc7314

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

fs/nfs_common/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
obj-$(CONFIG_NFS_ACL_SUPPORT) += nfs_acl.o
77
nfs_acl-objs := nfsacl.o
88

9+
CFLAGS_localio_trace.o += -I$(src)
910
obj-$(CONFIG_NFS_COMMON_LOCALIO_SUPPORT) += nfs_localio.o
10-
nfs_localio-objs := nfslocalio.o
11+
nfs_localio-objs := nfslocalio.o localio_trace.o
1112

1213
obj-$(CONFIG_GRACE_PERIOD) += grace.o
1314
obj-$(CONFIG_NFS_V4_2_SSC_HELPER) += nfs_ssc.o

fs/nfs_common/localio_trace.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2024 Trond Myklebust <[email protected]>
4+
* Copyright (C) 2024 Mike Snitzer <[email protected]>
5+
*/
6+
#include <linux/nfs_fs.h>
7+
#include <linux/namei.h>
8+
9+
#define CREATE_TRACE_POINTS
10+
#include "localio_trace.h"

fs/nfs_common/localio_trace.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2024 Trond Myklebust <[email protected]>
4+
* Copyright (C) 2024 Mike Snitzer <[email protected]>
5+
*/
6+
#undef TRACE_SYSTEM
7+
#define TRACE_SYSTEM nfs_localio
8+
9+
#if !defined(_TRACE_NFS_COMMON_LOCALIO_H) || defined(TRACE_HEADER_MULTI_READ)
10+
#define _TRACE_NFS_COMMON_LOCALIO_H
11+
12+
#include <linux/tracepoint.h>
13+
14+
#include <trace/misc/fs.h>
15+
#include <trace/misc/nfs.h>
16+
#include <trace/misc/sunrpc.h>
17+
18+
DECLARE_EVENT_CLASS(nfs_local_client_event,
19+
TP_PROTO(
20+
const struct nfs_client *clp
21+
),
22+
23+
TP_ARGS(clp),
24+
25+
TP_STRUCT__entry(
26+
__field(unsigned int, protocol)
27+
__string(server, clp->cl_hostname)
28+
),
29+
30+
TP_fast_assign(
31+
__entry->protocol = clp->rpc_ops->version;
32+
__assign_str(server);
33+
),
34+
35+
TP_printk(
36+
"server=%s NFSv%u", __get_str(server), __entry->protocol
37+
)
38+
);
39+
40+
#define DEFINE_NFS_LOCAL_CLIENT_EVENT(name) \
41+
DEFINE_EVENT(nfs_local_client_event, name, \
42+
TP_PROTO( \
43+
const struct nfs_client *clp \
44+
), \
45+
TP_ARGS(clp))
46+
47+
DEFINE_NFS_LOCAL_CLIENT_EVENT(nfs_localio_enable_client);
48+
DEFINE_NFS_LOCAL_CLIENT_EVENT(nfs_localio_disable_client);
49+
50+
#endif /* _TRACE_NFS_COMMON_LOCALIO_H */
51+
52+
#undef TRACE_INCLUDE_PATH
53+
#define TRACE_INCLUDE_PATH .
54+
#define TRACE_INCLUDE_FILE localio_trace
55+
/* This part must be outside protection */
56+
#include <trace/define_trace.h>

fs/nfs_common/nfslocalio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <linux/nfs_fs.h>
1313
#include <net/netns/generic.h>
1414

15+
#include "localio_trace.h"
16+
1517
MODULE_LICENSE("GPL");
1618
MODULE_DESCRIPTION("NFS localio protocol bypass support");
1719

@@ -141,6 +143,7 @@ void nfs_localio_enable_client(struct nfs_client *clp)
141143

142144
spin_lock(&nfs_uuid->lock);
143145
set_bit(NFS_CS_LOCAL_IO, &clp->cl_flags);
146+
trace_nfs_localio_enable_client(clp);
144147
spin_unlock(&nfs_uuid->lock);
145148
}
146149
EXPORT_SYMBOL_GPL(nfs_localio_enable_client);
@@ -199,6 +202,7 @@ void nfs_localio_disable_client(struct nfs_client *clp)
199202
if (test_and_clear_bit(NFS_CS_LOCAL_IO, &clp->cl_flags)) {
200203
/* &clp->cl_uuid is always not NULL, using as bool here */
201204
nfs_uuid = &clp->cl_uuid;
205+
trace_nfs_localio_disable_client(clp);
202206
}
203207
spin_unlock(&clp->cl_uuid.lock);
204208

0 commit comments

Comments
 (0)