summaryrefslogtreecommitdiffstats
path: root/tapset/task.stp
blob: 4be41a94d0c24437282eaf62b0eacb05bf90febd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
%{
#include <linux/kernel.h>
#include <linux/ktime.h>
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/svc.h>
%}

function task_dump:string(_task:long)
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	char buf[64];
	int cc=0;

	if (task <= 0) {
		sprintf(buf+cc, "task NULL");
	} else {
		sprintf(buf+cc, ": task 0x%p tk_pid %d tk_status %d", 
			task, task->tk_pid, task->tk_status);
		cc = strlen(buf);
	}
	snprintf(THIS->__retvalue, 64, "%s", buf); 

	CATCH_DEREF_FAULT();
%}
function xprt_dump:string(_task:long)
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_rqst *req;
	struct rpc_xprt *xprt;
	char buf[64];
	int cc=0;

	if (task <= 0) {
		sprintf(buf+cc, "task NULL");
		goto leave;
	}
	req = (struct rpc_rqst *)(long) kread(&(task->tk_rqstp));
	if (req <= 0) {
		sprintf(buf+cc, "req is NULL");
		goto leave;
	}
	xprt = (struct rpc_xprt *)(long) kread(&(req->rq_xprt));
	if (xprt <= 0) {
		sprintf(buf+cc, "xprt is NULL");
		goto leave;
	}
	sprintf(buf+cc, ": xprt 0x%p state 0x%lx", xprt, xprt->state);
	cc = strlen(buf);
leave:
	snprintf(THIS->__retvalue, 64, "%s", buf); 

	CATCH_DEREF_FAULT();
%}
function task_status:long(_task:long)
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));

	THIS->__retvalue = task->tk_status;

	CATCH_DEREF_FAULT();
%}
function task_flags:string(_task:long)
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	char buf[64];
	int cc=0;

	if (task->tk_flags & RPC_TASK_ASYNC) {
		snprintf(buf+cc, 64, "ASYNC");
		cc = strlen(buf);
	}
	snprintf(THIS->__retvalue, 64, "%s", buf); 

	CATCH_DEREF_FAULT();
%}

function cl_prognum:long(_task:long) 
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client));

	THIS->__retvalue = clnt->cl_prog;

	CATCH_DEREF_FAULT();
%}

function cl_vers:long(_task:long) 
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client));

	THIS->__retvalue = clnt->cl_vers;

	CATCH_DEREF_FAULT();
%}
function cl_protname:string(_task:long) 
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_clnt *clnt;
	char *protname = NULL;

	if (task) {
		clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client));
		if (clnt)
			protname = (char *)(long) kread(&(clnt->cl_protname));
	}
	snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", protname);

	CATCH_DEREF_FAULT();
%}

function cl_prog:string(_task:long) 
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_clnt *clnt;
	struct rpc_procinfo *proc;
	char *p_name;
	char buf[64];

	static struct {
		int	prog;
		char *string;
	} prog_progtbl[] = {
		{100000, "rpcbind"},
		{100024, "statd"},
		{100011, "rquotad"},
		{100003, "nfs"},
		{100021, "nlockmgr"},
		{100005, "mountd"},
		{100227, "nfs_acl"},
	};
	int	i;
	int tabsz = (sizeof(prog_progtbl)/sizeof(prog_progtbl[0]));

	if (task <= 0) {
		sprintf(buf, "task NULL");
		goto leave;
	}
	clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client));
	if (clnt == NULL) {
		sprintf(buf, "tk_client NULL");
		goto leave;
	}
	proc = (struct rpc_procinfo *)(long) kread(&(clnt->cl_procinfo));
	if (proc == NULL) {
		sprintf(buf, "cl_procinfo NULL");
		goto leave;
	}
	p_name = kread(&(proc->p_name));

	for (i = 0; i < tabsz; i++) {
		if (prog_progtbl[i].prog == clnt->cl_prog) {
			break;
		}
	}
	if (i == tabsz)
		snprintf(buf, 64, "0x%x[%d]:%d", 
			clnt->cl_prog, clnt->cl_vers, proc->p_proc);
	else
		snprintf(buf, 64, "%s[%d]:%d", 
			prog_progtbl[i].string, clnt->cl_vers, proc->p_proc);

leave:
	snprintf(THIS->__retvalue, 64, "%s", buf); 

	CATCH_DEREF_FAULT();
%}

function cl_server:string(_task:long)
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_clnt *clnt;
	char *cl_server;

	if (task) {
		clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client));
		if (clnt)
			cl_server = kread(&(clnt->cl_server));
	}
	snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", cl_server);

	CATCH_DEREF_FAULT();
%}
function rpc_rtt:long(_task:long)
%{
	struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task));
	struct rpc_rqst *req;
	long rtt = 0;

	if (task) {
		req = (struct rpc_rqst *)(long) kread(&(task->tk_rqstp));
		if (req)
			rtt = ktime_to_ms(req->rq_rtt);
	}

	THIS->__retvalue = rtt;

	CATCH_DEREF_FAULT();
%}
/*
function rpcprocnum:long(_msg:long)
%{
	struct rpc_message *msg = (struct rpc_message *)(long) kread(&(THIS->_msg));
	struct rpc_procinfo *rpc_proc = 
		(struct rpc_procinfo *)(long) kread(&(msg->rpc_proc));

	THIS->__retvalue = rpc_proc->p_proc;

	CATCH_DEREF_FAULT();
%}
function rpcprocname:string(_msg:long)
%{
	struct rpc_message *msg = (struct rpc_message *)(long) kread(&(THIS->_msg));
	struct rpc_procinfo *rpc_proc = 
		(struct rpc_procinfo *)(long) kread(&(msg->rpc_proc));
	char *p_name = kread(&(rpc_proc->p_name));
	char buf[MAXSTRINGLEN];

	snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s(%d)",
		p_name ? p_name : "NULL" , rpc_proc->p_proc);

	CATCH_DEREF_FAULT();
%}
*/