[PATCH RFC 07/21] NFSD: Add tracepoint in nfsd_setattr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Capture especially the XID, file handle, and attr mask for
troubleshooting. So for example:

nfsd-1025  [002]   256.807363: nfsd_setattr:         xid=0x12147d7a fh_hash=0x6085d6fb valid=MODE|ATIME|MTIME

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---
 fs/nfsd/trace.h |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfsd/vfs.c   |    2 +
 2 files changed, 83 insertions(+)

diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index 2ed632d36640..77b7e8a45776 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -12,6 +12,64 @@
 #include "export.h"
 #include "nfsfh.h"
 
+/*
+ * from include/linux/fs.h
+ */
+#define ATTR_VALID_LIST							\
+	attr_valid_list(MODE)						\
+	attr_valid_list(UID)						\
+	attr_valid_list(GID)						\
+	attr_valid_list(SIZE)						\
+	attr_valid_list(ATIME)						\
+	attr_valid_list(MTIME)						\
+	attr_valid_list(CTIME)						\
+	attr_valid_list(ATIME_SET)					\
+	attr_valid_list(MTIME_SET)					\
+	attr_valid_list(FORCE)						\
+	attr_valid_list(KILL_SUID)					\
+	attr_valid_list(KILL_SGID)					\
+	attr_valid_list(FILE)						\
+	attr_valid_list(KILL_PRIV)					\
+	attr_valid_list(OPEN)						\
+	attr_valid_list(TIMES_SET)					\
+	attr_valid_list_end(TOUCH)
+
+#undef attr_valid_list
+#undef attr_valid_list_end
+#define attr_valid_list(x)		TRACE_DEFINE_ENUM(ATTR_##x);
+#define attr_valid_list_end(x)		TRACE_DEFINE_ENUM(ATTR_##x);
+
+ATTR_VALID_LIST
+
+#undef attr_valid_list
+#undef attr_valid_list_end
+#define attr_valid_list(x)		{ ATTR_##x, #x },
+#define attr_valid_list_end(x)		{ ATTR_##x, #x }
+
+#define show_attr_valid_flags(x)	__print_flags(x, "|", ATTR_VALID_LIST)
+
+/*
+ * from include/uapi/linux/stat.h
+ */
+TRACE_DEFINE_ENUM(S_IFSOCK);
+TRACE_DEFINE_ENUM(S_IFLNK);
+TRACE_DEFINE_ENUM(S_IFREG);
+TRACE_DEFINE_ENUM(S_IFBLK);
+TRACE_DEFINE_ENUM(S_IFDIR);
+TRACE_DEFINE_ENUM(S_IFCHR);
+TRACE_DEFINE_ENUM(S_IFIFO);
+
+#define show_inode_type(x)						\
+	__print_symbolic(x,						\
+			{ S_IFSOCK, "SOCK" },				\
+			{ S_IFLNK, "LNK" },				\
+			{ S_IFREG, "REG" },				\
+			{ S_IFBLK, "BLK" },				\
+			{ S_IFDIR, "DIR" },				\
+			{ S_IFCHR, "CHR" },				\
+			{ S_IFIFO, "FIFO" },				\
+			{ 0, "NONE" })
+
 /*
  * from fs/nfsd/vfs.h
  */
@@ -805,6 +863,29 @@ TRACE_EVENT(nfsd_cb_done,
 		__entry->status)
 );
 
+TRACE_EVENT(nfsd_setattr_args,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const struct svc_fh *fhp,
+		unsigned int valid
+	),
+	TP_ARGS(rqstp, fhp, valid),
+	TP_STRUCT__entry(
+		__field(u32, xid)
+		__field(u32, fh_hash)
+		__field(unsigned long, valid)
+	),
+	TP_fast_assign(
+		__entry->xid = be32_to_cpu(rqstp->rq_xid);
+		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
+		__entry->valid = valid;
+	),
+	TP_printk("xid=0x%08x fh_hash=0x%08x valid=%s",
+		__entry->xid, __entry->fh_hash,
+		show_attr_valid_flags(__entry->valid)
+	)
+);
+
 #endif /* _NFSD_TRACE_H */
 
 #undef TRACE_INCLUDE_PATH
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 1ecaceebee13..a311593ac976 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -375,6 +375,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 	bool		get_write_count;
 	bool		size_change = (iap->ia_valid & ATTR_SIZE);
 
+	trace_nfsd_setattr_args(rqstp, fhp, iap->ia_valid);
+
 	if (iap->ia_valid & ATTR_SIZE) {
 		accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
 		ftype = S_IFREG;





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux