# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright 2017 Nexenta Systems, Inc. All rights reserved. # SRCS= smbd-all.d smbd-authsvc.d smbd-doorsvc.d smbd-pipesvc.d \ smbnode.d smbsrv.d smbvfs.d smb-trace.d smb2-trace.d \ nbl-conflict.d include ../../Makefile.cmd ROOTSMBDTRACEDIR = $(ROOTLIB)/smbsrv/dtrace ROOTSMBDTRACEFILE = $(SRCS:%=$(ROOTSMBDTRACEDIR)/%) $(ROOTSMBDTRACEFILE): FILEMODE = 0555 $(ROOTSMBDTRACEDIR): $(INS.dir) $(ROOTSMBDTRACEDIR)/%: % $(INS.file) all: clean: lint: include ../../Makefile.targ install: all $(ROOTSMBDTRACEDIR) .WAIT $(ROOTSMBDTRACEFILE) #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2019 Nexenta Systems, Inc. All rights reserved. */ /* * This dtrace script shows how to track down the owners of locks * that prevent I/O in filesystems with mandatory locking enabled * (eg. ZFS with nbmand=on). This script is not in any way specific * to SMB, but this problem is most often seen when SMB is in use * because SMB requires mandatory locking semantics. * * Run this script, eg. dtrace -s nbl-conflict.d * taking note of these fields in the dtrace output: * conflict_lock: .l_sysid .l_pid * conflict_shrlock: .s_sysid .s_pid * * The sysid values tell you if a local or remote owner has the * lock or share preventing I/O, and the pid tells which process. */ sdt::nbl_lock_conflict:conflict_lock { this->lock = (lock_descriptor_t *)arg0; print(this->lock->l_flock); } sdt::nbl_share_conflict:conflict_shrlock { this->shrl = (struct shrlock *)arg0; print(*(this->shrl)); } /* * The above probe action in nbl_share_conflict shows conflicts * with read/write operations (eg. from the NFS server). * This probe action shows share reservation conflicts at open. * (Remove this if you're only interested in I/O conflicts.) */ sdt::add_share:conflict_shrlock { this->shrl = (struct shrlock *)arg0; print(*(this->shrl)); } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2018 Nexenta Systems, Inc. All rights reserved. */ /* * Example using the "smb" dtrace provider. * Traces all SMB commands. * * All these probes provide: * args[0] conninfo_t * args[1] smbopinfo_t * Some also provide one of: (not used here) * args[2] smb_name_args_t * args[2] smb_open_args_t * args[2] smb_rw_args_t * * Usage: smb-trace.d [|all [|all] []]] * * example: smb_trace.d 192.168.012.001 mypool_fs1 0 * * It is valid to specify or as "all" to * print data for all clients and/or all shares. * Omitting will print data for all zones. */ #pragma D option defaultargs dtrace:::BEGIN { all_clients = (($$1 == NULL) || ($$1 == "all")) ? 1 : 0; all_shares = (($$2 == NULL) || ($$2 == "all")) ? 1 : 0; all_zones = ($$3 == NULL) ? 1 : 0; client = $$1; share = $$2; zoneid = $3; printf("%Y - client=%s share=%s zone=%s)\n", walltimestamp, (all_clients) ? "all" : client, (all_shares) ? "all" : share, (all_zones) ? "all" : $$3); } smb:::op-*-start / ((all_clients) || (args[0]->ci_remote == client)) && ((all_shares) || (args[1]->soi_share == share)) && ((all_zones) || (args[1]->soi_zoneid == zoneid)) / { printf("clnt=%s mid=0x%x uid=0x%x tid=0x%x\n", args[0]->ci_remote, args[1]->soi_mid, args[1]->soi_uid, args[1]->soi_tid); } smb:::op-*-done / ((all_clients) || (args[0]->ci_remote == client)) && ((all_shares) || (args[1]->soi_share == share)) && ((all_zones) || (args[1]->soi_zoneid == zoneid)) / { printf("clnt=%s mid=0x%x status=0x%x\n", args[0]->ci_remote, args[1]->soi_mid, args[1]->soi_status); } dtrace:::END { } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2018 Nexenta Systems, Inc. All rights reserved. */ /* * Example using the "smb2" dtrace provider. * Traces all SMB commands. * * All these probes provide: * args[0] conninfo_t * args[1] smb2opinfo_t * Some also provide one of: (not used here) * args[2] smb_open_args_t * args[2] smb_rw_args_t * * Usage: smb2-trace.d [|all [|all] []]] * * example: smb2_trace.d 192.168.012.001 mypool_fs1 0 * * It is valid to specify or as "all" to * print data for all clients and/or all shares. * Omitting will print data for all zones. */ #pragma D option defaultargs dtrace:::BEGIN { all_clients = (($$1 == NULL) || ($$1 == "all")) ? 1 : 0; all_shares = (($$2 == NULL) || ($$2 == "all")) ? 1 : 0; all_zones = ($$3 == NULL) ? 1 : 0; client = $$1; share = $$2; zoneid = $3; printf("%Y - client=%s share=%s zone=%s)\n", walltimestamp, (all_clients) ? "all" : client, (all_shares) ? "all" : share, (all_zones) ? "all" : $$3); } smb2:::op-*-start / ((all_clients == 1) || (args[0]->ci_remote == client)) && ((all_shares == 1) || (args[1]->soi_share == share)) && ((all_zones == 1) || (args[1]->soi_zoneid == zoneid)) / { printf("clnt=%s mid=0x%x uid=0x%x tid=0x%x\n", args[0]->ci_remote, args[1]->soi_mid, args[1]->soi_uid, args[1]->soi_tid); } smb2:::op-*-done / ((all_clients == 1) || (args[0]->ci_remote == client)) && ((all_shares == 1) || (args[1]->soi_share == share)) && ((all_zones == 1) || (args[1]->soi_zoneid == zoneid)) / { printf("clnt=%s mid=0x%x status=0x%x\n", args[0]->ci_remote, args[1]->soi_mid, args[1]->soi_status); } dtrace:::END { } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2018 Nexenta Systems, Inc. All rights reserved. */ /* * User-level dtrace for smbd. Watch everything it does. * Usage: dtrace -s smbd-all.d -p `pgrep smbd` */ #pragma D option flowindent self int trace; self int mask; /* * Trace everything in smbd */ pid$target:*smbd::entry, pid$target:libmlsvc.so.1::entry, pid$target:libmlrpc.so.2::entry, pid$target:libsmbns.so.1::entry, pid$target:libsmb.so.1::entry, pid$target:libads.so.1::entry { self->trace++; } /* * If traced and not masked, print entry/return */ pid$target:*smbd::entry, pid$target:libmlsvc.so.1::entry, pid$target:libmlrpc.so.2::entry, pid$target:libsmbns.so.1::entry, pid$target:libsmb.so.1::entry, pid$target:libads.so.1::entry /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg0); printf("\t0x%x", arg1); printf("\t0x%x", arg2); printf("\t0x%x", arg3); printf("\t0x%x", arg4); printf("\t0x%x", arg5); } /* * Mask (don't print) all function calls below these functions. * These make many boring, repetitive function calls like * smb_mbtowc, smb_msgbuf_has_space, ... * * Also, libmlrpc has rather deep call stacks, particularly under * ndr_encode_decode_common(), so this stops traces below there. * Remove that from the mask actions to see the details. */ pid$target::ht_findfirst:entry, pid$target::ht_findnext:entry, pid$target::ndr_encode_decode_common:entry, pid$target::smb_msgbuf_decode:entry, pid$target::smb_msgbuf_encode:entry, pid$target::smb_strlwr:entry, pid$target::smb_strupr:entry, pid$target::smb_wcequiv_strlen:entry { self->mask++; } /* * Get some of the smbd debug messages, etc. */ pid$target:libsmb.so.1:smb_trace:entry /self->trace > 0 && self->mask == 0/ { printf("%s", copyinstr(arg0)); } pid$target:libsmb.so.1:smb_syslog:entry /self->trace > 0 && self->mask == 0/ { printf("%s", copyinstr(arg1)); } pid$target:libc_hwcap1.so.1:syslog:entry /self->trace > 0 && self->mask == 0/ { printf("%s", copyinstr(arg1)); } /* * Now inverses of above, unwind order. */ pid$target::ht_findfirst:return, pid$target::ht_findnext:return, pid$target::ndr_encode_decode_common:return, pid$target::smb_msgbuf_decode:return, pid$target::smb_msgbuf_encode:return, pid$target::smb_strlwr:return, pid$target::smb_strupr:return, pid$target::smb_wcequiv_strlen:return { self->mask--; } pid$target:*smbd::return, pid$target:libmlsvc.so.1::return, pid$target:libmlrpc.so.2::return, pid$target:libsmbns.so.1::return, pid$target:libsmb.so.1::return, pid$target:libads.so.1::return /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg1); } pid$target:*smbd::return, pid$target:libmlsvc.so.1::return, pid$target:libmlrpc.so.2::return, pid$target:libsmbns.so.1::return, pid$target:libsmb.so.1::return, pid$target:libads.so.1::return { self->trace--; } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2018 Nexenta Systems, Inc. All rights reserved. */ /* * User-level dtrace for the smbd authentication service * Usage: dtrace -s smbd-authsvc.d -p `pgrep smbd` */ #pragma D option flowindent self int trace; self int mask; /* * The smbd_authsvc_work() function is a good place to start tracing * to watch authentication. This function executes all the actions * associated with a single session setup conversation (even though * that conversation will usually involve multiple SMB requests). */ pid$target:*smbd:smbd_authsvc_work:entry { self->trace++; } /* * If traced and not masked, print entry/return */ pid$target:*smbd::entry, pid$target:libmlsvc.so.1::entry, pid$target:libmlrpc.so.2::entry, pid$target:libsmbns.so.1::entry, pid$target:libsmb.so.1::entry, pid$target:libsmbfs.so.1::entry /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg0); printf("\t0x%x", arg1); printf("\t0x%x", arg2); printf("\t0x%x", arg3); printf("\t0x%x", arg4); printf("\t0x%x", arg5); } /* * Mask (don't print) all function calls below these functions. * These make many boring, repetitive function calls like * smb_mbtowc, smb_msgbuf_has_space, ... * * Also, libmlrpc has rather deep call stacks, particularly under * ndr_encode_decode_common(), so this stops traces below there. * Remove that from the mask actions to see the details. */ pid$target::ndr_encode_decode_common:entry, pid$target::smb_msgbuf_decode:entry, pid$target::smb_msgbuf_encode:entry, pid$target::smb_strlwr:entry, pid$target::smb_strupr:entry, pid$target::smb_wcequiv_strlen:entry { self->mask++; } /* * Now inverses of above, unwind order. */ pid$target::ndr_encode_decode_common:return, pid$target::smb_msgbuf_decode:return, pid$target::smb_msgbuf_encode:return, pid$target::smb_strlwr:return, pid$target::smb_strupr:return, pid$target::smb_wcequiv_strlen:return { self->mask--; } pid$target:*smbd::return, pid$target:libmlsvc.so.1::return, pid$target:libmlrpc.so.2::return, pid$target:libsmbns.so.1::return, pid$target:libsmb.so.1::return, pid$target:libsmbfs.so.1::return /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg1); } pid$target:*smbd:smbd_authsvc_work:return { self->trace--; } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2018 Nexenta Systems, Inc. All rights reserved. */ /* * User-level dtrace for smbd * Usage: dtrace -s smbd-doorsvc.d -p `pgrep smbd` */ #pragma D option flowindent self int trace; self int mask; /* * smbd_door_dispatch_op() is the logical top of smbd door service calls. */ pid$target:*smbd:smbd_door_dispatch_op:entry { self->trace++; } /* * If traced and not masked, print entry/return */ pid$target:*smbd::entry, pid$target:libmlsvc.so.1::entry, pid$target:libmlrpc.so.2::entry, pid$target:libsmbns.so.1::entry, pid$target:libsmb.so.1::entry, pid$target:libsmbfs.so.1::entry /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg0); printf("\t0x%x", arg1); printf("\t0x%x", arg2); printf("\t0x%x", arg3); printf("\t0x%x", arg4); printf("\t0x%x", arg5); } /* * Mask (don't print) all function calls below these functions. * These make many boring, repetitive function calls like * smb_mbtowc, smb_msgbuf_has_space, ... */ pid$target::smb_msgbuf_decode:entry, pid$target::smb_msgbuf_encode:entry, pid$target::smb_strlwr:entry, pid$target::smb_strupr:entry, pid$target::smb_wcequiv_strlen:entry { self->mask++; } /* * Now inverses of above, unwind order. */ pid$target::smb_msgbuf_decode:return, pid$target::smb_msgbuf_encode:return, pid$target::smb_strlwr:return, pid$target::smb_strupr:return, pid$target::smb_wcequiv_strlen:return { self->mask--; } pid$target:*smbd::return, pid$target:libmlsvc.so.1::return, pid$target:libmlrpc.so.2::return, pid$target:libsmbns.so.1::return, pid$target:libsmb.so.1::return, pid$target:libsmbfs.so.1::return /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg1); } pid$target:*smbd:smbd_door_dispatch_op:return { self->trace--; } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2018 Nexenta Systems, Inc. All rights reserved. */ /* * User-level dtrace for smbd * Usage: dtrace -s smbd-pipesvc.d -p `pgrep smbd` */ #pragma D option flowindent self int trace; self int mask; /* * The pipesvc_worker() function is a good place to start tracing * to watch RPC service actions. This worker handles all activity * for a given named pipe instance, including the payload from all * SMB read/write requests on this endpoint. */ pid$target:*smbd:pipesvc_worker:entry { self->trace++; } /* * If traced and not masked, print entry/return */ pid$target:*smbd::entry, pid$target:libmlsvc.so.1::entry, pid$target:libmlrpc.so.2::entry, pid$target:libsmbns.so.1::entry, pid$target:libsmb.so.1::entry /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg0); printf("\t0x%x", arg1); printf("\t0x%x", arg2); printf("\t0x%x", arg3); printf("\t0x%x", arg4); printf("\t0x%x", arg5); } /* * Mask (don't print) all function calls below these functions. * These make many boring, repetitive function calls like * smb_mbtowc, smb_msgbuf_has_space, ... * * Also, libmlrpc has rather deep call stacks, particularly under * ndr_encode_decode_common(), so this stops traces below there. * Remove that from the mask actions to see the details. */ pid$target::ht_findfirst:entry, pid$target::ht_findnext:entry, pid$target::ndr_encode_decode_common:entry, pid$target::smb_msgbuf_decode:entry, pid$target::smb_msgbuf_encode:entry, pid$target::smb_strlwr:entry, pid$target::smb_strupr:entry, pid$target::smb_wcequiv_strlen:entry { self->mask++; } /* * Now inverses of above, unwind order. */ pid$target::ht_findfirst:return, pid$target::ht_findnext:return, pid$target::ndr_encode_decode_common:return, pid$target::smb_msgbuf_decode:return, pid$target::smb_msgbuf_encode:return, pid$target::smb_strlwr:return, pid$target::smb_strupr:return, pid$target::smb_wcequiv_strlen:return { self->mask--; } pid$target:*smbd::return, pid$target:libmlsvc.so.1::return, pid$target:libmlrpc.so.2::return, pid$target:libsmbns.so.1::return, pid$target:libsmb.so.1::return /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg1); } /* * This function in libmlrpc prints out lots of internal state. * Comment it out if you don't want that noise. */ pid$target:libmlrpc.so.2:ndo_trace:entry /self->trace > 0 && self->mask == 0/ { printf("ndo_trace: %s", copyinstr(arg0)); } pid$target:*smbd:pipesvc_worker:return { self->trace--; } #!/usr/sbin/dtrace -qs /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ BEGIN { printf("-->SMB Server Node Trace Started"); printf("\n\n"); } END { printf("<--SMB Server Node Trace Ended"); printf("\n\n"); } sdt:smbsrv:smb_node_lookup:smb_node_lookup_hit /((smb_node_t *)arg0)->n_state == SMB_NODE_STATE_AVAILABLE/ { printf("\nSMB Node lookup hit/SMB_NODE_STATE_AVAILABLE"); printf("\n\tNode: %p", arg0); printf("\n\tRefCnt: %d", ((smb_node_t *)arg0)->n_refcnt); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_lookup:smb_node_lookup_hit /((smb_node_t *)arg0)->n_state == SMB_NODE_STATE_DESTROYING/ { printf("\nSMB Node lookup hit/SMB_NODE_STATE_DESTROYING"); printf("\n\tNode: %p", arg0); printf("\n\tRefCnt: %d", ((smb_node_t *)arg0)->n_refcnt); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_lookup:smb_node_lookup_hit /(((smb_node_t *)arg0)->n_state != SMB_NODE_STATE_DESTROYING) && (((smb_node_t *)arg0)->n_state != SMB_NODE_STATE_AVAILABLE)/ { printf("\nSMB Node lookup hit/Unknown State"); printf("\n\tNode: %p", arg0); printf("\n\tRefCnt: %d", ((smb_node_t *)arg0)->n_refcnt); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_lookup:smb_node_lookup_miss { printf("\nSMB Node lookup miss"); printf("\n\tNode: %p", arg0); printf("\n\tRefCnt: %d", ((smb_node_t *)arg0)->n_refcnt); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_ref:smb_node_ref_exit { printf("\nSMB Node reference taken"); printf("\n\tNode: %p", arg0); printf("\n\tRefCnt: %d", ((smb_node_t *)arg0)->n_refcnt); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_release:smb_node_release /((smb_node_t *)arg0)->n_refcnt == 1/ { printf("\nSMB Node release(will be destroyed)"); printf("\n\tNode: %p", arg0); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_release:smb_node_release /((smb_node_t *)arg0)->n_refcnt > 1/ { printf("\nSMB Node release"); printf("\n\tNode: %p", arg0); printf("\n\tRefCnt: %d", ((smb_node_t *)arg0)->n_refcnt); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg0)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_delete_on_close:smb_node_delete_on_close /(int)arg0 == 0/ { printf("\nSMB Node delete on close successful"); printf("\n\tNode: %p", arg1); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg1)->vp)->v_path); stack(); } sdt:smbsrv:smb_node_delete_on_close:smb_node_delete_on_close /(int)arg0 == 0/ { printf("\nSMB Node delete on close failed (%d)", (int)arg0); printf("\n\tNode: %p", arg1); printf("\n\tName: %s", (string)((vnode_t *)((smb_node_t *)arg1)->vp)->v_path); stack(); } #!/usr/sbin/dtrace -s /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2017 Nexenta Systems, Inc. All rights reserved. */ /* * Developer dtrace program for smbsrv * Usage: dtrace -s smbsrv.d */ self int trace; self int mask; /* * Trace almost everything */ fbt:smbsrv::entry { self->trace++; } /* * If traced and not masked, print entry/return */ fbt:smbsrv::entry /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg0); printf("\t0x%x", arg1); printf("\t0x%x", arg2); printf("\t0x%x", arg3); printf("\t0x%x", arg4); printf("\t0x%x", arg5); } /* * Mask (don't print) all function calls below these functions. * These make many boring, repetitive function calls like * smb_mbtowc, mbc_marshal_... */ fbt::smb_mbc_vdecodef:entry, fbt::smb_mbc_vencodef:entry, fbt::smb_msgbuf_decode:entry, fbt::smb_msgbuf_encode:entry, fbt::smb_strlwr:entry, fbt::smb_strupr:entry, fbt::smb_wcequiv_strlen:entry { self->mask++; } /* * Now inverses of above, unwind order. */ fbt::smb_mbc_vdecodef:return, fbt::smb_mbc_vencodef:return, fbt::smb_msgbuf_decode:return, fbt::smb_msgbuf_encode:return, fbt::smb_strlwr:return, fbt::smb_strupr:return, fbt::smb_wcequiv_strlen:return { self->mask--; } fbt:smbsrv::return /self->trace > 0 && self->mask == 0/ { printf("\t0x%x", arg1); } fbt:smbsrv::return { self->trace--; } /* * Use the "smb", "smb2" dtrace providers. */ smb:::op-*-start, smb2:::op-*-start { printf("clnt=%s mid=0x%x uid=0x%x tid=0x%x\n", args[0]->ci_remote, args[1]->soi_mid, args[1]->soi_uid, args[1]->soi_tid); } smb:::op-*-done, smb2:::op-*-done { printf("clnt=%s mid=0x%x status=0x%x\n", args[0]->ci_remote, args[1]->soi_mid, args[1]->soi_status); } #!/usr/sbin/dtrace -qs /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ BEGIN { printf("\n-->SMB Server VFS Trace Started"); printf("\n\n"); } END { printf("\n<--SMB Server VFS Trace Ended"); printf("\n\n"); } sdt:smbsrv:smb_vfs_hold:smb_vfs_hold_hit { printf("\nSMB VFS lookup hit"); printf("\n Path: %s", (string)((smb_vfs_t *)arg0)->sv_rootvp->v_path); printf("\n RefCount: %d", ((smb_vfs_t *)arg0)->sv_refcnt); } sdt:smbsrv:smb_vfs_hold:smb_vfs_hold_miss { printf("\nSMB VFS lookup miss"); printf("\n Path: %s", (string)((smb_vfs_t *)arg0)->sv_rootvp->v_path); printf("\n RefCount: %d", ((smb_vfs_t *)arg0)->sv_refcnt); } sdt:smbsrv:smb_vfs_rele:smb_vfs_release /(smb_vfs_t *)arg0 != 0/ { printf("\nSMB VFS release hit"); printf("\n Path: %s", (string)((smb_vfs_t *)arg0)->sv_rootvp->v_path); printf("\n RefCount: %d", ((smb_vfs_t *)arg0)->sv_refcnt - 2); } sdt:smbsrv:smb_vfs_rele:smb_vfs_release /(smb_vfs_t *)arg0 == 0/ { printf("\nSMB VFS release miss"); printf("\n Path: %s", (string)((vnode_t *)arg1)->v_path); } sdt:smbsrv:smb_vfs_rele_all:smb_vfs_rele_all_hit { printf("\nSMB VFS free"); printf("\n Path: %s", (string)((smb_vfs_t *)arg0)->sv_rootvp->v_path); printf("\n RefCount: %d", ((smb_vfs_t *)arg0)->sv_refcnt); }