Print this page
NEX-4820 intended nbmand locking functionality is confused
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-9808 SMB3 persistent handles
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5665 SMB2 oplock leases
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-9808 SMB3 persistent handles
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5665 SMB2 oplock leases
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-72 Improve startup/shudown debug features
SMB-50 User-mode SMB server
Includes work by these authors:
Thomas Keiser <thomas.keiser@nexenta.com>
Albert Lee <trisk@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/smbsrv/libfksmbsrv/common/fksmb_init.c
+++ new/usr/src/lib/smbsrv/libfksmbsrv/common/fksmb_init.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 - * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
23 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/ddi.h>
28 28 #include <sys/modctl.h>
29 29 #include <sys/cred.h>
30 30 #include <sys/disp.h>
31 31 #include <sys/ioccom.h>
32 32 #include <sys/policy.h>
33 33 #include <sys/cmn_err.h>
34 34 #include <smbsrv/smb_kproto.h>
35 35 #include <smbsrv/smb_ioctl.h>
36 36
37 37 /*
38 38 * *****************************************************************************
39 39 * ****************************** Global Variables *****************************
40 40 * *****************************************************************************
41 41 *
|
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
42 42 * These variables can only be changed through the /etc/system file.
43 43 */
44 44
45 45 /*
46 46 * Maximum buffer size for NT: configurable based on the client environment.
47 47 * IR104720 Experiments with Windows 2000 indicate that we achieve better
48 48 * SmbWriteX performance with a buffer size of 64KB instead of the 37KB used
49 49 * with Windows NT4.0. Previous experiments with NT4.0 resulted in directory
50 50 * listing problems so this buffer size is configurable based on the end-user
51 51 * environment. When in doubt use 37KB.
52 - *
53 - * smb_raw_mode: read_raw and write_raw supported (1) or NOT supported (0).
54 52 */
55 53 int smb_maxbufsize = SMB_NT_MAXBUF;
56 -int smb_oplock_levelII = 1;
57 -int smb_oplock_timeout = OPLOCK_STD_TIMEOUT;
58 -int smb_oplock_min_timeout = OPLOCK_MIN_TIMEOUT;
59 54 int smb_flush_required = 1;
60 55 int smb_dirsymlink_enable = 1;
61 56 int smb_sign_debug = 0;
62 -int smb_raw_mode = 0;
63 57 int smb_shortnames = 1;
64 58 uint_t smb_audit_flags =
65 59 #ifdef DEBUG
66 60 SMB_AUDIT_NODE;
67 61 #else
68 62 0;
69 63 #endif
70 64
71 65 /*
66 + * We don't normally have nbmand support in the test share
67 + * used by fksmbd, but we'd still like the locking code
68 + * to be testable. Intereactions with NFS etc. are not a
69 + * concern in fksmbd, so allow it to use advisory locks.
70 + *
71 + * Should fix the fksmbd test share so it supports nbmand,
72 + * and then set this to zero like the real server.
73 + */
74 +int smb_allow_advisory_locks = 1; /* See smb_vops.c */
75 +
76 +/*
72 77 * Maximum number of simultaneous authentication, share mapping, pipe open
73 78 * requests to be processed.
74 79 */
75 80 int smb_ssetup_threshold = 256;
76 81 int smb_tcon_threshold = 1024;
77 82 int smb_opipe_threshold = 1024;
78 83
79 84 /*
80 85 * Number of milliseconds that a request will be stalled if it comes in after
81 86 * the maximum number of inflight operations are being proccessed.
82 87 */
83 88 int smb_ssetup_timeout = (30 * 1000);
84 89 int smb_tcon_timeout = (30 * 1000);
85 90 int smb_opipe_timeout = (30 * 1000);
86 91
87 92 int smb_threshold_debug = 0;
88 93
89 94 /*
90 95 * Thread priorities used in smbsrv. Our threads spend most of their time
91 96 * blocked on various conditions. However, if the system gets heavy load,
92 97 * the scheduler has to choose an order to run these. We want the order:
93 98 * (a) timers, (b) notifications, (c) workers, (d) receivers (and etc.)
94 99 * where notifications are oplock and change notify work. Aside from this
95 100 * relative ordering, smbsrv threads should run with a priority close to
96 101 * that of normal user-space threads (thus minclsyspri below), just like
97 102 * NFS and other "file service" kinds of processing.
98 103 */
99 104 int smbsrv_base_pri = MINCLSYSPRI;
100 105 int smbsrv_listen_pri = MINCLSYSPRI;
101 106 int smbsrv_receive_pri = MINCLSYSPRI;
102 107 int smbsrv_worker_pri = MINCLSYSPRI + 1;
103 108 int smbsrv_notify_pri = MINCLSYSPRI + 2;
104 109 int smbsrv_timer_pri = MINCLSYSPRI + 5;
105 110
106 111 /*
107 112 * These are the (open,close,ioctl) entry points into this
108 113 * (fake) "driver". They are declared in smb_ioctl.h
109 114 */
110 115
111 116 static int g_init_done = 0;
112 117
113 118 int fksmbsrv_vfs_init(void);
114 119
115 120 int
116 121 fksmbsrv_drv_open(void)
117 122 {
118 123 int rc;
119 124
120 125 if (g_init_done == 0) {
121 126 if ((rc = fksmbsrv_vfs_init()) != 0) {
122 127 cmn_err(CE_WARN, "fksmbsrv_vfs_init, rc=%d", rc);
123 128 return (rc);
124 129 }
125 130 if ((rc = smb_server_g_init()) != 0) {
126 131 cmn_err(CE_WARN, "smb_server_g_init, rc=%d", rc);
127 132 return (rc);
128 133 }
|
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
129 134 g_init_done = 1;
130 135 }
131 136
132 137 rc = smb_server_create();
133 138 return (rc);
134 139 }
135 140
136 141 int
137 142 fksmbsrv_drv_close(void)
138 143 {
144 + smb_server_t *sv;
139 145 int rc;
140 146
141 - rc = smb_server_delete();
147 + rc = smb_server_lookup(&sv);
148 + if (rc == 0)
149 + rc = smb_server_delete(sv);
142 150
143 151 if (g_init_done != 0) {
144 152 smb_server_g_fini();
145 153 g_init_done = 0;
146 154 }
147 155
148 156 return (rc);
149 157 }
150 158
151 159 /*
152 160 * This is the primary entry point into this library, called by
153 161 * fksmbd (user-level debug version of smbsrv).
154 162 */
155 163 int
156 164 fksmbsrv_drv_ioctl(int cmd, void *varg)
157 165 {
158 166 smb_ioc_t *ioc = varg;
159 167 int rc = 0;
160 168
161 169 switch (cmd) {
162 170 case SMB_IOC_CONFIG:
163 171 rc = smb_server_configure(&ioc->ioc_cfg);
164 172 break;
165 173 case SMB_IOC_START:
166 174 rc = smb_server_start(&ioc->ioc_start);
167 175 break;
168 176 case SMB_IOC_STOP:
169 177 rc = smb_server_stop();
170 178 break;
171 179 case SMB_IOC_EVENT:
172 180 rc = smb_server_notify_event(&ioc->ioc_event);
173 181 break;
174 182 case SMB_IOC_GMTOFF:
175 183 rc = smb_server_set_gmtoff(&ioc->ioc_gmt);
176 184 break;
177 185 case SMB_IOC_SHARE:
178 186 rc = smb_kshare_export_list(&ioc->ioc_share);
179 187 break;
180 188 case SMB_IOC_UNSHARE:
181 189 rc = smb_kshare_unexport_list(&ioc->ioc_share);
182 190 break;
183 191 case SMB_IOC_SHAREINFO:
184 192 rc = smb_kshare_info(&ioc->ioc_shareinfo);
185 193 break;
186 194 case SMB_IOC_NUMOPEN:
187 195 rc = smb_server_numopen(&ioc->ioc_opennum);
188 196 break;
189 197 case SMB_IOC_SVCENUM:
190 198 rc = smb_server_enum(&ioc->ioc_svcenum);
191 199 break;
192 200 case SMB_IOC_SESSION_CLOSE:
193 201 rc = smb_server_session_close(&ioc->ioc_session);
194 202 break;
195 203 case SMB_IOC_FILE_CLOSE:
196 204 rc = smb_server_file_close(&ioc->ioc_fileid);
197 205 break;
198 206 case SMB_IOC_SPOOLDOC:
199 207 rc = smb_server_spooldoc(&ioc->ioc_spooldoc);
200 208 break;
201 209 default:
202 210 rc = ENOTTY;
203 211 break;
204 212 }
205 213
206 214 return (rc);
207 215 }
208 216
209 217 /*
210 218 * This function intentionally does nothing. It's used only to
211 219 * force libfksmbsrv to load when fksmbd starts so one can set
212 220 * breakpoints etc. without debugger "force load" tricks.
213 221 */
214 222 void
215 223 fksmbsrv_drv_load(void)
216 224 {
217 225 }
|
↓ open down ↓ |
66 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX