NFSv4: Add tracepoints for debugging reads and writes
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 14 Aug 2013 19:31:28 +0000 (15:31 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 22 Aug 2013 12:58:26 +0000 (08:58 -0400)
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@netapp.com>
fs/nfs/nfs4filelayout.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4trace.c
fs/nfs/nfs4trace.h
fs/nfs/pnfs.c

index 17ed87ef9de809cf76f7ea6e4af4e2b0f3f3f614..a70cb3a0b96e85d4b3f0868dc2827a626dae7c52 100644 (file)
@@ -39,6 +39,7 @@
 #include "internal.h"
 #include "delegation.h"
 #include "nfs4filelayout.h"
+#include "nfs4trace.h"
 
 #define NFSDBG_FACILITY         NFSDBG_PNFS_LD
 
@@ -247,6 +248,7 @@ static int filelayout_read_done_cb(struct rpc_task *task,
        struct nfs_pgio_header *hdr = data->header;
        int err;
 
+       trace_nfs4_pnfs_read(data, task->tk_status);
        err = filelayout_async_handle_error(task, data->args.context->state,
                                            data->ds_clp, hdr->lseg);
 
@@ -363,6 +365,7 @@ static int filelayout_write_done_cb(struct rpc_task *task,
        struct nfs_pgio_header *hdr = data->header;
        int err;
 
+       trace_nfs4_pnfs_write(data, task->tk_status);
        err = filelayout_async_handle_error(task, data->args.context->state,
                                            data->ds_clp, hdr->lseg);
 
@@ -395,6 +398,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task,
 {
        int err;
 
+       trace_nfs4_pnfs_commit_ds(data, task->tk_status);
        err = filelayout_async_handle_error(task, NULL, data->ds_clp,
                                            data->lseg);
 
index bcfe3adb20570f6b1539404568288eb9c47e492f..214f9c4fdeee93f6e4f2921aed594d7605aa8460 100644 (file)
@@ -3881,6 +3881,7 @@ 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, task->tk_status);
        if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) {
                rpc_restart_call_prepare(task);
                return -EAGAIN;
@@ -3942,6 +3943,7 @@ 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, task->tk_status);
        if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) {
                rpc_restart_call_prepare(task);
                return -EAGAIN;
@@ -4033,6 +4035,7 @@ static int nfs4_commit_done_cb(struct rpc_task *task, struct nfs_commit_data *da
 {
        struct inode *inode = data->inode;
 
+       trace_nfs4_commit(data, task->tk_status);
        if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) {
                rpc_restart_call_prepare(task);
                return -EAGAIN;
index 3f0218365fc77a733c78c8b44e76942395a1f725..f8409743c5c54129056c100942a6185112ebbd71 100644 (file)
@@ -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
index 99d1b1e796508227487e0631162f6ed7b0b13784..1ea69836443f06f700f97fa713ea0c1cf6298a81 100644 (file)
@@ -742,6 +742,160 @@ 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_event,
+               TP_PROTO(
+                       const struct nfs_read_data *data,
+                       int error
+               ),
+
+               TP_ARGS(data, 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(
+                       const struct inode *inode = data->header->inode;
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = NFS_FILEID(inode);
+                       __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
+                       __entry->offset = data->args.offset;
+                       __entry->count = data->args.count;
+                       __entry->error = error;
+               ),
+
+               TP_printk(
+                       "error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
+                       "offset=%lld count=%zu",
+                       __entry->error,
+                       show_nfsv4_errors(__entry->error),
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->fileid,
+                       __entry->fhandle,
+                       (long long)__entry->offset,
+                       __entry->count
+               )
+);
+#define DEFINE_NFS4_READ_EVENT(name) \
+       DEFINE_EVENT(nfs4_read_event, name, \
+                       TP_PROTO( \
+                               const struct nfs_read_data *data, \
+                               int error \
+                       ), \
+                       TP_ARGS(data, error))
+DEFINE_NFS4_READ_EVENT(nfs4_read);
+#ifdef CONFIG_NFS_V4_1
+DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
+#endif /* CONFIG_NFS_V4_1 */
+
+DECLARE_EVENT_CLASS(nfs4_write_event,
+               TP_PROTO(
+                       const struct nfs_write_data *data,
+                       int error
+               ),
+
+               TP_ARGS(data, 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(
+                       const struct inode *inode = data->header->inode;
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = NFS_FILEID(inode);
+                       __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
+                       __entry->offset = data->args.offset;
+                       __entry->count = data->args.count;
+                       __entry->error = error;
+               ),
+
+               TP_printk(
+                       "error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
+                       "offset=%lld count=%zu",
+                       __entry->error,
+                       show_nfsv4_errors(__entry->error),
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->fileid,
+                       __entry->fhandle,
+                       (long long)__entry->offset,
+                       __entry->count
+               )
+);
+
+#define DEFINE_NFS4_WRITE_EVENT(name) \
+       DEFINE_EVENT(nfs4_write_event, name, \
+                       TP_PROTO( \
+                               const struct nfs_write_data *data, \
+                               int error \
+                       ), \
+                       TP_ARGS(data, error))
+DEFINE_NFS4_WRITE_EVENT(nfs4_write);
+#ifdef CONFIG_NFS_V4_1
+DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
+#endif /* CONFIG_NFS_V4_1 */
+
+DECLARE_EVENT_CLASS(nfs4_commit_event,
+               TP_PROTO(
+                       const struct nfs_commit_data *data,
+                       int error
+               ),
+
+               TP_ARGS(data, 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(
+                       const struct inode *inode = data->inode;
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = NFS_FILEID(inode);
+                       __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
+                       __entry->offset = data->args.offset;
+                       __entry->count = data->args.count;
+                       __entry->error = error;
+               ),
+
+               TP_printk(
+                       "error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
+                       "offset=%lld count=%zu",
+                       __entry->error,
+                       show_nfsv4_errors(__entry->error),
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->fileid,
+                       __entry->fhandle,
+                       (long long)__entry->offset,
+                       __entry->count
+               )
+);
+#define DEFINE_NFS4_COMMIT_EVENT(name) \
+       DEFINE_EVENT(nfs4_commit_event, name, \
+                       TP_PROTO( \
+                               const struct nfs_commit_data *data, \
+                               int error \
+                       ), \
+                       TP_ARGS(data, 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
index 3a3a79d6bf15c4fa4dfabdf10802a0ee4be9c5aa..d75d938d36cbff83bee4f905e142eeaf95c9b33b 100644 (file)
@@ -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)
@@ -1526,6 +1527,7 @@ void pnfs_ld_write_done(struct nfs_write_data *data)
 {
        struct nfs_pgio_header *hdr = data->header;
 
+       trace_nfs4_pnfs_write(data, hdr->pnfs_error);
        if (!hdr->pnfs_error) {
                pnfs_set_layoutcommit(data);
                hdr->mds_ops->rpc_call_done(&data->task, data);
@@ -1680,6 +1682,7 @@ void pnfs_ld_read_done(struct nfs_read_data *data)
 {
        struct nfs_pgio_header *hdr = data->header;
 
+       trace_nfs4_pnfs_read(data, hdr->pnfs_error);
        if (likely(!hdr->pnfs_error)) {
                __nfs4_read_done_cb(data);
                hdr->mds_ops->rpc_call_done(&data->task, data);