xref: /openbsd-src/sys/nfs/nfs_debug.c (revision 564dba153ad58a54537fe1a69624950a6a705de2)
1*564dba15Sjsg /*	$OpenBSD: nfs_debug.c,v 1.7 2024/05/01 13:15:59 jsg Exp $ */
2cecbdfb6Sthib /*
3cecbdfb6Sthib  * Copyright (c) 2009 Thordur I. Bjornsson. <thib@openbsd.org>
4cecbdfb6Sthib  *
5cecbdfb6Sthib  * Permission to use, copy, modify, and distribute this software for any
6cecbdfb6Sthib  * purpose with or without fee is hereby granted, provided that the above
7cecbdfb6Sthib  * copyright notice and this permission notice appear in all copies.
8cecbdfb6Sthib  *
9cecbdfb6Sthib  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10cecbdfb6Sthib  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11cecbdfb6Sthib  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12cecbdfb6Sthib  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13cecbdfb6Sthib  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14cecbdfb6Sthib  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15cecbdfb6Sthib  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16cecbdfb6Sthib  */
17cecbdfb6Sthib #include <sys/param.h>
18cecbdfb6Sthib #include <sys/systm.h>
19cecbdfb6Sthib #include <sys/mount.h>
20bfe91d83Sthib #include <sys/pool.h>
21bfe91d83Sthib #include <sys/vnode.h>
22cecbdfb6Sthib 
23cecbdfb6Sthib #include <nfs/nfsproto.h>
24cecbdfb6Sthib #include <nfs/nfs.h>
25bfe91d83Sthib #include <nfs/nfsnode.h>
26cecbdfb6Sthib 
27cecbdfb6Sthib #include <machine/db_machdep.h>
28cecbdfb6Sthib #include <ddb/db_interface.h>
29cecbdfb6Sthib #include <ddb/db_output.h>
30cecbdfb6Sthib 
31cecbdfb6Sthib void
db_show_all_nfsreqs(db_expr_t expr,int haddr,db_expr_t count,char * modif)32cecbdfb6Sthib db_show_all_nfsreqs(db_expr_t expr, int haddr, db_expr_t count, char *modif)
33cecbdfb6Sthib {
345430ff35Stedu 	int full = 0;
35cecbdfb6Sthib 
36bfe91d83Sthib 	if (modif[0] == 'f')
375430ff35Stedu 		full = 1;
38cecbdfb6Sthib 
39bfe91d83Sthib 	pool_walk(&nfsreqpl, full, db_printf, nfs_request_print);
40cecbdfb6Sthib }
41cecbdfb6Sthib 
42cecbdfb6Sthib void
nfs_request_print(void * v,int full,int (* pr)(const char *,...))43bfe91d83Sthib nfs_request_print(void *v, int full, int (*pr)(const char *, ...))
44cecbdfb6Sthib {
45bfe91d83Sthib 	struct nfsreq	*rep = v;
46bfe91d83Sthib 
47cecbdfb6Sthib 	(*pr)("xid 0x%x flags 0x%x rexmit %i procnum %i proc %p\n",
48cecbdfb6Sthib 	    rep->r_xid, rep->r_flags, rep->r_rexmit, rep->r_procnum,
49cecbdfb6Sthib 	    rep->r_procp);
50cecbdfb6Sthib 
51cecbdfb6Sthib 	if (full) {
52cecbdfb6Sthib 		(*pr)("mreq %p mrep %p md %p nfsmount %p vnode %p timer %i",
53cecbdfb6Sthib 		    " rtt %i\n",
54cecbdfb6Sthib 		    rep->r_mreq, rep->r_mrep, rep->r_md, rep->r_nmp,
55cecbdfb6Sthib 		    rep->r_vp, rep->r_timer, rep->r_rtt);
56cecbdfb6Sthib 	}
57cecbdfb6Sthib }
58bfe91d83Sthib 
59bfe91d83Sthib void
db_show_all_nfsnodes(db_expr_t expr,int haddr,db_expr_t count,char * modif)60bfe91d83Sthib db_show_all_nfsnodes(db_expr_t expr, int haddr, db_expr_t count, char *modif)
61bfe91d83Sthib {
625430ff35Stedu 	int full = 0;
63bfe91d83Sthib 
64bfe91d83Sthib 	if (modif[0] == 'f')
655430ff35Stedu 		full = 1;
66bfe91d83Sthib 
67bfe91d83Sthib 	pool_walk(&nfs_node_pool, full, db_printf, nfs_node_print);
68bfe91d83Sthib }
69bfe91d83Sthib 
70bfe91d83Sthib 
71bfe91d83Sthib 
72bfe91d83Sthib void
nfs_node_print(void * v,int full,int (* pr)(const char *,...))73bfe91d83Sthib nfs_node_print(void *v, int full, int (*pr)(const char *, ...))
74bfe91d83Sthib {
75bfe91d83Sthib 	struct nfsnode	*np = v;
76bfe91d83Sthib 
771b9beab9Sguenther 	(*pr)("size %llu flag %i vnode %p accstamp %lld\n",
781b9beab9Sguenther 	    np->n_size, np->n_flag, np->n_vnode, (long long)np->n_accstamp);
79bfe91d83Sthib 
80bfe91d83Sthib 	if (full) {
81bfe91d83Sthib 		(*pr)("pushedlo %llu pushedhi %llu pushlo %llu pushhi %llu\n",
82bfe91d83Sthib 		    np->n_pushedlo, np->n_pushedhi, np->n_pushlo,
83bfe91d83Sthib 		    np->n_pushhi);
84bfe91d83Sthib 		(*pr)("commitflags %i\n", np->n_commitflags);
85bfe91d83Sthib 	}
86bfe91d83Sthib }
87