[PATCH v3 08/17] nfsd: add tracepoint to nfsd_rename

From: Jeff Layton
Date: Sat May 03 2025 - 11:13:58 EST


Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
fs/nfsd/trace.h | 28 ++++++++++++++++++++++++++++
fs/nfsd/vfs.c | 2 ++
2 files changed, 30 insertions(+)

diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index 24e3c32d9db48bd8bf51eb41dda46b889dfa9e8d..4e873ceca602098d2899c5ff2deee610ddb670a0 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -2484,6 +2484,34 @@ TRACE_EVENT(nfsd_vfs_unlink,
__entry->xid, __entry->fh_hash,
__get_str(name))
);
+
+TRACE_EVENT(nfsd_vfs_rename,
+ TP_PROTO(struct svc_rqst *rqstp,
+ struct svc_fh *sfhp,
+ struct svc_fh *tfhp,
+ const char *name,
+ unsigned int namelen,
+ const char *tgt,
+ unsigned int tgtlen),
+ TP_ARGS(rqstp, sfhp, tfhp, name, namelen, tgt, tgtlen),
+ TP_STRUCT__entry(
+ SVC_RQST_ENDPOINT_FIELDS(rqstp)
+ __field(u32, sfh_hash)
+ __field(u32, tfh_hash)
+ __string_len(name, name, namelen)
+ __string_len(tgt, tgt, tgtlen)
+ ),
+ TP_fast_assign(
+ SVC_RQST_ENDPOINT_ASSIGNMENTS(rqstp);
+ __entry->sfh_hash = knfsd_fh_hash(&sfhp->fh_handle);
+ __entry->tfh_hash = knfsd_fh_hash(&tfhp->fh_handle);
+ __assign_str(name);
+ __assign_str(tgt);
+ ),
+ TP_printk("xid=0x%08x sfh_hash=0x%08x tfh_hash=0x%08x name=%s target=%s",
+ __entry->xid, __entry->sfh_hash, __entry->tfh_hash,
+ __get_str(name), __get_str(tgt))
+);
#endif /* _NFSD_TRACE_H */

#undef TRACE_INCLUDE_PATH
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index bd19e5926ef198279e39ac9ef1873eab289cb4a0..9fd5f7d277b452e12a2d5854b9d3ff79418a8818 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1865,6 +1865,8 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
int host_err;
bool close_cached = false;

+ trace_nfsd_vfs_rename(rqstp, ffhp, tfhp, fname, flen, tname, tlen);
+
err = fh_verify(rqstp, ffhp, S_IFDIR, NFSD_MAY_REMOVE);
if (err)
goto out;

--
2.49.0