nfsd: add trace events
For now just a few simple events to trace the layout stateid lifetime, but
these already were enough to find several bugs in the Linux client layout
stateid handling.
Signed-off-by: Christoph Hellwig <hch@lst.de>
diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
index d926865..60137c5 100644
--- a/fs/nfsd/nfs4layouts.c
+++ b/fs/nfsd/nfs4layouts.c
@@ -9,6 +9,7 @@
#include "pnfs.h"
#include "netns.h"
+#include "trace.h"
#define NFSDDBG_FACILITY NFSDDBG_PNFS
@@ -125,6 +126,8 @@
struct nfs4_client *clp = ls->ls_stid.sc_client;
struct nfs4_file *fp = ls->ls_stid.sc_file;
+ trace_layoutstate_free(&ls->ls_stid.sc_stateid);
+
spin_lock(&clp->cl_lock);
list_del_init(&ls->ls_perclnt);
spin_unlock(&clp->cl_lock);
@@ -215,6 +218,7 @@
list_add(&ls->ls_perfile, &fp->fi_lo_states);
spin_unlock(&fp->fi_lock);
+ trace_layoutstate_alloc(&ls->ls_stid.sc_stateid);
return ls;
}
@@ -280,6 +284,8 @@
if (list_empty(&ls->ls_layouts))
goto out_unlock;
+ trace_layout_recall(&ls->ls_stid.sc_stateid);
+
atomic_inc(&ls->ls_stid.sc_count);
update_stateid(&ls->ls_stid.sc_stateid);
memcpy(&ls->ls_recall_sid, &ls->ls_stid.sc_stateid, sizeof(stateid_t));
@@ -454,8 +460,10 @@
nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lrp->lr_sid,
false, lrp->lr_layout_type,
&ls);
- if (nfserr)
+ if (nfserr) {
+ trace_layout_return_lookup_fail(&lrp->lr_sid);
return nfserr;
+ }
spin_lock(&ls->ls_lock);
list_for_each_entry_safe(lp, n, &ls->ls_layouts, lo_perstate) {
@@ -472,6 +480,7 @@
}
lrp->lrs_present = 1;
} else {
+ trace_layoutstate_unhash(&ls->ls_stid.sc_stateid);
nfs4_unhash_stid(&ls->ls_stid);
lrp->lrs_present = 0;
}
@@ -570,6 +579,8 @@
rpc_ntop((struct sockaddr *)&clp->cl_addr, addr_str, sizeof(addr_str));
+ nfsd4_cb_layout_fail(ls);
+
printk(KERN_WARNING
"nfsd: client %s failed to respond to layout recall. "
" Fencing..\n", addr_str);
@@ -597,6 +608,7 @@
case 0:
return 1;
case -NFS4ERR_NOMATCHING_LAYOUT:
+ trace_layout_recall_done(&ls->ls_stid.sc_stateid);
task->tk_status = 0;
return 1;
case -NFS4ERR_DELAY:
@@ -624,6 +636,8 @@
container_of(cb, struct nfs4_layout_stateid, ls_recall);
LIST_HEAD(reaplist);
+ trace_layout_recall_release(&ls->ls_stid.sc_stateid);
+
nfsd4_return_all_layouts(ls, &reaplist);
nfsd4_free_layouts(&reaplist);
nfs4_put_stid(&ls->ls_stid);