Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
/*	$NetBSD: nfs_clkdtrace.c,v 1.2 2016/11/18 22:58:08 pgoyette Exp $	*/
/*-
 * Copyright (c) 2009 Robert N. M. Watson
 * All rights reserved.
 *
 * This software was developed at the University of Cambridge Computer
 * Laboratory with support from a grant from Google, Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
/* __FBSDID("FreeBSD: head/sys/fs/nfsclient/nfs_clkdtrace.c 298788 2016-04-29 16:07:25Z pfg "); */
__RCSID("$NetBSD: nfs_clkdtrace.c,v 1.2 2016/11/18 22:58:08 pgoyette Exp $");

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>

#if 0
#include <sys/dtrace.h>
#endif

#include <sys/dtrace_bsd.h>

#include <fs/nfs/common/nfsproto.h>

#include <fs/nfs/client/nfs_kdtrace.h>

/*
 * dtnfscl is a DTrace provider that tracks the intent to perform RPCs
 * in the NFS client, as well as access to and maintenance of the access and
 * attribute caches.  This is not quite the same as RPCs, because NFS may
 * issue multiple RPC transactions in the event that authentication fails,
 * there's a jukebox error, or none at all if the access or attribute cache
 * hits.  However, it cleanly represents the logical layer between RPC
 * transmission and vnode/vfs operations, providing access to state linking
 * the two.
 */

static int	dtnfsclient_unload(void);
static void	dtnfsclient_getargdesc(void *, dtrace_id_t, void *,
		    dtrace_argdesc_t *);
static void	dtnfsclient_provide(void *, dtrace_probedesc_t *);
static void	dtnfsclient_destroy(void *, dtrace_id_t, void *);
static void	dtnfsclient_enable(void *, dtrace_id_t, void *);
static void	dtnfsclient_disable(void *, dtrace_id_t, void *);
static void	dtnfsclient_load(void *);

static dtrace_pattr_t dtnfsclient_attr = {
{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON },
{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON },
{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON },
};

/*
 * Description of NFSv4, NFSv3 and (optional) NFSv2 probes for a procedure.
 */
struct dtnfsclient_rpc {
	char		*nr_v4_name;
	char		*nr_v3_name;	/* Or NULL if none. */
	char		*nr_v2_name;	/* Or NULL if none. */

	/*
	 * IDs for the start and done cases, for NFSv2, NFSv3 and NFSv4.
	 */
	uint32_t	 nr_v2_id_start, nr_v2_id_done;
	uint32_t	 nr_v3_id_start, nr_v3_id_done;
	uint32_t	 nr_v4_id_start, nr_v4_id_done;
};

/*
 * This table is indexed by NFSv3 procedure number, but also used for NFSv2
 * procedure names and NFSv4 operations.
 */
static struct dtnfsclient_rpc	dtnfsclient_rpcs[NFSV41_NPROCS + 1] = {
	{ "null", "null", "null" },
	{ "getattr", "getattr", "getattr" },
	{ "setattr", "setattr", "setattr" },
	{ "lookup", "lookup", "lookup" },
	{ "access", "access", "noop" },
	{ "readlink", "readlink", "readlink" },
	{ "read", "read", "read" },
	{ "write", "write", "write" },
	{ "create", "create", "create" },
	{ "mkdir", "mkdir", "mkdir" },
	{ "symlink", "symlink", "symlink" },
	{ "mknod", "mknod" },
	{ "remove", "remove", "remove" },
	{ "rmdir", "rmdir", "rmdir" },
	{ "rename", "rename", "rename" },
	{ "link", "link", "link" },
	{ "readdir", "readdir", "readdir" },
	{ "readdirplus", "readdirplus" },
	{ "fsstat", "fsstat", "statfs" },
	{ "fsinfo", "fsinfo" },
	{ "pathconf", "pathconf" },
	{ "commit", "commit" },
	{ "lookupp" },
	{ "setclientid" },
	{ "setclientidcfrm" },
	{ "lock" },
	{ "locku" },
	{ "open" },
	{ "close" },
	{ "openconfirm" },
	{ "lockt" },
	{ "opendowngrade" },
	{ "renew" },
	{ "putrootfh" },
	{ "releaselckown" },
	{ "delegreturn" },
	{ "retdelegremove" },
	{ "retdelegrename1" },
	{ "retdelegrename2" },
	{ "getacl" },
	{ "setacl" },
	{ "noop", "noop", "noop" }
};

