6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2016 Syneto S.R.L. All rights reserved.
26 */
27
28 /*
29 * The flush SMB is sent to ensure all data and allocation information
30 * for the corresponding file has been written to stable storage. This
31 * is a synchronous request. The response should not be sent until the
32 * writes are complete.
33 *
34 * The SmbFlush request is described in CIFS/1.0 1996 Section 3.9.14.
35 *
36 * CIFS/1.0 June 13, 1996
37 * Heizer, et al
38 * draft-heizer-cifs-v1-spec-00.txt
39 */
40
41 #include <smbsrv/smb_kproto.h>
42 #include <smbsrv/smb_fsops.h>
43
44
45 /*
46 * smb_com_flush
47 *
48 * Flush any cached data for a specified file, or for all files that
49 * this client has open, to stable storage. If the fid is valid (i.e.
50 * not 0xFFFF), we flush only that file. Otherwise we flush all files
51 * associated with this client.
52 *
53 * We need to protect the list because there's a good chance we'll
54 * block during the flush operation.
55 */
56 smb_sdrc_t
57 smb_pre_flush(smb_request_t *sr)
58 {
59 int rc;
60
61 rc = smbsr_decode_vwv(sr, "w", &sr->smb_fid);
62
63 DTRACE_SMB_1(op__Flush__start, smb_request_t *, sr);
64
65 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
66 }
67
68 void
69 smb_post_flush(smb_request_t *sr)
70 {
71 DTRACE_SMB_1(op__Flush__done, smb_request_t *, sr);
72 }
73
74 smb_sdrc_t
75 smb_com_flush(smb_request_t *sr)
76 {
77 smb_ofile_t *file;
78 smb_llist_t *flist;
79 int rc;
80
81 if (smb_flush_required == 0) {
82 rc = smbsr_encode_empty_result(sr);
83 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
84 }
85
86 if (sr->smb_fid != 0xffff) {
87 smbsr_lookup_file(sr);
88 if (sr->fid_ofile == NULL) {
89 smbsr_error(sr, NT_STATUS_INVALID_HANDLE,
90 ERRDOS, ERRbadfid);
91 return (SDRC_ERROR);
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2016 Syneto S.R.L. All rights reserved.
26 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 /*
30 * The flush SMB is sent to ensure all data and allocation information
31 * for the corresponding file has been written to stable storage. This
32 * is a synchronous request. The response should not be sent until the
33 * writes are complete.
34 *
35 * The SmbFlush request is described in CIFS/1.0 1996 Section 3.9.14.
36 *
37 * CIFS/1.0 June 13, 1996
38 * Heizer, et al
39 * draft-heizer-cifs-v1-spec-00.txt
40 */
41
42 #include <smbsrv/smb_kproto.h>
43 #include <smbsrv/smb_fsops.h>
44
45
46 /*
47 * smb_com_flush
48 *
49 * Flush any cached data for a specified file, or for all files that
50 * this client has open, to stable storage. If the fid is valid (i.e.
51 * not 0xFFFF), we flush only that file. Otherwise we flush all files
52 * associated with this client.
53 *
54 * We need to protect the list because there's a good chance we'll
55 * block during the flush operation.
56 */
57 smb_sdrc_t
58 smb_pre_flush(smb_request_t *sr)
59 {
60 int rc;
61
62 rc = smbsr_decode_vwv(sr, "w", &sr->smb_fid);
63
64 DTRACE_SMB_START(op__Flush, smb_request_t *, sr);
65
66 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
67 }
68
69 void
70 smb_post_flush(smb_request_t *sr)
71 {
72 DTRACE_SMB_DONE(op__Flush, smb_request_t *, sr);
73 }
74
75 smb_sdrc_t
76 smb_com_flush(smb_request_t *sr)
77 {
78 smb_ofile_t *file;
79 smb_llist_t *flist;
80 int rc;
81
82 if (smb_flush_required == 0) {
83 rc = smbsr_encode_empty_result(sr);
84 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
85 }
86
87 if (sr->smb_fid != 0xffff) {
88 smbsr_lookup_file(sr);
89 if (sr->fid_ofile == NULL) {
90 smbsr_error(sr, NT_STATUS_INVALID_HANDLE,
91 ERRDOS, ERRbadfid);
92 return (SDRC_ERROR);
|