Set up tracepoints to track read, write and commit, as well as pNFS reads and writes and commits to the data server. Signed-off-by: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx> --- fs/nfs/nfs4filelayout.c | 10 +++++ fs/nfs/nfs4proc.c | 8 ++++ fs/nfs/nfs4trace.c | 5 +++ fs/nfs/nfs4trace.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/pnfs.c | 7 ++++ 5 files changed, 134 insertions(+) diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index f6ec7c7..ca92340 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c @@ -39,6 +39,7 @@ #include "internal.h" #include "delegation.h" #include "nfs4filelayout.h" +#include "nfs4trace.h" #define NFSDBG_FACILITY NFSDBG_PNFS_LD @@ -273,6 +274,9 @@ static int filelayout_read_done_cb(struct rpc_task *task, struct nfs_pgio_header *hdr = data->header; int err; + trace_nfs4_pnfs_read(hdr, data->args.context, + data->args.offset, data->args.count, + task->tk_status); err = filelayout_async_handle_error(task, data->args.context->state, data->ds_clp, hdr->lseg); @@ -389,6 +393,9 @@ static int filelayout_write_done_cb(struct rpc_task *task, struct nfs_pgio_header *hdr = data->header; int err; + trace_nfs4_pnfs_write(hdr, data->args.context, + data->args.offset, data->args.count, + task->tk_status); err = filelayout_async_handle_error(task, data->args.context->state, data->ds_clp, hdr->lseg); @@ -421,6 +428,9 @@ static int filelayout_commit_done_cb(struct rpc_task *task, { int err; + trace_nfs4_pnfs_commit_ds(data->inode, + data->args.offset, data->args.count, + task->tk_status); err = filelayout_async_handle_error(task, NULL, data->ds_clp, data->lseg); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index d269199..a1aac14 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3885,6 +3885,9 @@ static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_read_data *data) { struct nfs_server *server = NFS_SERVER(data->header->inode); + trace_nfs4_read(data->header, data->args.context, + data->args.offset, data->args.count, + task->tk_status); if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { rpc_restart_call_prepare(task); return -EAGAIN; @@ -3946,6 +3949,9 @@ static int nfs4_write_done_cb(struct rpc_task *task, struct nfs_write_data *data { struct inode *inode = data->header->inode; + trace_nfs4_write(data->header, data->args.context, + data->args.offset, data->args.count, + task->tk_status); if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { rpc_restart_call_prepare(task); return -EAGAIN; @@ -4037,6 +4043,8 @@ static int nfs4_commit_done_cb(struct rpc_task *task, struct nfs_commit_data *da { struct inode *inode = data->inode; + trace_nfs4_commit(inode, data->args.offset, data->args.count, + task->tk_status); if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { rpc_restart_call_prepare(task); return -EAGAIN; diff --git a/fs/nfs/nfs4trace.c b/fs/nfs/nfs4trace.c index 3f02183..f840974 100644 --- a/fs/nfs/nfs4trace.c +++ b/fs/nfs/nfs4trace.c @@ -8,3 +8,8 @@ #define CREATE_TRACE_POINTS #include "nfs4trace.h" +#ifdef CONFIG_NFS_V4_1 +EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_read); +EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_write); +EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_commit_ds); +#endif diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index 7b3cfbf..eea87d9 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -675,6 +675,110 @@ DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid); DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name); DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group); +DECLARE_EVENT_CLASS(nfs4_read_write_event, + TP_PROTO(const struct nfs_pgio_header *header, + const struct nfs_open_context *ctx, + loff_t offset, + size_t count, + int error), + + TP_ARGS(header, ctx, offset, count, error), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(loff_t, offset) + __field(size_t, count) + __field(int, error) + ), + + TP_fast_assign( + struct inode *inode = header->inode; + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->offset = offset; + __entry->count = count; + __entry->error = error; + ), + + TP_printk("error=%d (%s) fileid=%02x:%02x:%lld, fhandle=%0x08x" + "offset=%llu, count=%zu", + __entry->error, + show_nfsv4_errors(__entry->error), + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, + (unsigned long long)__entry->offset, + __entry->count + ) +); + +#define DEFINE_NFS4_READ_WRITE_EVENT(name) \ +DEFINE_EVENT(nfs4_read_write_event, name, \ + TP_PROTO(const struct nfs_pgio_header *header, \ + const struct nfs_open_context *ctx, \ + loff_t offset, \ + size_t count, \ + int error), \ + TP_ARGS(header, ctx, offset, count, error)) +DEFINE_NFS4_READ_WRITE_EVENT(nfs4_read); +DEFINE_NFS4_READ_WRITE_EVENT(nfs4_write); +#ifdef CONFIG_NFS_V4_1 +DEFINE_NFS4_READ_WRITE_EVENT(nfs4_pnfs_read); +DEFINE_NFS4_READ_WRITE_EVENT(nfs4_pnfs_write); +#endif /* CONFIG_NFS_V4_1 */ + +DECLARE_EVENT_CLASS(nfs4_commit_event, + TP_PROTO(const struct inode *inode, + loff_t offset, + size_t count, + int error), + + TP_ARGS(inode, offset, count, error), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(loff_t, offset) + __field(size_t, count) + __field(int, error) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->offset = offset; + __entry->count = count; + __entry->error = error; + ), + + TP_printk("error=%d (%s) fileid=%02x:%02x:%lld, fhandle=%0x08x" + "offset=%llu, count=%zu", + __entry->error, + show_nfsv4_errors(__entry->error), + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, + (unsigned long long)__entry->offset, + __entry->count + ) +); +#define DEFINE_NFS4_COMMIT_EVENT(name) \ +DEFINE_EVENT(nfs4_commit_event, name, \ + TP_PROTO(const struct inode *inode, \ + loff_t offset, \ + size_t count, \ + int error), \ + TP_ARGS(inode, offset, count, error)) +DEFINE_NFS4_COMMIT_EVENT(nfs4_commit); +#ifdef CONFIG_NFS_V4_1 +DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds); +#endif /* CONFIG_NFS_V4_1 */ + #endif /* _TRACE_NFS4_H */ #undef TRACE_INCLUDE_PATH diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 9bf5cda..3a147dd 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -33,6 +33,7 @@ #include "internal.h" #include "pnfs.h" #include "iostat.h" +#include "nfs4trace.h" #define NFSDBG_FACILITY NFSDBG_PNFS #define PNFS_LAYOUTGET_RETRY_TIMEOUT (120*HZ) @@ -1551,6 +1552,9 @@ void pnfs_ld_write_done(struct nfs_write_data *data) { struct nfs_pgio_header *hdr = data->header; + trace_nfs4_pnfs_write(hdr, data->args.context, + data->args.offset, data->args.count, + hdr->pnfs_error); if (!hdr->pnfs_error) { pnfs_set_layoutcommit(data); hdr->mds_ops->rpc_call_done(&data->task, data); @@ -1705,6 +1709,9 @@ void pnfs_ld_read_done(struct nfs_read_data *data) { struct nfs_pgio_header *hdr = data->header; + trace_nfs4_pnfs_write(hdr, data->args.context, + data->args.offset, data->args.count, + hdr->pnfs_error); if (likely(!hdr->pnfs_error)) { __nfs4_read_done_cb(data); hdr->mds_ops->rpc_call_done(&data->task, data); -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html