/*
 * Module name strings.
 */
static char	*dtnfsclient_accesscache_str = "accesscache";
static char	*dtnfsclient_attrcache_str = "attrcache";
static char	*dtnfsclient_nfs2_str = "nfs2";
static char	*dtnfsclient_nfs3_str = "nfs3";
static char	*dtnfsclient_nfs4_str = "nfs4";

/*
 * Function name strings.
 */
static char	*dtnfsclient_flush_str = "flush";
static char	*dtnfsclient_load_str = "load";
static char	*dtnfsclient_get_str = "get";

/*
 * Name strings.
 */
static char	*dtnfsclient_done_str = "done";
static char	*dtnfsclient_hit_str = "hit";
static char	*dtnfsclient_miss_str = "miss";
static char	*dtnfsclient_start_str = "start";

static dtrace_pops_t dtnfsclient_pops = {
	dtnfsclient_provide,
	NULL,
	dtnfsclient_enable,
	dtnfsclient_disable,
	NULL,
	NULL,
	dtnfsclient_getargdesc,
	NULL,
	NULL,
	dtnfsclient_destroy
};

static dtrace_provider_id_t	dtnfsclient_id;

/*
 * When tracing on a procedure is enabled, the DTrace ID for an RPC event is
 * stored in one of these two NFS client-allocated arrays; 0 indicates that
 * the event is not being traced so probes should not be called.
 *
 * For simplicity, we allocate both v2, v3 and v4 arrays as NFSV41_NPROCS + 1,
 * and the v2, v3 arrays are simply sparse.
 */
extern uint32_t			nfscl_nfs2_start_probes[NFSV41_NPROCS + 1];
extern uint32_t			nfscl_nfs2_done_probes[NFSV41_NPROCS + 1];

extern uint32_t			nfscl_nfs3_start_probes[NFSV41_NPROCS + 1];
extern uint32_t			nfscl_nfs3_done_probes[NFSV41_NPROCS + 1];

extern uint32_t			nfscl_nfs4_start_probes[NFSV41_NPROCS + 1];
extern uint32_t			nfscl_nfs4_done_probes[NFSV41_NPROCS + 1];

/*
 * Look up a DTrace probe ID to see if it's associated with a "done" event --
 * if so, we will return a fourth argument type of "int".
 */
static int
dtnfs234_isdoneprobe(dtrace_id_t id)
{
	int i;

	for (i = 0; i < NFSV41_NPROCS + 1; i++) {
		if (dtnfsclient_rpcs[i].nr_v4_id_done == id ||
		    dtnfsclient_rpcs[i].nr_v3_id_done == id ||
		    dtnfsclient_rpcs[i].nr_v2_id_done == id)
			return (1);
	}
	return (0);
}

static void
dtnfsclient_getargdesc(void *arg, dtrace_id_t id, void *parg,
    dtrace_argdesc_t *desc)
{
	const char *p = NULL;

	if (id == nfscl_accesscache_flush_done_id ||
	    id == nfscl_attrcache_flush_done_id ||
	    id == nfscl_attrcache_get_miss_id) {
		switch (desc->dtargd_ndx) {
		case 0:
			p = "struct vnode *";
			break;
		default:
			desc->dtargd_ndx = DTRACE_ARGNONE;
			break;
		}
	} else if (id == nfscl_accesscache_get_hit_id ||
	    id == nfscl_accesscache_get_miss_id) {
		switch (desc->dtargd_ndx) {
		case 0:
			p = "struct vnode *";
			break;
		case 1:
			p = "uid_t";
			break;
		case 2:
			p = "uint32_t";
			break;
		default:
			desc->dtargd_ndx = DTRACE_ARGNONE;
			break;
		}
	} else if (id == nfscl_accesscache_load_done_id) {
		switch (desc->dtargd_ndx) {
		case 0:
			p = "struct vnode *";
			break;
		case 1:
			p = "uid_t";
			break;
		case 2:
			p = "uint32_t";
			break;
		case 3:
			p = "int";
			break;
		default:
			desc->dtargd_ndx = DTRACE_ARGNONE;
			break;
		}
	} else if (id == nfscl_attrcache_get_hit_id) {
		switch (desc->dtargd_ndx) {
		case 0:
			p = "struct vnode *";
			break;
		case 1:
			p = "struct vattr *";
			break;
		default:
			desc->dtargd_ndx = DTRACE_ARGNONE;
			break;
		}
	} else if (id == nfscl_attrcache_load_done_id) {
		switch (desc->dtargd_ndx) {
		case 0:
			p = "struct vnode *";
			break;
		case 1:
			p = "struct vattr *";
			break;
		case 2:
			p = "int";
			break;
		default:
			desc->dtargd_ndx = DTRACE_ARGNONE;
			break;
		}
	} else {
		switch (desc->dtargd_ndx) {
		case 0:
			p = "struct vnode *";
			break;
		case 1:
			p = "struct mbuf *";
			break;
		case 2:
			p = "struct ucred *";
			break;
		case 3:
			p = "int";
			break;
		case 4:
			if (dtnfs234_isdoneprobe(id)) {
				p = "int";
				break;
			}
			/* FALLSTHROUGH */
		default:
			desc->dtargd_ndx = DTRACE_ARGNONE;
			break;
		}
	}
	if (p != NULL)
		strlcpy(desc->dtargd_native, p, sizeof(desc->dtargd_native));
}

