Print this page
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-9864 Some SMB cancel races remain after NEX-5845
Revert (part of) "NEX-5845 rework SMB immediate cancel"
reverts (part of) commit 7a5da69f6d42b17ebcc95ca3d02925d07a01343e.
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5845 rework SMB immediate cancel
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
NEX-5152 immediate SMB cancel may fail
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
re #13470 rb4432 Sync some SMB differences from illumos
re #11215 rb3676 sesctl to SGI JBOD hangs in biowait() with a command stuck in mptsas driver
re #10734 NT Trans. Notify returning too quickly
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/smbsrv/smb_nt_cancel.c
+++ new/usr/src/uts/common/fs/smbsrv/smb_nt_cancel.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 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
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 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 - * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
24 + *
25 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
25 26 */
26 27
27 28 /*
28 29 * SMB: nt_cancel
29 30 *
30 31 * This SMB allows a client to cancel a request currently pending at the
31 32 * server.
32 33 *
33 34 * Client Request Description
34 35 * ================================== =================================
35 36 *
36 37 * UCHAR WordCount; No words are sent (== 0)
37 38 * USHORT ByteCount; No bytes (==0)
38 39 *
39 40 * The Sid, Uid, Pid, Tid, and Mid fields of the SMB are used to locate an
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
40 41 * pending server request from this session. If a pending request is
41 42 * found, it is "hurried along" which may result in success or failure of
42 43 * the original request. No other response is generated for this SMB.
43 44 */
44 45
45 46 #include <smbsrv/smb_kproto.h>
46 47
47 48 smb_sdrc_t
48 49 smb_pre_nt_cancel(smb_request_t *sr)
49 50 {
50 - DTRACE_SMB_1(op__NtCancel__start, smb_request_t *, sr);
51 + DTRACE_SMB_START(op__NtCancel, smb_request_t *, sr);
51 52 return (SDRC_SUCCESS);
52 53 }
53 54
54 55 void
55 56 smb_post_nt_cancel(smb_request_t *sr)
56 57 {
57 - DTRACE_SMB_1(op__NtCancel__done, smb_request_t *, sr);
58 + DTRACE_SMB_DONE(op__NtCancel, smb_request_t *, sr);
58 59 }
59 60
61 +/*
62 + * Dispatch handler for SMB_COM_NT_CANCEL.
63 + * Note that Cancel does NOT get a response.
64 + *
65 + * SMB NT Cancel has an inherent race with the request being
66 + * cancelled. See comments at smb_request_cancel().
67 + */
60 68 smb_sdrc_t
61 69 smb_com_nt_cancel(smb_request_t *sr)
62 70 {
63 71 struct smb_request *req;
64 72 struct smb_session *session;
73 + int cnt = 0;
65 74
66 75 session = sr->session;
67 76
68 77 smb_slist_enter(&session->s_req_list);
69 78 req = smb_slist_head(&session->s_req_list);
70 79 while (req) {
71 80 ASSERT(req->sr_magic == SMB_REQ_MAGIC);
72 81 if ((req != sr) &&
73 82 (req->smb_uid == sr->smb_uid) &&
74 83 (req->smb_pid == sr->smb_pid) &&
75 84 (req->smb_tid == sr->smb_tid) &&
76 85 (req->smb_mid == sr->smb_mid)) {
77 86 smb_request_cancel(req);
87 + cnt++;
78 88 }
79 89 req = smb_slist_next(&session->s_req_list, req);
80 90 }
91 + if (cnt != 1) {
92 + DTRACE_PROBE2(smb__ntcancel__error,
93 + uint16_t, sr->smb_mid, int, cnt);
94 + }
81 95 smb_slist_exit(&session->s_req_list);
82 96
83 97 return (SDRC_NO_REPLY);
98 +}
99 +
100 +/*
101 + * This handles an SMB_COM_NT_CANCEL request when seen in the reader.
102 + * (See smb1sr_newrq) Handle this immediately, rather than
103 + * going through the normal taskq dispatch mechanism.
104 + * Note that Cancel does NOT get a response.
105 + */
106 +int
107 +smb1sr_newrq_cancel(smb_request_t *sr)
108 +{
109 + (void) smb_pre_nt_cancel(sr);
110 + (void) smb_com_nt_cancel(sr);
111 + smb_post_nt_cancel(sr);
112 + return (0);
84 113 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX