--- old/usr/src/uts/common/fs/zfs/sys/arc.h	Mon Aug  5 17:26:56 2019
+++ new/usr/src/uts/common/fs/zfs/sys/arc.h	Mon Aug  5 17:26:56 2019
@@ -22,6 +22,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  */
 
 #ifndef	_SYS_ARC_H
@@ -33,6 +34,7 @@
 extern "C" {
 #endif
 
+#include <sys/kreplication_common.h>
 #include <sys/zio.h>
 #include <sys/dmu.h>
 #include <sys/spa.h>
@@ -90,7 +92,15 @@
 	ARC_FLAG_L2_WRITING		= 1 << 11,	/* write in progress */
 	ARC_FLAG_L2_EVICTED		= 1 << 12,	/* evicted during I/O */
 	ARC_FLAG_L2_WRITE_HEAD		= 1 << 13,	/* head of write list */
-	/* indicates that the buffer contains metadata (otherwise, data) */
+
+	/*
+	 * Below BUFC flags indicate that either the buffer contains
+	 * metadata or DDT metadata. If both of these are not set then the
+	 * buffer contains data.
+	 * ARC_FLAG_BUFC_DDT is only used when zfs_arc_segregate_ddt is true.
+	 * If this tunable is zero ARC_FLAG_BUFC_METADATA is used for both DDT
+	 * and regular metadata.
+	 */
 	ARC_FLAG_BUFC_METADATA		= 1 << 14,
 
 	/* Flags specifying whether optional hdr struct fields are defined */
@@ -105,6 +115,8 @@
 	ARC_FLAG_COMPRESSED_ARC		= 1 << 17,
 	ARC_FLAG_SHARED_DATA		= 1 << 18,
 
+	ARC_FLAG_BUFC_DDT		= 1 << 19,	/* DDT buf */
+
 	/*
 	 * The arc buffer's compression mode is stored in the top 7 bits of the
 	 * flags field, so these dummy flags are included so that MDB can
@@ -117,7 +129,6 @@
 	ARC_FLAG_COMPRESS_4		= 1 << 28,
 	ARC_FLAG_COMPRESS_5		= 1 << 29,
 	ARC_FLAG_COMPRESS_6		= 1 << 30
-
 } arc_flags_t;
 
 typedef enum arc_buf_flags {
@@ -137,6 +148,7 @@
 	ARC_BUFC_INVALID,			/* invalid type */
 	ARC_BUFC_DATA,				/* buffer contains data */
 	ARC_BUFC_METADATA,			/* buffer contains metadata */
+	ARC_BUFC_DDT,				/* buffer contains ddt */
 	ARC_BUFC_NUMTYPES
 } arc_buf_contents_t;
 
@@ -146,6 +158,7 @@
 typedef enum arc_space_type {
 	ARC_SPACE_DATA,
 	ARC_SPACE_META,
+	ARC_SPACE_DDT,
 	ARC_SPACE_HDRS,
 	ARC_SPACE_L2HDRS,
 	ARC_SPACE_OTHER,
@@ -152,6 +165,18 @@
 	ARC_SPACE_NUMTYPES
 } arc_space_type_t;
 
+/* see spa_misc.c and zio_ddt_write() */
+extern uint64_t zfs_ddt_byte_ceiling;
+typedef enum zfs_ddt_limit {
+	DDT_NO_LIMIT = 0,
+	DDT_LIMIT_TO_ARC = 1,
+	DDT_LIMIT_TO_L2ARC = 2,
+} zfs_ddt_limit_t;
+extern zfs_ddt_limit_t zfs_ddt_limit_type;
+extern boolean_t zfs_arc_segregate_ddt;
+extern uint64_t const * arc_ddt_evict_threshold;
+
+
 void arc_space_consume(uint64_t space, arc_space_type_t type);
 void arc_space_return(uint64_t space, arc_space_type_t type);
 boolean_t arc_is_metadata(arc_buf_t *buf);
@@ -169,6 +194,7 @@
 void arc_buf_destroy(arc_buf_t *buf, void *tag);
 int arc_buf_size(arc_buf_t *buf);
 int arc_buf_lsize(arc_buf_t *buf);
+void arc_buf_access(arc_buf_t *buf);
 void arc_release(arc_buf_t *buf, void *tag);
 int arc_released(arc_buf_t *buf);
 void arc_buf_freeze(arc_buf_t *buf);
@@ -177,6 +203,8 @@
 int arc_referenced(arc_buf_t *buf);
 #endif
 
+int arc_io_bypass(spa_t *spa, const blkptr_t *bp,
+    arc_bypass_io_func func, void *arg);
 int arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
     arc_done_func_t *done, void *private, zio_priority_t priority, int flags,
     arc_flags_t *arc_flags, const zbookmark_phys_t *zb);
@@ -185,7 +213,7 @@
     arc_done_func_t *ready, arc_done_func_t *child_ready,
     arc_done_func_t *physdone, arc_done_func_t *done,
     void *private, zio_priority_t priority, int zio_flags,
-    const zbookmark_phys_t *zb);
+    const zbookmark_phys_t *zb, const zio_smartcomp_info_t *smartcomp);
 void arc_freed(spa_t *spa, const blkptr_t *bp);
 
 void arc_flush(spa_t *spa, boolean_t retry);
@@ -200,7 +228,7 @@
  * Level 2 ARC
  */
 
-void l2arc_add_vdev(spa_t *spa, vdev_t *vd);
+void l2arc_add_vdev(spa_t *spa, vdev_t *vd, boolean_t rebuild);
 void l2arc_remove_vdev(vdev_t *vd);
 boolean_t l2arc_vdev_present(vdev_t *vd);
 void l2arc_init(void);
@@ -207,6 +235,7 @@
 void l2arc_fini(void);
 void l2arc_start(void);
 void l2arc_stop(void);
+void l2arc_spa_rebuild_start(spa_t *spa);
 
 #ifndef _KERNEL
 extern boolean_t arc_watch;