static void
dtnfsclient_provide(void *arg, dtrace_probedesc_t *desc)
{
	int i;

	if (desc != NULL)
		return;

	/*
	 * Register access cache probes.
	 */
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_accesscache_str,
	    dtnfsclient_flush_str, dtnfsclient_done_str) == 0) {
		nfscl_accesscache_flush_done_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_accesscache_str,
		    dtnfsclient_flush_str, dtnfsclient_done_str, 0, NULL);
	}
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_accesscache_str,
	    dtnfsclient_get_str, dtnfsclient_hit_str) == 0) {
		nfscl_accesscache_get_hit_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_accesscache_str,
		    dtnfsclient_get_str, dtnfsclient_hit_str, 0, NULL);
	}
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_accesscache_str,
	    dtnfsclient_get_str, dtnfsclient_miss_str) == 0) {
		nfscl_accesscache_get_miss_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_accesscache_str,
		    dtnfsclient_get_str, dtnfsclient_miss_str, 0, NULL);
	}
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_accesscache_str,
	    dtnfsclient_load_str, dtnfsclient_done_str) == 0) {
		nfscl_accesscache_load_done_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_accesscache_str,
		    dtnfsclient_load_str, dtnfsclient_done_str, 0, NULL);
	}

	/*
	 * Register attribute cache probes.
	 */
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_attrcache_str,
	    dtnfsclient_flush_str, dtnfsclient_done_str) == 0) {
		nfscl_attrcache_flush_done_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_attrcache_str,
		    dtnfsclient_flush_str, dtnfsclient_done_str, 0, NULL);
	}
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_attrcache_str,
	    dtnfsclient_get_str, dtnfsclient_hit_str) == 0) {
		nfscl_attrcache_get_hit_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_attrcache_str,
		    dtnfsclient_get_str, dtnfsclient_hit_str, 0, NULL);
	}
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_attrcache_str,
	    dtnfsclient_get_str, dtnfsclient_miss_str) == 0) {
		nfscl_attrcache_get_miss_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_attrcache_str,
		    dtnfsclient_get_str, dtnfsclient_miss_str, 0, NULL);
	}
	if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_attrcache_str,
	    dtnfsclient_load_str, dtnfsclient_done_str) == 0) {
		nfscl_attrcache_load_done_id = dtrace_probe_create(
		    dtnfsclient_id, dtnfsclient_attrcache_str,
		    dtnfsclient_load_str, dtnfsclient_done_str, 0, NULL);
	}

	/*
	 * Register NFSv2 RPC procedures; note sparseness check for each slot
	 * in the NFSv3, NFSv4 procnum-indexed array.
	 */
	for (i = 0; i < NFSV41_NPROCS + 1; i++) {
		if (dtnfsclient_rpcs[i].nr_v2_name != NULL &&
		    dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_nfs2_str,
		    dtnfsclient_rpcs[i].nr_v2_name, dtnfsclient_start_str) ==
		    0) {
			dtnfsclient_rpcs[i].nr_v2_id_start =
			    dtrace_probe_create(dtnfsclient_id,
			    dtnfsclient_nfs2_str,
			    dtnfsclient_rpcs[i].nr_v2_name,
			    dtnfsclient_start_str, 0,
			    &nfscl_nfs2_start_probes[i]);
		}
		if (dtnfsclient_rpcs[i].nr_v2_name != NULL &&
		    dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_nfs2_str,
		    dtnfsclient_rpcs[i].nr_v2_name, dtnfsclient_done_str) ==
		    0) {
			dtnfsclient_rpcs[i].nr_v2_id_done = 
			    dtrace_probe_create(dtnfsclient_id,
			    dtnfsclient_nfs2_str,
			    dtnfsclient_rpcs[i].nr_v2_name,
			    dtnfsclient_done_str, 0,
			    &nfscl_nfs2_done_probes[i]);
		}
	}

	/*
	 * Register NFSv3 RPC procedures; note sparseness check for each slot
	 * in the NFSv4 procnum-indexed array.
	 */
	for (i = 0; i < NFSV41_NPROCS + 1; i++) {
		if (dtnfsclient_rpcs[i].nr_v3_name != NULL &&
		    dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_nfs3_str,
		    dtnfsclient_rpcs[i].nr_v3_name, dtnfsclient_start_str) ==
		    0) {
			dtnfsclient_rpcs[i].nr_v3_id_start =
			    dtrace_probe_create(dtnfsclient_id,
			    dtnfsclient_nfs3_str,
			    dtnfsclient_rpcs[i].nr_v3_name,
			    dtnfsclient_start_str, 0,
			    &nfscl_nfs3_start_probes[i]);
		}
		if (dtnfsclient_rpcs[i].nr_v3_name != NULL &&
		    dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_nfs3_str,
		    dtnfsclient_rpcs[i].nr_v3_name, dtnfsclient_done_str) ==
		    0) {
			dtnfsclient_rpcs[i].nr_v3_id_done = 
			    dtrace_probe_create(dtnfsclient_id,
			    dtnfsclient_nfs3_str,
			    dtnfsclient_rpcs[i].nr_v3_name,
			    dtnfsclient_done_str, 0,
			    &nfscl_nfs3_done_probes[i]);
		}
	}

	/*
	 * Register NFSv4 RPC procedures.
	 */
	for (i = 0; i < NFSV41_NPROCS + 1; i++) {
		if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_nfs4_str,
		    dtnfsclient_rpcs[i].nr_v4_name, dtnfsclient_start_str) ==
		    0) {
			dtnfsclient_rpcs[i].nr_v4_id_start =
			    dtrace_probe_create(dtnfsclient_id,
			    dtnfsclient_nfs4_str,
			    dtnfsclient_rpcs[i].nr_v4_name,
			    dtnfsclient_start_str, 0,
			    &nfscl_nfs4_start_probes[i]);
		}
		if (dtrace_probe_lookup(dtnfsclient_id, dtnfsclient_nfs4_str,
		    dtnfsclient_rpcs[i].nr_v4_name, dtnfsclient_done_str) ==
		    0) {
			dtnfsclient_rpcs[i].nr_v4_id_done = 
			    dtrace_probe_create(dtnfsclient_id,
			    dtnfsclient_nfs4_str,
			    dtnfsclient_rpcs[i].nr_v4_name,
			    dtnfsclient_done_str, 0,
			    &nfscl_nfs4_done_probes[i]);
		}
	}
}

static void
dtnfsclient_destroy(void *arg, dtrace_id_t id, void *parg)
{
}

