2024-06-07 08:50:09

by Chen Hanxiao

[permalink] [raw]
Subject: [PATCH] NFS: add new nfs3 acl tracepoint events

Add some new tracepoints to the NFSv3 acl events

Signed-off-by: Chen Hanxiao <[email protected]>
---
fs/nfs/nfs3acl.c | 3 +++
fs/nfs/nfstrace.c | 2 ++
fs/nfs/nfstrace.h | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)

diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 18d8f6529f61..5c5c1e1c07f8 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -9,6 +9,7 @@

#include "internal.h"
#include "nfs3_fs.h"
+#include "nfstrace.h"

#define NFSDBG_FACILITY NFSDBG_PROC

@@ -96,6 +97,7 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu)
nfs3_prepare_get_acl(&inode->i_default_acl);

status = rpc_call_sync(server->client_acl, &msg, 0);
+ trace_nfs3_get_acl(inode, status);
dprintk("NFS reply getacl: %d\n", status);

/* pages may have been allocated at the xdr layer. */
@@ -287,6 +289,7 @@ int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
acl = alloc;
}
status = __nfs3_proc_setacls(inode, acl, dfacl);
+ trace_nfs3_set_acl(inode, status);
out:
if (acl != orig)
posix_acl_release(acl);
diff --git a/fs/nfs/nfstrace.c b/fs/nfs/nfstrace.c
index 5d1bfccbb4da..c6cf133b8853 100644
--- a/fs/nfs/nfstrace.c
+++ b/fs/nfs/nfstrace.c
@@ -13,3 +13,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_fsync_enter);
EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_fsync_exit);
EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_xdr_status);
EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_xdr_bad_filehandle);
+EXPORT_TRACEPOINT_SYMBOL_GPL(nfs3_get_acl);
+EXPORT_TRACEPOINT_SYMBOL_GPL(nfs3_set_acl);
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 1e710654af11..d0d8b83c665a 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -161,6 +161,45 @@ DEFINE_NFS_INODE_EVENT(nfs_readdir_force_readdirplus);
DEFINE_NFS_INODE_EVENT_DONE(nfs_readdir_cache_fill_done);
DEFINE_NFS_INODE_EVENT_DONE(nfs_readdir_uncached_done);

+DECLARE_EVENT_CLASS(nfs3_acl_template,
+ TP_PROTO(
+ const struct inode *inode,
+ int error
+ ),
+
+ TP_ARGS(inode, error),
+
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(u32, fhandle)
+ __field(u64, fileid)
+ __field(unsigned long, error)
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->fileid = NFS_FILEID(inode);
+ __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
+ __entry->error = error < 0 ? -error : 0;
+ ),
+
+ TP_printk(
+ "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
+ -__entry->error,
+ show_nfs4_status(__entry->error),
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+ (unsigned long long)__entry->fileid,
+ __entry->fhandle
+ )
+);
+
+DEFINE_EVENT(nfs3_acl_template, nfs3_get_acl,
+ TP_PROTO(const struct inode *inode, int error),
+ TP_ARGS(inode, error));
+DEFINE_EVENT(nfs3_acl_template, nfs3_set_acl,
+ TP_PROTO(const struct inode *inode, int error),
+ TP_ARGS(inode, error));
+
TRACE_EVENT(nfs_access_exit,
TP_PROTO(
const struct inode *inode,
--
2.39.1