Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: trond.myklebust@fys.uio.no
Cc: nfs@lists.sourceforge.net
Subject: [PATCH 15/15] SUNRPC: Debugging aid
Date: Wed, 24 Jan 2007 14:20:26 -0500	[thread overview]
Message-ID: <20070124192026.31133.27374.stgit@localhost.localdomain> (raw)
In-Reply-To: <20070124191704.31133.12713.stgit@localhost.localdomain>

Add helper functions for tracking the current FSM state for each RPC task.
The FSM state name is now displayed in rpc_show_task instead of the
absolute address of the FSM function.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 include/linux/sunrpc/sched.h |   13 ++++++++++++-
 net/sunrpc/clnt.c            |   35 ++++++++++++++++++++++++++++++++++-
 net/sunrpc/sched.c           |   11 ++++++++---
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 88e6e39..7732e80 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -95,7 +95,8 @@ #endif
 	long			tk_rtt;		/* round-trip time (jiffies) */
 
 #ifdef RPC_DEBUG
-	unsigned short		tk_pid;		/* debugging aid */
+	unsigned short		tk_pid;
+	const char *		tk_action_name;
 #endif
 };
 #define tk_auth			tk_client->cl_auth
@@ -292,6 +293,16 @@ static inline const char * rpc_qname(str
 {
 	return ((q && q->name) ? q->name : "unknown");
 }
+
+#define __rpc_new_task_state(t, n)				\
+	do {							\
+		t->tk_action_name = n ;				\
+	} while (0)
+#else
+#define __rpc_new_task_state(t, n)	do { } while (0)
 #endif
 
+#define rpc_new_task_state()					\
+	__rpc_new_task_state(task, __FUNCTION__)
+
 #endif /* _LINUX_SUNRPC_SCHED_H_ */
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index e885ae5..423c905 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -42,7 +42,7 @@ #endif
 
 #define dprint_status(t)					\
 	dprintk("RPC: %5u %s (status %d)\n", t->tk_pid,		\
-			__FUNCTION__, t->tk_status)
+			__FUNCTION__, t->tk_status)		\
 
 static DECLARE_WAIT_QUEUE_HEAD(destroy_wait);
 
