xref: /openbsd-src/sys/nfs/nfs_debug.c (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: nfs_debug.c,v 1.2 2009/01/18 13:57:17 thib Exp $ */
2 /*
3  * Copyright (c) 2009 Thordur I. Bjornsson. <thib@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 #include <sys/param.h>
18 #include <sys/systm.h>
19 #include <sys/proc.h>
20 #include <sys/mount.h>
21 #include <sys/kernel.h>
22 #include <sys/queue.h>
23 
24 #include <nfs/rpcv2.h>
25 #include <nfs/nfsproto.h>
26 #include <nfs/nfs.h>
27 
28 #include <machine/db_machdep.h>
29 #include <ddb/db_interface.h>
30 #include <ddb/db_output.h>
31 
32 extern struct nfsreqhead nfs_reqq;
33 
34 void
35 db_show_all_nfsreqs(db_expr_t expr, int haddr, db_expr_t count, char *modif)
36 {
37 	struct nfsreq	*rep;
38 
39 	if (TAILQ_EMPTY(&nfs_reqq)) {
40 		db_printf("no outstanding requests\n");
41 		return;
42 	}
43 
44 	TAILQ_FOREACH(rep, &nfs_reqq, r_chain)
45 		db_printf("%p\n", rep);
46 
47 }
48 
49 void
50 db_nfsreq_print(struct nfsreq *rep, int full, int (*pr)(const char *, ...))
51 {
52 	(*pr)("xid 0x%x flags 0x%x rexmit %i procnum %i proc %p\n",
53 	    rep->r_xid, rep->r_flags, rep->r_rexmit, rep->r_procnum,
54 	    rep->r_procp);
55 
56 	if (full) {
57 		(*pr)("mreq %p mrep %p md %p nfsmount %p vnode %p timer %i",
58 		    " rtt %i\n",
59 		    rep->r_mreq, rep->r_mrep, rep->r_md, rep->r_nmp,
60 		    rep->r_vp, rep->r_timer, rep->r_rtt);
61 	}
62 }
63