--- old/usr/src/uts/common/fs/smbsrv/smb_write.c	Fri Mar 31 14:29:44 2017
+++ new/usr/src/uts/common/fs/smbsrv/smb_write.c	Fri Mar 31 14:29:44 2017
@@ -61,8 +61,7 @@
 	param->rw_offset = (uint64_t)off;
 	param->rw_vdb.vdb_uio.uio_loffset = (offset_t)param->rw_offset;
 
-	DTRACE_SMB_2(op__Write__start, smb_request_t *, sr,
-	    smb_rw_param_t *, param);
+	DTRACE_SMB_1(op__Write__start, smb_request_t *, sr); /* arg.rw */
 
 	return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 }
@@ -70,8 +69,7 @@
 void
 smb_post_write(smb_request_t *sr)
 {
-	DTRACE_SMB_2(op__Write__done, smb_request_t *, sr,
-	    smb_rw_param_t *, sr->arg.rw);
+	DTRACE_SMB_1(op__Write__done, smb_request_t *, sr); /* arg.rw */
 
 	kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 }
@@ -151,8 +149,7 @@
 	param->rw_count = (uint32_t)count;
 	param->rw_offset = (uint64_t)off;
 
-	DTRACE_SMB_2(op__WriteAndClose__start, smb_request_t *, sr,
-	    smb_rw_param_t *, param);
+	DTRACE_SMB_1(op__WriteAndClose__start, smb_request_t *, sr); /* arg.rw */
 
 	return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 }
@@ -160,8 +157,7 @@
 void
 smb_post_write_and_close(smb_request_t *sr)
 {
-	DTRACE_SMB_2(op__WriteAndClose__done, smb_request_t *, sr,
-	    smb_rw_param_t *, sr->arg.rw);
+	DTRACE_SMB_1(op__WriteAndClose__done, smb_request_t *, sr); /* arg.rw */
 
 	kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 }
@@ -249,8 +245,7 @@
 	param->rw_count = (uint32_t)count;
 	param->rw_offset = (uint64_t)off;
 
-	DTRACE_SMB_2(op__WriteAndUnlock__start, smb_request_t *, sr,
-	    smb_rw_param_t *, param);
+	DTRACE_SMB_1(op__WriteAndUnlock__start, smb_request_t *, sr); /* arg.rw */
 
 	return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 }
@@ -258,8 +253,7 @@
 void
 smb_post_write_and_unlock(smb_request_t *sr)
 {
-	DTRACE_SMB_2(op__WriteAndUnlock__done, smb_request_t *, sr,
-	    smb_rw_param_t *, sr->arg.rw);
+	DTRACE_SMB_1(op__WriteAndUnlock__done, smb_request_t *, sr); /* arg.rw */
 
 	kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 }
@@ -325,6 +319,66 @@
 }
 
 /*
+ * The SMB_COM_WRITE_RAW protocol was a negotiated option introduced in
+ * SMB Core Plus to maximize performance when writing a large block
+ * of data to 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_write_raw(smb_request_t *sr)
+{
+	smb_rw_param_t *param;
+	uint32_t off_low;
+	uint32_t timeout;
+	uint32_t off_high;
+	uint16_t datalen;
+	uint16_t total;
+	int rc;
+
+	param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
+	sr->arg.rw = param;
+
+	if (sr->smb_wct == 12) {
+		rc = smbsr_decode_vwv(sr, "ww2.llw4.ww", &sr->smb_fid, &total,
+		    &off_low, &timeout, &param->rw_mode, &datalen,
+		    &param->rw_dsoff);
+
+		param->rw_offset = (uint64_t)off_low;
+	} else {
+		rc = smbsr_decode_vwv(sr, "ww2.llw4.wwl", &sr->smb_fid, &total,
+		    &off_low, &timeout, &param->rw_mode, &datalen,
+		    &param->rw_dsoff, &off_high);
+
+		param->rw_offset = ((uint64_t)off_high << 32) | off_low;
+	}
+
+	param->rw_count = (uint32_t)datalen;
+	param->rw_total = (uint32_t)total;
+
+	DTRACE_SMB_1(op__WriteRaw__start, smb_request_t *, sr); /* arg.rw */
+
+	return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
+}
+
+void
+smb_post_write_raw(smb_request_t *sr)
+{
+	DTRACE_SMB_1(op__WriteRaw__done, smb_request_t *, sr); /* arg.rw */
+
+	kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
+}
+
+smb_sdrc_t
+smb_com_write_raw(struct smb_request *sr)
+{
+	smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, ERRDOS,
+	    ERROR_NOT_SUPPORTED);
+	return (SDRC_ERROR);
+}
+
+/*
  * Write bytes to a file (SMB Core).  This request was extended in
  * LM 0.12 to support 64-bit offsets, indicated by sending a wct of
  * 14, instead of 12, and including additional offset information.
@@ -387,8 +441,7 @@
 	    (sr->smb_data.max_bytes > (sr->smb_data.chain_offset + 0xFFFF)))
 		param->rw_count |= ((uint32_t)datalen_high << 16);
 
-	DTRACE_SMB_2(op__WriteX__start, smb_request_t *, sr,
-	    smb_rw_param_t *, param);
+	DTRACE_SMB_1(op__WriteX__start, smb_request_t *, sr); /* arg.rw */
 
 	return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 }
@@ -396,8 +449,7 @@
 void
 smb_post_write_andx(smb_request_t *sr)
 {
-	DTRACE_SMB_2(op__WriteX__done, smb_request_t *, sr,
-	    smb_rw_param_t *, sr->arg.rw);
+	DTRACE_SMB_1(op__WriteX__done, smb_request_t *, sr); /* arg.rw */
 
 	kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 }
