Print this page
NEX-17289 Minimal SMB 3.0.2 support
Reviewed by: Gordon Ross <gordon.ross@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-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-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-5844 want SMB2 ioctl FSCTL_SRV_COPYCHUNK
NEX-6124 smb_fsop_read/write should allow file != sr->fid_ofile
NEX-6125 smbtorture invalid response with smb2.ioctl
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-6041 Should pass the smbtorture lock tests
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
NEX-3662 Backport illumos 1501: taskq_create_proc ... TQ_DYNAMIC puts tasks in p0 (take 2)
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Marcel Telka <marcel.telka@nexenta.com>
NEX-3576 RPC error when displaying open files via Windows MMC
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
NEX-2188 Browsing top level share produces RPC error 1728
SMB-69 read-raw, write-raw are dead code
SMB-39 Use AF_UNIX pipes for RPC
@@ -18,11 +18,11 @@
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
@@ -71,21 +71,19 @@
param->rw_offset = (uint64_t)off_low;
param->rw_count = (uint32_t)count;
param->rw_mincnt = 0;
- DTRACE_SMB_2(op__Read__start, smb_request_t *, sr,
- smb_rw_param_t *, param);
+ DTRACE_SMB_START(op__Read, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_read(smb_request_t *sr)
{
- DTRACE_SMB_2(op__Read__done, smb_request_t *, sr,
- smb_rw_param_t *, sr->arg.rw);
+ DTRACE_SMB_DONE(op__Read, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
@@ -157,30 +155,29 @@
param->rw_offset = (uint64_t)off_low;
param->rw_count = (uint32_t)count;
param->rw_mincnt = 0;
- DTRACE_SMB_2(op__LockAndRead__start, smb_request_t *, sr,
- smb_rw_param_t *, param);
+ DTRACE_SMB_START(op__LockAndRead, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_lock_and_read(smb_request_t *sr)
{
- DTRACE_SMB_2(op__LockAndRead__done, smb_request_t *, sr,
- smb_rw_param_t *, sr->arg.rw);
+ DTRACE_SMB_DONE(op__LockAndRead, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
smb_com_lock_and_read(smb_request_t *sr)
{
smb_rw_param_t *param = sr->arg.rw;
DWORD status;
+ uint32_t lk_pid;
uint16_t count;
int rc;
if (STYPE_ISDSK(sr->tid_tree->t_res_type) == 0) {
smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRDOS, ERRnoaccess);
@@ -193,12 +190,15 @@
return (SDRC_ERROR);
}
sr->user_cr = smb_ofile_getcred(sr->fid_ofile);
+ /* Note: SMB1 locking uses 16-bit PIDs. */
+ lk_pid = sr->smb_pid & 0xFFFF;
+
status = smb_lock_range(sr, param->rw_offset, (uint64_t)param->rw_count,
- 0, SMB_LOCK_TYPE_READWRITE);
+ lk_pid, SMB_LOCK_TYPE_READWRITE, 0);
if (status != NT_STATUS_SUCCESS) {
smb_lock_range_error(sr, status);
return (SDRC_ERROR);
}
@@ -217,10 +217,39 @@
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
/*
+ * The SMB_COM_READ_RAW protocol was a negotiated option introduced in
+ * SMB Core Plus to maximize performance when reading a large block
+ * of data from a server. It's obsolete and no longer supported.
+ *
+ * We keep a handler for it so the dtrace provider can see if
+ * the client tried to use this command.
+ */
+smb_sdrc_t
+smb_pre_read_raw(smb_request_t *sr)
+{
+ DTRACE_SMB_START(op__ReadRaw, smb_request_t *, sr);
+ return (SDRC_SUCCESS);
+}
+
+void
+smb_post_read_raw(smb_request_t *sr)
+{
+ DTRACE_SMB_DONE(op__ReadRaw, smb_request_t *, sr);
+}
+
+smb_sdrc_t
+smb_com_read_raw(smb_request_t *sr)
+{
+ smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, ERRDOS,
+ ERROR_NOT_SUPPORTED);
+ return (SDRC_ERROR);
+}
+
+/*
* Read bytes from a file (SMB Core). This request was extended in
* LM 0.12 to support 64-bit offsets, indicated by sending a wct of
* 12 and including additional offset information.
*
* MS-SMB 3.3.5.7 update to LM 0.12 4.2.4:
@@ -266,21 +295,19 @@
param->rw_count = (uint32_t)maxcnt_low;
}
param->rw_mincnt = 0;
- DTRACE_SMB_2(op__ReadX__start, smb_request_t *, sr,
- smb_rw_param_t *, param);
+ DTRACE_SMB_START(op__ReadX, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_read_andx(smb_request_t *sr)
{
- DTRACE_SMB_2(op__ReadX__done, smb_request_t *, sr,
- smb_rw_param_t *, sr->arg.rw);
+ DTRACE_SMB_DONE(op__ReadX, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
@@ -356,15 +383,12 @@
* Common function for reading files or IPC/MSRPC named pipes. All
* protocol read functions should lookup the fid before calling this
* function. We can't move the fid lookup here because lock-and-read
* requires the fid to do locking before attempting the read.
*
- * Reading from a file should break oplocks on the file to LEVEL_II.
- * A call to smb_oplock_break(SMB_OPLOCK_BREAK_TO_LEVEL_II) is not
- * required as it is a no-op. If there's anything greater than a
- * LEVEL_II oplock on the file, the oplock MUST be owned by the ofile
- * on which the read is occuring and therefore would not be broken.
+ * Reading from a file does not break oplocks because any need for
+ * breaking before read is handled in open.
*
* Returns errno values.
*/
int
smb_common_read(smb_request_t *sr, smb_rw_param_t *param)
@@ -411,11 +435,12 @@
}
sr->raw_data.max_bytes = vdb->vdb_uio.uio_resid;
top = smb_mbuf_allocate(&vdb->vdb_uio);
- rc = smb_fsop_read(sr, sr->user_cr, node, &vdb->vdb_uio);
+ rc = smb_fsop_read(sr, sr->user_cr, node, ofile,
+ &vdb->vdb_uio, 0);
sr->raw_data.max_bytes -= vdb->vdb_uio.uio_resid;
smb_mbuf_trim(top, sr->raw_data.max_bytes);
MBC_ATTACH_MBUF(&sr->raw_data, top);
break;