static void
dtnfsclient_enable(void *arg, dtrace_id_t id, void *parg)
{
	uint32_t *p = parg;
	void *f = dtrace_probe;

	if (id == nfscl_accesscache_flush_done_id)
		dtrace_nfscl_accesscache_flush_done_probe = f;
	else if (id == nfscl_accesscache_get_hit_id)
		dtrace_nfscl_accesscache_get_hit_probe = f;
	else if (id == nfscl_accesscache_get_miss_id)
		dtrace_nfscl_accesscache_get_miss_probe = f;
	else if (id == nfscl_accesscache_load_done_id)
		dtrace_nfscl_accesscache_load_done_probe = f;
	else if (id == nfscl_attrcache_flush_done_id)
		dtrace_nfscl_attrcache_flush_done_probe = f;
	else if (id == nfscl_attrcache_get_hit_id)
		dtrace_nfscl_attrcache_get_hit_probe = f;
	else if (id == nfscl_attrcache_get_miss_id)
		dtrace_nfscl_attrcache_get_miss_probe = f;
	else if (id == nfscl_attrcache_load_done_id)
		dtrace_nfscl_attrcache_load_done_probe = f;
	else
		*p = id;
}

static void
dtnfsclient_disable(void *arg, dtrace_id_t id, void *parg)
{
	uint32_t *p = parg;

	if (id == nfscl_accesscache_flush_done_id)
		dtrace_nfscl_accesscache_flush_done_probe = NULL;
	else if (id == nfscl_accesscache_get_hit_id)
		dtrace_nfscl_accesscache_get_hit_probe = NULL;
	else if (id == nfscl_accesscache_get_miss_id)
		dtrace_nfscl_accesscache_get_miss_probe = NULL;
	else if (id == nfscl_accesscache_load_done_id)
		dtrace_nfscl_accesscache_load_done_probe = NULL;
	else if (id == nfscl_attrcache_flush_done_id)
		dtrace_nfscl_attrcache_flush_done_probe = NULL;
	else if (id == nfscl_attrcache_get_hit_id)
		dtrace_nfscl_attrcache_get_hit_probe = NULL;
	else if (id == nfscl_attrcache_get_miss_id)
		dtrace_nfscl_attrcache_get_miss_probe = NULL;
	else if (id == nfscl_attrcache_load_done_id)
		dtrace_nfscl_attrcache_load_done_probe = NULL;
	else
		*p = 0;
}

static void
dtnfsclient_load(void *dummy)
{

	if (dtrace_register("nfscl", &dtnfsclient_attr,
	    DTRACE_PRIV_USER, NULL, &dtnfsclient_pops, NULL,
	    &dtnfsclient_id) != 0)
		return;

	dtrace_nfscl_nfs234_start_probe =
	    (dtrace_nfsclient_nfs23_start_probe_func_t)dtrace_probe;
	dtrace_nfscl_nfs234_done_probe =
	    (dtrace_nfsclient_nfs23_done_probe_func_t)dtrace_probe;
}


static int
dtnfsclient_unload()
{

	dtrace_nfscl_nfs234_start_probe = NULL;
	dtrace_nfscl_nfs234_done_probe = NULL;

	return (dtrace_unregister(dtnfsclient_id));
}

static int
dtnfsclient_modevent(module_t mod __unused, int type, void *data __unused)
{
	int error = 0;

	switch (type) {
	case MOD_LOAD:
		break;

	case MOD_UNLOAD:
		break;

	case MOD_SHUTDOWN:
		break;

	default:
		error = EOPNOTSUPP;
		break;
	}

	return (error);
}

SYSINIT(dtnfsclient_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY,
    dtnfsclient_load, NULL);
SYSUNINIT(dtnfsclient_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY,
    dtnfsclient_unload, NULL);

DEV_MODULE(dtnfscl, dtnfsclient_modevent, NULL);
MODULE_VERSION(dtnfscl, 1);
MODULE_DEPEND(dtnfscl, dtrace, 1, 1, 1);
MODULE_DEPEND(dtnfscl, opensolaris, 1, 1, 1);
MODULE_DEPEND(dtnfscl, nfscl, 1, 1, 1);
MODULE_DEPEND(dtnfscl, nfscommon, 1, 1, 1);