xref: /illumos-gate/usr/src/cmd/smbsrv/dtrace/nbl-conflict.d (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 #!/usr/sbin/dtrace -s
2 
3 /*
4  * This file and its contents are supplied under the terms of the
5  * Common Development and Distribution License ("CDDL"), version 1.0.
6  * You may only use this file in accordance with the terms of version
7  * 1.0 of the CDDL.
8  *
9  * A full copy of the text of the CDDL should have accompanied this
10  * source.  A copy of the CDDL is also available via the Internet at
11  * http://www.illumos.org/license/CDDL.
12  */
13 
14 /*
15  * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
16  */
17 
18 /*
19  * This dtrace script shows how to track down the owners of locks
20  * that prevent I/O in filesystems with mandatory locking enabled
21  * (eg. ZFS with nbmand=on).  This script is not in any way specific
22  * to SMB, but this problem is most often seen when SMB is in use
23  * because SMB requires mandatory locking semantics.
24  *
25  * Run this script, eg. dtrace -s nbl-conflict.d
26  * taking note of these fields in the dtrace output:
27  *	conflict_lock:  .l_sysid .l_pid
28  *	conflict_shrlock: .s_sysid .s_pid
29  *
30  * The sysid values tell you if a local or remote owner has the
31  * lock or share preventing I/O, and the pid tells which process.
32  */
33 
34 sdt::nbl_lock_conflict:conflict_lock
35 {
36 	this->lock = (lock_descriptor_t *)arg0;
37 	print(this->lock->l_flock);
38 }
39 
40 sdt::nbl_share_conflict:conflict_shrlock
41 {
42 	this->shrl = (struct shrlock *)arg0;
43 	print(*(this->shrl));
44 }
45 
46 /*
47  * The above probe action in nbl_share_conflict shows conflicts
48  * with read/write operations (eg. from the NFS server).
49  * This probe action shows share reservation conflicts at open.
50  * (Remove this if you're only interested in I/O conflicts.)
51  */
52 sdt::add_share:conflict_shrlock
53 {
54 	this->shrl = (struct shrlock *)arg0;
55 	print(*(this->shrl));
56 }
57