NFSv4: Add tracepoints for debugging delegations
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 13 Aug 2013 14:36:56 +0000 (10:36 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 22 Aug 2013 12:58:24 +0000 (08:58 -0400)
Set up tracepoints to track when delegations are set, reclaimed,
returned by the client, or recalled by the server.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/callback_proc.c
fs/nfs/delegation.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4trace.h

index e6ebc4c38c812c01c79c587862ac9192d721765a..c0749305189bc6aa3bb065a2b6f1ec9a9151e006 100644 (file)
@@ -15,6 +15,7 @@
 #include "internal.h"
 #include "pnfs.h"
 #include "nfs4session.h"
+#include "nfs4trace.h"
 
 #ifdef NFS_DEBUG
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -93,6 +94,7 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
        default:
                res = htonl(NFS4ERR_RESOURCE);
        }
+       trace_nfs4_recall_delegation(inode, -ntohl(res));
        iput(inode);
 out:
        dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
index 7ec4814e298d4d957fd4bfa17cb59de20e429ba9..ef792f29f831c4c72e3e4edd7db9257165aca2fe 100644 (file)
@@ -20,6 +20,7 @@
 #include "nfs4_fs.h"
 #include "delegation.h"
 #include "internal.h"
+#include "nfs4trace.h"
 
 static void nfs_free_delegation(struct nfs_delegation *delegation)
 {
@@ -160,6 +161,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
                        spin_unlock(&delegation->lock);
                        put_rpccred(oldcred);
                        rcu_read_unlock();
+                       trace_nfs4_reclaim_delegation(inode, res->delegation_type);
                } else {
                        /* We appear to have raced with a delegation return. */
                        spin_unlock(&delegation->lock);
@@ -344,6 +346,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
        spin_lock(&inode->i_lock);
        nfsi->cache_validity |= NFS_INO_REVAL_FORCED;
        spin_unlock(&inode->i_lock);
+       trace_nfs4_set_delegation(inode, res->delegation_type);
 
 out:
        spin_unlock(&clp->cl_lock);
index 4b3ba92b0e10b044d06e0ee82efccfadcb5898f8..cbbaee27bf8230908700da6dd185daf7035f24b6 100644 (file)
@@ -4802,6 +4802,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
        if (!nfs4_sequence_done(task, &data->res.seq_res))
                return;
 
+       trace_nfs4_delegreturn_exit(&data->args, &data->res, task->tk_status);
        switch (task->tk_status) {
        case -NFS4ERR_STALE_STATEID:
        case -NFS4ERR_EXPIRED:
@@ -4905,6 +4906,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
        int err;
        do {
                err = _nfs4_proc_delegreturn(inode, cred, stateid, issync);
+               trace_nfs4_delegreturn(inode, err);
                switch (err) {
                        case -NFS4ERR_STALE_STATEID:
                        case -NFS4ERR_EXPIRED:
index 6388db847017d4eea19921b4d10a2ec5906a4ef7..900f233ee4dc3381d5c1c6183da4248a3cdcf8e3 100644 (file)
@@ -411,6 +411,76 @@ DEFINE_NFS4_LOCK_EVENT(nfs4_lock_reclaim);
 DEFINE_NFS4_LOCK_EVENT(nfs4_lock_expired);
 DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
 
+DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
+               TP_PROTO(
+                       const struct inode *inode,
+                       fmode_t fmode
+               ),
+
+               TP_ARGS(inode, fmode),
+
+               TP_STRUCT__entry(
+                       __field(dev_t, dev)
+                       __field(u32, fhandle)
+                       __field(u64, fileid)
+                       __field(unsigned int, fmode)
+               ),
+
+               TP_fast_assign(
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = NFS_FILEID(inode);
+                       __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
+                       __entry->fmode = (__force unsigned int)fmode;
+               ),
+
+               TP_printk(
+                       "fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
+                       show_fmode_flags(__entry->fmode),
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->fileid,
+                       __entry->fhandle
+               )
+);
+#define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
+       DEFINE_EVENT(nfs4_set_delegation_event, name, \
+                       TP_PROTO( \
+                               const struct inode *inode, \
+                               fmode_t fmode \
+                       ), \
+                       TP_ARGS(inode, fmode))
+DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
+DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
+
+TRACE_EVENT(nfs4_delegreturn_exit,
+               TP_PROTO(
+                       const struct nfs4_delegreturnargs *args,
+                       const struct nfs4_delegreturnres *res,
+                       int error
+               ),
+
+               TP_ARGS(args, res, error),
+
+               TP_STRUCT__entry(
+                       __field(dev_t, dev)
+                       __field(u32, fhandle)
+                       __field(int, error)
+               ),
+
+               TP_fast_assign(
+                       __entry->dev = res->server->s_dev;
+                       __entry->fhandle = nfs_fhandle_hash(args->fhandle);
+                       __entry->error = error;
+               ),
+
+               TP_printk(
+                       "error=%d (%s) dev=%02x:%02x fhandle=0x%08x",
+                       __entry->error,
+                       show_nfsv4_errors(__entry->error),
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       __entry->fhandle
+               )
+);
+
 DECLARE_EVENT_CLASS(nfs4_lookup_event,
                TP_PROTO(
                        const struct inode *dir,
@@ -554,6 +624,8 @@ DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
 DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
 DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
+DEFINE_NFS4_INODE_EVENT(nfs4_recall_delegation);
+DEFINE_NFS4_INODE_EVENT(nfs4_delegreturn);
 
 #endif /* _TRACE_NFS4_H */