@@ -554,6 +554,8 @@ out_release:
 void
 rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags)
 {
+	rpc_new_task_state();
+
 	task->tk_msg   = *msg;
 	task->tk_flags |= flags;
 	/* Bind the user cred */
@@ -664,6 +666,8 @@ call_start(struct rpc_task *task)
 {
 	struct rpc_clnt	*clnt = task->tk_client;
 
+	rpc_new_task_state();
+
 	dprintk("RPC: %5u call_start %s%d proc %d (%s)\n", task->tk_pid,
 			clnt->cl_protname, clnt->cl_vers,
 			task->tk_msg.rpc_proc->p_proc,
@@ -681,6 +685,8 @@ call_start(struct rpc_task *task)
 static void
 call_reserve(struct rpc_task *task)
 {
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	if (!rpcauth_uptodatecred(task)) {
@@ -701,6 +707,8 @@ call_reserveresult(struct rpc_task *task
 {
 	int status = task->tk_status;
 
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	/*
@@ -756,6 +764,8 @@ call_allocate(struct rpc_task *task)
 	struct rpc_xprt *xprt = task->tk_xprt;
 	struct rpc_procinfo *proc = task->tk_msg.rpc_proc;
 
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	task->tk_status = 0;
@@ -868,6 +878,8 @@ call_bind(struct rpc_task *task)
 {
 	struct rpc_xprt *xprt = task->tk_xprt;
 
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	task->tk_action = call_connect;
@@ -886,6 +898,8 @@ call_bind_status(struct rpc_task *task)
 {
 	int status = -EACCES;
 
+	rpc_new_task_state();
+
 	if (task->tk_status >= 0) {
 		dprint_status(task);
 		task->tk_status = 0;
@@ -934,6 +948,8 @@ call_connect(struct rpc_task *task)
 {
 	struct rpc_xprt *xprt = task->tk_xprt;
 
+	rpc_new_task_state();
+
 	dprintk("RPC: %5u call_connect xprt %p %s connected\n",
 			task->tk_pid, xprt,
 			(xprt_connected(xprt) ? "is" : "is not"));
@@ -956,6 +972,8 @@ call_connect_status(struct rpc_task *tas
 	struct rpc_clnt *clnt = task->tk_client;
 	int status = task->tk_status;
 
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	task->tk_status = 0;
@@ -988,6 +1006,8 @@ call_connect_status(struct rpc_task *tas
 static void
 call_transmit(struct rpc_task *task)
 {
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	task->tk_action = call_status;
@@ -1025,7 +1045,10 @@ call_transmit(struct rpc_task *task)
 static void
 call_transmit_status(struct rpc_task *task)
 {
+	rpc_new_task_state();
+
 	task->tk_action = call_status;
+
 	/*
 	 * Special case: if we've been waiting on the socket's write_space()
 	 * callback, then don't call xprt_end_transmit().
@@ -1046,6 +1069,8 @@ call_status(struct rpc_task *task)
 	struct rpc_rqst	*req = task->tk_rqstp;
 	int		status;
 
+	rpc_new_task_state();
+
 	if (req->rq_received > 0 && !req->rq_bytes_sent)
 		task->tk_status = req->rq_received;
 
@@ -1099,6 +1124,8 @@ call_timeout(struct rpc_task *task)
 {
 	struct rpc_clnt	*clnt = task->tk_client;
 
+	rpc_new_task_state();
+
 	if (xprt_adjust_timeout(task->tk_rqstp) == 0) {
 		dprintk("RPC: %5u call_timeout (minor)\n", task->tk_pid);
 		goto retry;
@@ -1138,6 +1165,8 @@ call_decode(struct rpc_task *task)
 	kxdrproc_t	decode = task->tk_msg.rpc_proc->p_decode;
 	__be32		*p;
 
+	rpc_new_task_state();
+
 	dprintk("RPC: %5u call_decode (status %d)\n",
 			task->tk_pid, task->tk_status);
 
@@ -1200,6 +1229,8 @@ out_retry:
 static void
 call_refresh(struct rpc_task *task)
 {
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	xprt_release(task);	/* Must do to obtain new XID */
@@ -1217,6 +1248,8 @@ call_refreshresult(struct rpc_task *task
 {
 	int status = task->tk_status;
 
+	rpc_new_task_state();
+
 	dprint_status(task);
 
 	task->tk_status = 0;
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index c689196..b712317 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -590,6 +590,8 @@ void rpc_delay(struct rpc_task *task, un
  */
 static void rpc_prepare_task(struct rpc_task *task)
 {
+	rpc_new_task_state();
+
 	lock_kernel();
 	task->tk_ops->rpc_call_prepare(task, task->tk_calldata);
 	unlock_kernel();
@@ -602,6 +604,7 @@ void rpc_exit_task(struct rpc_task *task
 {
 	task->tk_action = NULL;
 	if (task->tk_ops->rpc_call_done != NULL) {
+		rpc_new_task_state();
 		lock_kernel();
 		task->tk_ops->rpc_call_done(task, task->tk_calldata);
 		unlock_kernel();
@@ -611,6 +614,7 @@ void rpc_exit_task(struct rpc_task *task
 			xprt_release(task);
 		}
 	}
+	__rpc_new_task_state(task, "done");
 }
 EXPORT_SYMBOL(rpc_exit_task);
 
@@ -785,6 +789,7 @@ void rpc_free(struct rpc_task *task, voi
 void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *tk_ops, void *calldata)
 {
 	memset(task, 0, sizeof(*task));
+	rpc_new_task_state();
 	init_timer(&task->tk_timer);
 	task->tk_timer.data     = (unsigned long) task;
 	task->tk_timer.function = (void (*)(unsigned long)) rpc_run_timer;
@@ -1059,14 +1064,14 @@ void rpc_show_tasks(void)
 		return;
 	}
 	printk("-pid- proc flgs status -client- -prog- --rqstp- -timeout "
-		"-rpcwait -action- ---ops--\n");
+		"---rpcwait-- ---ops-- -----action----- \n");
 	alltask_for_each(t, le, &all_tasks) {
 		const char *rpc_waitq = "none";
 
 		if (RPC_IS_QUEUED(t))
 			rpc_waitq = rpc_qname(t->u.tk_wait.rpc_waitq);
 
-		printk("%5u %04d %04x %6d %8p %6d %8p %8ld %8s %8p %8p\n",
+		printk("%5u %04d %04x %6d %8p %6d %8p %8ld %12.12s %8p %16.16s\n",
 			t->tk_pid,
 			(t->tk_msg.rpc_proc ? t->tk_msg.rpc_proc->p_proc : -1),
 			t->tk_flags, t->tk_status,
@@ -1074,7 +1079,7 @@ void rpc_show_tasks(void)
 			(t->tk_client ? t->tk_client->cl_prog : 0),
 			t->tk_rqstp, t->tk_timeout,
 			rpc_waitq,
-			t->tk_action, t->tk_ops);
+			t->tk_ops, t->tk_action_name);
 	}
 	spin_unlock(&rpc_sched_lock);
 }

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

      parent reply	other threads:[~2007-01-24 19:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-24 19:17 [PATCH 00/15] patches for 2.6.21 Chuck Lever
2007-01-24 19:19 ` [PATCH 01/15] NFS: fix print format for tk_pid Chuck Lever
2007-01-24 19:19 ` [PATCH 02/15] SUNRPC: fix print format for tk_pid in auth_gss support Chuck Lever
2007-01-24 19:19 ` [PATCH 03/15] SUNRPC: fix print format for tk_pid Chuck Lever
2007-01-24 19:19 ` [PATCH 04/15] SUNRPC: Eliminate side effects from rpc_malloc Chuck Lever
2007-01-24 19:19 ` [PATCH 05/15] SUNRPC: Make rpc_free API more generic Chuck Lever
2007-01-24 19:19 ` [PATCH 06/15] NFS: disconnect before retrying NFSv4 requests over TCP Chuck Lever
2007-01-24 19:20 ` [PATCH 07/15] SUNRPC: introduce rpcbind: replacement for in-kernel portmapper Chuck Lever
2007-01-24 19:20 ` [PATCH 08/15] SUNRPC: switch socket-based RPC transports to use rpcbind Chuck Lever
2007-01-24 19:20 ` [PATCH 09/15] SUNRPC: switch the RPC server to use the new rpcbind registration API Chuck Lever
2007-01-24 19:20 ` [PATCH 10/15] NFS: switch NFSROOT to use new rpcbind client Chuck Lever
2007-01-24 19:20 ` [PATCH 11/15] SUNRPC: remove old portmapper Chuck Lever
2007-01-24 19:20 ` [PATCH 12/15] SUNRPC: RPC client should retry with different versions of rpcbind Chuck Lever
2007-01-24 19:20 ` [PATCH 13/15] SUNRPC: RPC buffer size estimates are too large Chuck Lever
2007-01-24 20:37   ` J. Bruce Fields
2007-01-24 20:41     ` Chuck Lever
2007-01-24 20:51       ` J. Bruce Fields
2007-01-24 21:09         ` Chuck Lever
2007-01-24 21:25           ` J. Bruce Fields
2007-01-24 21:28             ` Chuck Lever
2007-01-24 20:47   ` J. Bruce Fields
2007-01-24 20:50     ` Chuck Lever
2007-01-24 21:01       ` J. Bruce Fields
2007-01-24 21:11         ` Chuck Lever
2007-01-24 19:20 ` [PATCH 14/15] NLM: Shrink the maximum request size of NLM4 requests Chuck Lever
2007-01-24 19:20 ` Chuck Lever [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070124192026.31133.27374.stgit@localhost.localdomain \
    --to=chuck.lever@oracle.com \
    --cc=nfs@lists.sourceforge.net \
    --cc=trond.myklebust@fys.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox