public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: cel@kernel.org
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna@kernel.org>
Cc: sargun@sargun.me, <linux-nfs@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH v4 03/18] nfsd: add a tracepoint for nfsd_setattr
Date: Sat,  3 May 2025 15:59:21 -0400	[thread overview]
Message-ID: <20250503195936.5083-4-cel@kernel.org> (raw)
In-Reply-To: <20250503195936.5083-1-cel@kernel.org>

From: Jeff Layton <jlayton@kernel.org>

Turn Sargun's internal kprobe based implementation of this into a normal
static tracepoint. Also, remove the dprintk's that got added recently
with the fix for zero-length ACLs.

Cc: Sargun Dillon <sargun@sargun.me>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/trace.h         | 39 +++++++++++++++++++++++++++++++++++++++
 fs/nfsd/vfs.c           |  2 ++
 include/trace/misc/fs.h | 21 +++++++++++++++++++++
 3 files changed, 62 insertions(+)

diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index fc373c4d5fdd..b435276a1aaa 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -11,6 +11,7 @@
 #include <linux/tracepoint.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/xprt.h>
+#include <trace/misc/fs.h>
 #include <trace/misc/nfs.h>
 #include <trace/misc/sunrpc.h>
 
@@ -2355,6 +2356,44 @@ DEFINE_EVENT(nfsd_copy_async_done_class,		\
 DEFINE_COPY_ASYNC_DONE_EVENT(done);
 DEFINE_COPY_ASYNC_DONE_EVENT(cancel);
 
+TRACE_EVENT(nfsd_vfs_setattr,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const struct svc_fh *fhp,
+		const struct iattr *iap,
+		const struct timespec64 *guardtime
+	),
+	TP_ARGS(rqstp, fhp, iap, guardtime),
+	TP_STRUCT__entry(
+		NFSD_TRACE_PROC_CALL_FIELDS(rqstp)
+		__field(u32, fh_hash)
+		__field(s64, gtime_tv_sec)
+		__field(u32, gtime_tv_nsec)
+		__field(unsigned int, ia_valid)
+		__field(loff_t, ia_size)
+		__field(uid_t, ia_uid)
+		__field(gid_t, ia_gid)
+		__field(umode_t, ia_mode)
+	),
+	TP_fast_assign(
+		NFSD_TRACE_PROC_CALL_ASSIGNMENTS(rqstp);
+		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
+		__entry->gtime_tv_sec = guardtime ? guardtime->tv_sec : 0;
+		__entry->gtime_tv_nsec = guardtime ? guardtime->tv_nsec : 0;
+		__entry->ia_valid = iap->ia_valid;
+		__entry->ia_size = iap->ia_size;
+		__entry->ia_uid = __kuid_val(iap->ia_uid);
+		__entry->ia_gid = __kgid_val(iap->ia_gid);
+		__entry->ia_mode = iap->ia_mode;
+	),
+	TP_printk(
+		"xid=0x%08x fh_hash=0x%08x ia_valid=%s ia_size=%llu ia_mode=0%o ia_uid=%u ia_gid=%u guard_time=%lld.%u",
+		__entry->xid, __entry->fh_hash, show_ia_valid_flags(__entry->ia_valid),
+		__entry->ia_size, __entry->ia_mode, __entry->ia_uid, __entry->ia_gid,
+		__entry->gtime_tv_sec, __entry->gtime_tv_nsec
+	)
+)
+
 #endif /* _NFSD_TRACE_H */
 
 #undef TRACE_INCLUDE_PATH
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 68f7d0094b06..9e0a858d2129 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -501,6 +501,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	bool		size_change = (iap->ia_valid & ATTR_SIZE);
 	int		retries;
 
+	trace_nfsd_vfs_setattr(rqstp, fhp, iap, guardtime);
+
 	if (iap->ia_valid & ATTR_SIZE) {
 		accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
 		ftype = S_IFREG;
diff --git a/include/trace/misc/fs.h b/include/trace/misc/fs.h
index 738b97f22f36..0406ebe2a80a 100644
--- a/include/trace/misc/fs.h
+++ b/include/trace/misc/fs.h
@@ -120,3 +120,24 @@
 		{ LOOKUP_BENEATH,	"BENEATH" }, \
 		{ LOOKUP_IN_ROOT,	"IN_ROOT" }, \
 		{ LOOKUP_CACHED,	"CACHED" })
+
+#define show_ia_valid_flags(flags)			\
+	__print_flags(flags, "|",			\
+		{ ATTR_MODE,		"MODE" },	\
+		{ ATTR_UID,		"UID" },	\
+		{ ATTR_GID,		"GID" },	\
+		{ ATTR_SIZE,		"SIZE" },	\
+		{ ATTR_ATIME,		"ATIME" },	\
+		{ ATTR_MTIME,		"MTIME" },	\
+		{ ATTR_CTIME,		"CTIME" },	\
+		{ ATTR_ATIME_SET,	"ATIME_SET" },	\
+		{ ATTR_MTIME_SET,	"MTIME_SET" },	\
+		{ ATTR_FORCE,		"FORCE" },	\
+		{ ATTR_KILL_SUID,	"KILL_SUID" },	\
+		{ ATTR_KILL_SGID,	"KILL_SGID" },	\
+		{ ATTR_FILE,		"FILE" },	\
+		{ ATTR_KILL_PRIV,	"KILL_PRIV" },	\
+		{ ATTR_OPEN,		"OPEN" },	\
+		{ ATTR_TIMES_SET,	"TIMES_SET" },	\
+		{ ATTR_TOUCH,		"TOUCH"},	\
+		{ ATTR_DELEG,		"DELEG"})
-- 
2.49.0


  parent reply	other threads:[~2025-05-03 19:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-03 19:59 [PATCH v4 00/18] nfsd: observability improvements cel
2025-05-03 19:59 ` [PATCH v4 01/18] NFSD: Use sockaddr instead of a generic array cel
2025-05-03 20:29   ` Jeff Layton
2025-05-03 19:59 ` [PATCH v4 02/18] NFSD: Add a Call equivalent to the NFSD_TRACE_PROC_RES macros cel
2025-05-03 20:30   ` Jeff Layton
2025-05-03 19:59 ` cel [this message]
2025-05-03 19:59 ` [PATCH v4 04/18] nfsd: add a tracepoint to nfsd_lookup_dentry cel
2025-05-03 19:59 ` [PATCH v4 05/18] nfsd: add nfsd_vfs_create tracepoints cel
2025-05-03 19:59 ` [PATCH v4 06/18] nfsd: add tracepoint to nfsd_symlink cel
2025-05-03 19:59 ` [PATCH v4 07/18] nfsd: add tracepoint to nfsd_link() cel
2025-05-03 20:30   ` Jeff Layton
2025-05-03 19:59 ` [PATCH v4 08/18] nfsd: add tracepoints for unlink events cel
2025-05-03 19:59 ` [PATCH v4 09/18] nfsd: add tracepoint to nfsd_rename cel
2025-05-03 19:59 ` [PATCH v4 10/18] nfsd: add tracepoint to nfsd_readdir cel
2025-05-03 19:59 ` [PATCH v4 11/18] nfsd: add tracepoint for getattr and statfs events cel
2025-05-03 19:59 ` [PATCH v4 12/18] nfsd: remove old v2/3 create path dprintks cel
2025-05-03 19:59 ` [PATCH v4 13/18] nfsd: remove old v2/3 SYMLINK dprintks cel
2025-05-03 19:59 ` [PATCH v4 14/18] nfsd: remove old LINK dprintks cel
2025-05-03 19:59 ` [PATCH v4 15/18] nfsd: remove REMOVE/RMDIR dprintks cel
2025-05-03 19:59 ` [PATCH v4 16/18] nfsd: remove dprintks for v2/3 RENAME events cel
2025-05-03 19:59 ` [PATCH v4 17/18] nfsd: remove legacy READDIR dprintks cel
2025-05-03 19:59 ` [PATCH v4 18/18] nfsd: remove legacy dprintks from GETATTR and STATFS codepaths cel
2025-05-03 20:32 ` [PATCH v4 00/18] nfsd: observability improvements Jeff Layton

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=20250503195936.5083-4-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=anna@kernel.org \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=sargun@sargun.me \
    --cc=tom@talpey.com \
    --cc=trond.myklebust@hammerspace.com \
    /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