From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>
Cc: Sargun Dillon <sargun@sargun.me>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v2 06/12] nfsd: add tracepoints around nfsd_create events
Date: Wed, 09 Apr 2025 10:32:28 -0400 [thread overview]
Message-ID: <20250409-nfsd-tracepoints-v2-6-cf4e084fdd9c@kernel.org> (raw)
In-Reply-To: <20250409-nfsd-tracepoints-v2-0-cf4e084fdd9c@kernel.org>
...and remove the legacy dprintks.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfsd/nfs3proc.c | 18 +++++-------------
fs/nfsd/nfs4proc.c | 29 +++++++++++++++++++++++++++++
fs/nfsd/nfsproc.c | 6 +++---
fs/nfsd/trace.h | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 76 insertions(+), 16 deletions(-)
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index 372bdcf5e07a5c835da240ecebb02e3576eb2ca6..ea1280970ea11b2a82f0de88ad0422eef7063d6d 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -14,6 +14,7 @@
#include "xdr3.h"
#include "vfs.h"
#include "filecache.h"
+#include "trace.h"
#define NFSDDBG_FACILITY NFSDDBG_PROC
@@ -380,10 +381,7 @@ nfsd3_proc_create(struct svc_rqst *rqstp)
struct nfsd3_diropres *resp = rqstp->rq_resp;
svc_fh *dirfhp, *newfhp;
- dprintk("nfsd: CREATE(3) %s %.*s\n",
- SVCFH_fmt(&argp->fh),
- argp->len,
- argp->name);
+ trace_nfsd3_proc_create(rqstp, &argp->fh, S_IFREG, argp->name, argp->len);
dirfhp = fh_copy(&resp->dirfh, &argp->fh);
newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
@@ -405,10 +403,7 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp)
.na_iattr = &argp->attrs,
};
- dprintk("nfsd: MKDIR(3) %s %.*s\n",
- SVCFH_fmt(&argp->fh),
- argp->len,
- argp->name);
+ trace_nfsd3_proc_mkdir(rqstp, &argp->fh, S_IFDIR, argp->name, argp->len);
argp->attrs.ia_valid &= ~ATTR_SIZE;
fh_copy(&resp->dirfh, &argp->fh);
@@ -471,13 +466,10 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp)
struct nfsd_attrs attrs = {
.na_iattr = &argp->attrs,
};
- int type;
+ int type = nfs3_ftypes[argp->ftype];
dev_t rdev = 0;
- dprintk("nfsd: MKNOD(3) %s %.*s\n",
- SVCFH_fmt(&argp->fh),
- argp->len,
- argp->name);
+ trace_nfsd3_proc_mknod(rqstp, &argp->fh, type, argp->name, argp->len);
fh_copy(&resp->dirfh, &argp->fh);
fh_init(&resp->fh, NFS3_FHSIZE);
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 6e23d6103010197c0316b07c189fe12ec3033812..2c795103deaa4044596bd07d90db788169a32a0c 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -250,6 +250,8 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
__be32 status;
int host_err;
+ trace_nfsd4_create_file(rqstp, fhp, S_IFREG, open->op_fname, open->op_fnamelen);
+
if (isdotent(open->op_fname, open->op_fnamelen))
return nfserr_exist;
if (!(iap->ia_valid & ATTR_MODE))
@@ -807,6 +809,29 @@ nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
return status;
}
+static umode_t nfs_type_to_vfs_type(enum nfs_ftype4 nfstype)
+{
+ switch (nfstype) {
+ case NF4REG:
+ return S_IFREG;
+ case NF4DIR:
+ return S_IFDIR;
+ case NF4BLK:
+ return S_IFBLK;
+ case NF4CHR:
+ return S_IFCHR;
+ case NF4LNK:
+ return S_IFLNK;
+ case NF4SOCK:
+ return S_IFSOCK;
+ case NF4FIFO:
+ return S_IFIFO;
+ default:
+ break;
+ }
+ return 0;
+}
+
static __be32
nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
union nfsd4_op_u *u)
@@ -822,6 +847,10 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
__be32 status;
dev_t rdev;
+ trace_nfsd4_create(rqstp, &cstate->current_fh,
+ nfs_type_to_vfs_type(create->cr_type),
+ create->cr_name, create->cr_namelen);
+
fh_init(&resfh, NFS4_FHSIZE);
status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP);
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 6dda081eb24c00b834ab0965c3a35a12115bceb7..33d8cbf8785588d38d4ec5efd769c1d1d06c6a91 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -10,6 +10,7 @@
#include "cache.h"
#include "xdr.h"
#include "vfs.h"
+#include "trace.h"
#define NFSDDBG_FACILITY NFSDDBG_PROC
@@ -292,8 +293,7 @@ nfsd_proc_create(struct svc_rqst *rqstp)
int hosterr;
dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
- dprintk("nfsd: CREATE %s %.*s\n",
- SVCFH_fmt(dirfhp), argp->len, argp->name);
+ trace_nfsd_proc_create(rqstp, dirfhp, S_IFREG, argp->name, argp->len);
/* First verify the parent file handle */
resp->status = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC);
@@ -548,7 +548,7 @@ nfsd_proc_mkdir(struct svc_rqst *rqstp)
.na_iattr = &argp->attrs,
};
- dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
+ trace_nfsd_proc_mkdir(rqstp, &argp->fh, S_IFDIR, argp->name, argp->len);
if (resp->fh.fh_dentry) {
printk(KERN_WARNING
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index 382849d7c321d6ded8213890c2e7075770aa716c..c6aff23a845f06c87e701d57ec577c2c5c5a743c 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -2391,6 +2391,45 @@ TRACE_EVENT(nfsd_lookup_dentry,
TP_printk("xid=0x%08x fh_hash=0x%08x name=%s",
__entry->xid, __entry->fh_hash, __get_str(name))
);
+
+DECLARE_EVENT_CLASS(nfsd_vfs_create_class,
+ TP_PROTO(struct svc_rqst *rqstp,
+ struct svc_fh *fhp,
+ umode_t type,
+ const char *name,
+ unsigned int len),
+ TP_ARGS(rqstp, fhp, type, name, len),
+ TP_STRUCT__entry(
+ SVC_RQST_ENDPOINT_FIELDS(rqstp)
+ __field(u32, fh_hash)
+ __field(umode_t, type)
+ __string_len(name, name, len)
+ ),
+ TP_fast_assign(
+ SVC_RQST_ENDPOINT_ASSIGNMENTS(rqstp);
+ __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
+ __entry->type = type;
+ __assign_str(name);
+ ),
+ TP_printk("xid=0x%08x fh_hash=0x%08x type=%s name=%s",
+ __entry->xid, __entry->fh_hash,
+ show_fs_file_type(__entry->type), __get_str(name))
+);
+
+#define DEFINE_NFSD_VFS_CREATE_EVENT(__name) \
+ DEFINE_EVENT(nfsd_vfs_create_class, __name, \
+ TP_PROTO(struct svc_rqst *rqstp, struct svc_fh *fhp, \
+ umode_t type, const char *name, unsigned int len), \
+ TP_ARGS(rqstp, fhp, type, name, len))
+
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd_proc_create);
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd_proc_mkdir);
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd3_proc_create);
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd3_proc_mkdir);
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd3_proc_mknod);
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd4_create);
+DEFINE_NFSD_VFS_CREATE_EVENT(nfsd4_create_file);
+
#endif /* _NFSD_TRACE_H */
#undef TRACE_INCLUDE_PATH
--
2.49.0
next prev parent reply other threads:[~2025-04-09 14:33 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 14:32 [PATCH v2 00/12] nfsd: observability improvements Jeff Layton
2025-04-09 14:32 ` [PATCH v2 01/12] nfsd: add commit start/done tracepoints around nfsd_commit() Jeff Layton
2025-04-09 14:32 ` [PATCH v2 02/12] sunrpc: add info about xprt queue times to svc_xprt_dequeue tracepoint Jeff Layton
2025-04-09 15:00 ` Chuck Lever
2025-04-09 15:26 ` Jeff Layton
2025-04-11 13:10 ` Jeff Layton
2025-04-11 13:24 ` Chuck Lever
2025-04-11 13:40 ` Jeff Layton
2025-04-09 14:32 ` [PATCH v2 03/12] sunrpc: move the SVC_RQST_EVENT_*() macros to common header Jeff Layton
2025-04-09 14:32 ` [PATCH v2 04/12] nfsd: add a tracepoint for nfsd_setattr Jeff Layton
2025-04-09 15:03 ` Chuck Lever
2025-04-09 14:32 ` [PATCH v2 05/12] nfsd: add a tracepoint to nfsd_lookup_dentry Jeff Layton
2025-04-09 14:32 ` Jeff Layton [this message]
2025-04-09 15:09 ` [PATCH v2 06/12] nfsd: add tracepoints around nfsd_create events Chuck Lever
2025-04-09 15:36 ` Jeff Layton
2025-04-09 15:38 ` Chuck Lever
2025-04-09 15:40 ` Chuck Lever
2025-04-09 16:50 ` Jeff Layton
2025-04-09 16:59 ` Chuck Lever
2025-04-09 14:32 ` [PATCH v2 07/12] nfsd: add tracepoints for symlink events Jeff Layton
2025-04-09 15:15 ` Chuck Lever
2025-04-09 14:32 ` [PATCH v2 08/12] nfsd: add tracepoints for hardlink events Jeff Layton
2025-04-09 14:32 ` [PATCH v2 09/12] nfsd: add tracepoints for unlink events Jeff Layton
2025-04-09 14:32 ` [PATCH v2 10/12] nfsd: add tracepoints to rename events Jeff Layton
2025-04-09 14:32 ` [PATCH v2 11/12] nfsd: add tracepoints for readdir events Jeff Layton
2025-04-09 14:32 ` [PATCH v2 12/12] nfsd: add tracepoint for getattr events Jeff Layton
2025-04-11 14:52 ` (subset) [PATCH v2 00/12] nfsd: observability improvements cel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250409-nfsd-tracepoints-v2-6-cf4e084fdd9c@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=okorniev@redhat.com \
--cc=sargun@sargun.me \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox