All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jorge Mora <jmora1300@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: trond.myklebust@hammerspace.com, Anna.Schumaker@netapp.com
Subject: [PATCH v1 2/2] NFSv4.2 add tracepoint to IO_ADVISE
Date: Tue, 10 Jan 2023 11:46:41 -0700	[thread overview]
Message-ID: <20230110184641.13334-3-mora@netapp.com> (raw)
In-Reply-To: <20230110184641.13334-1-mora@netapp.com>

Add a tracepoint to the IO_ADVISE operation.

Signed-off-by: Jorge Mora <mora@netapp.com>
---
 fs/nfs/nfs42proc.c |  1 +
 fs/nfs/nfs4trace.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index af40f705386a..8f6ad08c7f99 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -205,6 +205,7 @@ static loff_t _nfs42_proc_io_advise(struct file *filep,
 
 	status = nfs4_call_sync(server->client, server, &msg,
 				&args.seq_args, &res.seq_res, 0);
+	trace_nfs4_io_advise(inode, &args, &res, status);
 	if (status == -ENOTSUPP)
 		server->caps &= ~NFS_CAP_IO_ADVISE;
 	return status;
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index e3fbdc8a98eb..e936b0bbebc6 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -2170,6 +2170,81 @@ TRACE_EVENT(nfs4_llseek,
 		)
 );
 
+#define show_nfs4_io_advise_hints(hints) \
+	__print_flags(hints, "|", \
+		{ NFS_IO_ADVISE4_NORMAL,			"NORMAL" }, \
+		{ NFS_IO_ADVISE4_SEQUENTIAL,			"SEQUENTIAL" }, \
+		{ NFS_IO_ADVISE4_SEQUENTIAL_BACKWARDS,		"SEQUENTIAL_BACKWARDS" }, \
+		{ NFS_IO_ADVISE4_RANDOM,			"RANDOM" }, \
+		{ NFS_IO_ADVISE4_WILLNEED,			"WILLNEED" }, \
+		{ NFS_IO_ADVISE4_WILLNEED_OPPORTUNISTIC,	"WILLNEED_OPPORTUNISTIC" }, \
+		{ NFS_IO_ADVISE4_DONTNEED,			"DONTNEED" }, \
+		{ NFS_IO_ADVISE4_NOREUSE,			"NOREUSE" }, \
+		{ NFS_IO_ADVISE4_READ,				"READ" }, \
+		{ NFS_IO_ADVISE4_WRITE,				"WRITE" }, \
+		{ NFS_IO_ADVISE4_INIT_PROXIMITY,		"INIT_PROXIMITY" })
+
+TRACE_EVENT(nfs4_io_advise,
+		TP_PROTO(
+			const struct inode *inode,
+			const struct nfs42_io_advise_args *args,
+			const struct nfs42_io_advise_res *res,
+			int error
+		),
+
+		TP_ARGS(inode, args, res, error),
+
+		TP_STRUCT__entry(
+			__field(unsigned long, error)
+			__field(u32, fhandle)
+			__field(u32, fileid)
+			__field(dev_t, dev)
+			__field(int, stateid_seq)
+			__field(u32, stateid_hash)
+			__field(loff_t, offset)
+			__field(u64, count)
+			__field(u32, arg_hints)
+			__field(u32, res_hints)
+		),
+
+		TP_fast_assign(
+			const struct nfs_inode *nfsi = NFS_I(inode);
+			const struct nfs_fh *fh = args->fh;
+
+			__entry->fileid = nfsi->fileid;
+			__entry->dev = inode->i_sb->s_dev;
+			__entry->fhandle = nfs_fhandle_hash(fh);
+			__entry->stateid_seq = be32_to_cpu(args->stateid.seqid);
+			__entry->stateid_hash = nfs_stateid_hash(&args->stateid);
+			__entry->offset = args->offset;
+			__entry->count = args->count;
+			__entry->arg_hints = args->hints;
+			if (error) {
+				__entry->error = -error;
+				__entry->res_hints = 0;
+			} else {
+				__entry->error = 0;
+				__entry->res_hints = res->hints;
+			}
+		),
+
+		TP_printk(
+			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
+			"stateid=%d:0x%08x offset=%llu count=%llu "
+			"arg_hints=%s res_hints=%s",
+			-__entry->error,
+			show_nfs4_status(__entry->error),
+			MAJOR(__entry->dev), MINOR(__entry->dev),
+			(unsigned long long)__entry->fileid,
+			__entry->fhandle,
+			__entry->stateid_seq, __entry->stateid_hash,
+			__entry->offset,
+			__entry->count,
+			show_nfs4_io_advise_hints(__entry->arg_hints),
+			show_nfs4_io_advise_hints(__entry->res_hints)
+		)
+);
+
 DECLARE_EVENT_CLASS(nfs4_sparse_event,
 		TP_PROTO(
 			const struct inode *inode,
-- 
2.31.1


      parent reply	other threads:[~2023-01-10 18:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 18:46 [PATCH v1 0/2] add support for IO_ADVISE Jorge Mora
2023-01-10 18:46 ` [PATCH v1 1/2] NFS: add IO_ADVISE operation Jorge Mora
2023-01-10 20:33   ` Trond Myklebust
2023-01-10 18:46 ` Jorge Mora [this message]

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=20230110184641.13334-3-mora@netapp.com \
    --to=jmora1300@gmail.com \
    --cc=Anna.Schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.