Skip to content

Commit 511ba52

Browse files
chuckleverTrond Myklebust
authored andcommitted
NFS4: Trace state recovery operation
Add a trace point in the main state manager loop to observe state recovery operation. Help track down state recovery bugs. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 4e121fc commit 511ba52

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

fs/nfs/nfs4state.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "nfs4session.h"
6161
#include "pnfs.h"
6262
#include "netns.h"
63+
#include "nfs4trace.h"
6364

6465
#define NFSDBG_FACILITY NFSDBG_STATE
6566

@@ -2539,6 +2540,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
25392540

25402541
/* Ensure exclusive access to NFSv4 state */
25412542
do {
2543+
trace_nfs4_state_mgr(clp);
25422544
clear_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
25432545
if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
25442546
section = "purge state";
@@ -2652,6 +2654,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
26522654
out_error:
26532655
if (strlen(section))
26542656
section_sep = ": ";
2657+
trace_nfs4_state_mgr_failed(clp, section, status);
26552658
pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s"
26562659
" with error %d\n", section_sep, section,
26572660
clp->cl_hostname, -status);

fs/nfs/nfs4trace.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,99 @@ TRACE_EVENT(nfs4_setup_sequence,
562562
)
563563
);
564564

565+
TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_RUNNING);
566+
TRACE_DEFINE_ENUM(NFS4CLNT_CHECK_LEASE);
567+
TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_EXPIRED);
568+
TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_REBOOT);
569+
TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_NOGRACE);
570+
TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN);
571+
TRACE_DEFINE_ENUM(NFS4CLNT_SESSION_RESET);
572+
TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_CONFIRM);
573+
TRACE_DEFINE_ENUM(NFS4CLNT_SERVER_SCOPE_MISMATCH);
574+
TRACE_DEFINE_ENUM(NFS4CLNT_PURGE_STATE);
575+
TRACE_DEFINE_ENUM(NFS4CLNT_BIND_CONN_TO_SESSION);
576+
TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);
577+
TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_MOVED);
578+
TRACE_DEFINE_ENUM(NFS4CLNT_DELEGATION_EXPIRED);
579+
TRACE_DEFINE_ENUM(NFS4CLNT_RUN_MANAGER);
580+
TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN_RUNNING);
581+
582+
#define show_nfs4_clp_state(state) \
583+
__print_flags(state, "|", \
584+
{ NFS4CLNT_MANAGER_RUNNING, "MANAGER_RUNNING" }, \
585+
{ NFS4CLNT_CHECK_LEASE, "CHECK_LEASE" }, \
586+
{ NFS4CLNT_LEASE_EXPIRED, "LEASE_EXPIRED" }, \
587+
{ NFS4CLNT_RECLAIM_REBOOT, "RECLAIM_REBOOT" }, \
588+
{ NFS4CLNT_RECLAIM_NOGRACE, "RECLAIM_NOGRACE" }, \
589+
{ NFS4CLNT_DELEGRETURN, "DELEGRETURN" }, \
590+
{ NFS4CLNT_SESSION_RESET, "SESSION_RESET" }, \
591+
{ NFS4CLNT_LEASE_CONFIRM, "LEASE_CONFIRM" }, \
592+
{ NFS4CLNT_SERVER_SCOPE_MISMATCH, \
593+
"SERVER_SCOPE_MISMATCH" }, \
594+
{ NFS4CLNT_PURGE_STATE, "PURGE_STATE" }, \
595+
{ NFS4CLNT_BIND_CONN_TO_SESSION, \
596+
"BIND_CONN_TO_SESSION" }, \
597+
{ NFS4CLNT_MOVED, "MOVED" }, \
598+
{ NFS4CLNT_LEASE_MOVED, "LEASE_MOVED" }, \
599+
{ NFS4CLNT_DELEGATION_EXPIRED, "DELEGATION_EXPIRED" }, \
600+
{ NFS4CLNT_RUN_MANAGER, "RUN_MANAGER" }, \
601+
{ NFS4CLNT_DELEGRETURN_RUNNING, "DELEGRETURN_RUNNING" })
602+
603+
TRACE_EVENT(nfs4_state_mgr,
604+
TP_PROTO(
605+
const struct nfs_client *clp
606+
),
607+
608+
TP_ARGS(clp),
609+
610+
TP_STRUCT__entry(
611+
__field(unsigned long, state)
612+
__string(hostname, clp->cl_hostname)
613+
),
614+
615+
TP_fast_assign(
616+
__entry->state = clp->cl_state;
617+
__assign_str(hostname, clp->cl_hostname)
618+
),
619+
620+
TP_printk(
621+
"hostname=%s clp state=%s", __get_str(hostname),
622+
show_nfs4_clp_state(__entry->state)
623+
)
624+
)
625+
626+
TRACE_EVENT(nfs4_state_mgr_failed,
627+
TP_PROTO(
628+
const struct nfs_client *clp,
629+
const char *section,
630+
int status
631+
),
632+
633+
TP_ARGS(clp, section, status),
634+
635+
TP_STRUCT__entry(
636+
__field(unsigned long, error)
637+
__field(unsigned long, state)
638+
__string(hostname, clp->cl_hostname)
639+
__string(section, section)
640+
),
641+
642+
TP_fast_assign(
643+
__entry->error = status;
644+
__entry->state = clp->cl_state;
645+
__assign_str(hostname, clp->cl_hostname);
646+
__assign_str(section, section);
647+
),
648+
649+
TP_printk(
650+
"hostname=%s clp state=%s error=%ld (%s) section=%s",
651+
__get_str(hostname),
652+
show_nfs4_clp_state(__entry->state), -__entry->error,
653+
show_nfsv4_errors(__entry->error), __get_str(section)
654+
655+
)
656+
)
657+
565658
TRACE_EVENT(nfs4_xdr_status,
566659
TP_PROTO(
567660
const struct xdr_stream *xdr,

0 commit comments

Comments
 (0)