Add a tracepoint to the IO_ADVISE operation. Signed-off-by: Jorge Mora <mora@xxxxxxxxxx> --- 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