--- old/usr/src/uts/common/sys/fs/zfs.h	Mon Aug  5 17:36:15 2019
+++ new/usr/src/uts/common/sys/fs/zfs.h	Mon Aug  5 17:36:15 2019
@@ -22,7 +22,8 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright (c) 2013, Saso Kiselkov. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
  * Copyright 2017 Joyent, Inc.
  * Copyright (c) 2017 Datto Inc.
@@ -52,7 +53,10 @@
 	ZFS_TYPE_SNAPSHOT	= (1 << 1),
 	ZFS_TYPE_VOLUME		= (1 << 2),
 	ZFS_TYPE_POOL		= (1 << 3),
-	ZFS_TYPE_BOOKMARK	= (1 << 4)
+	ZFS_TYPE_BOOKMARK	= (1 << 4),
+	ZFS_TYPE_VDEV		= (1 << 5),
+	ZFS_TYPE_COS		= (1 << 6),
+	ZFS_TYPE_AUTOSNAP	= (1 << 7)
 } zfs_type_t;
 
 /*
@@ -70,7 +74,8 @@
 } dmu_objset_type_t;
 
 #define	ZFS_TYPE_DATASET	\
-	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
+	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME |\
+    ZFS_TYPE_SNAPSHOT | ZFS_TYPE_AUTOSNAP)
 
 /*
  * All of these include the terminating NUL byte.
@@ -87,8 +92,7 @@
  * the property table in usr/src/common/zfs/zfs_prop.c.
  */
 typedef enum {
-	ZPROP_CONT = -2,
-	ZPROP_INVAL = -1,
+	ZFS_PROP_BAD = -1,
 	ZFS_PROP_TYPE = 0,
 	ZFS_PROP_CREATION,
 	ZFS_PROP_USED,
@@ -160,8 +164,13 @@
 	ZFS_PROP_SNAPSHOT_COUNT,
 	ZFS_PROP_REDUNDANT_METADATA,
 	ZFS_PROP_PREV_SNAP,
+	ZFS_PROP_LSTXG,
+	ZFS_PROP_ZPL_META_TO_METADEV,
+	ZFS_PROP_WBC_MODE,
 	ZFS_PROP_RECEIVE_RESUME_TOKEN,
-	ZFS_PROP_REMAPTXG,		/* not exposed to the user */
+	ZFS_PROP_SMARTCOMPRESSION,
+	ZFS_PROP_RATE_LIMIT,
+	ZFS_PROP_MODIFIED,
 	ZFS_NUM_PROPS
 } zfs_prop_t;
 
@@ -180,9 +189,12 @@
  * end of this list to ensure that external consumers are not affected
  * by the change. If you make any changes to this list, be sure to update
  * the property table in usr/src/common/zfs/zpool_prop.c.
+ *
+ * NOTE: When either adding or changing a feature make sure
+ * to update the zfs-tests zpool_get configuration file
+ * at usr/src/test/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg
  */
 typedef enum {
-	ZPOOL_PROP_INVAL = -1,
 	ZPOOL_PROP_NAME,
 	ZPOOL_PROP_SIZE,
 	ZPOOL_PROP_CAPACITY,
@@ -199,6 +211,7 @@
 	ZPOOL_PROP_AUTOEXPAND,
 	ZPOOL_PROP_DEDUPDITTO,
 	ZPOOL_PROP_DEDUPRATIO,
+	ZPOOL_PROP_DDTCAPPED,
 	ZPOOL_PROP_FREE,
 	ZPOOL_PROP_ALLOCATED,
 	ZPOOL_PROP_READONLY,
@@ -208,13 +221,97 @@
 	ZPOOL_PROP_FRAGMENTATION,
 	ZPOOL_PROP_LEAKED,
 	ZPOOL_PROP_MAXBLOCKSIZE,
+	ZPOOL_PROP_ENABLESPECIAL,
+	ZPOOL_PROP_LOWATERMARK,
+	ZPOOL_PROP_HIWATERMARK,
+	ZPOOL_PROP_DEDUPMETA_DITTO,
+	ZPOOL_PROP_DDT_DESEGREGATION,
+	ZPOOL_PROP_META_PLACEMENT,
+	ZPOOL_PROP_DDT_META_TO_METADEV,
+	ZPOOL_PROP_ZFS_META_TO_METADEV,
+	ZPOOL_PROP_DEDUP_BEST_EFFORT,
+	ZPOOL_PROP_DEDUP_LO_BEST_EFFORT,
+	ZPOOL_PROP_DEDUP_HI_BEST_EFFORT,
+	ZPOOL_PROP_FORCETRIM,
+	ZPOOL_PROP_AUTOTRIM,
+	ZPOOL_PROP_SMALL_DATA_TO_METADEV,
+	ZPOOL_PROP_MINWATERMARK,
+	ZPOOL_PROP_SYNC_TO_SPECIAL,
 	ZPOOL_PROP_BOOTSIZE,
+	ZPOOL_PROP_SCRUB_PRIO,
+	ZPOOL_PROP_RESILVER_PRIO,
 	ZPOOL_NUM_PROPS
 } zpool_prop_t;
 
+/*
+ * Note: it is important to keep min/max active properties together in the
+ * same order as the corresponding zio_priority_t definitions as this order
+ * is relied upon when processing in loops. See vdev_impl.h for the set of
+ * macros that rely on this dependency.
+ * Also path must be the first entry in the enum as loops use it as a starting
+ * index.
+ */
+typedef enum vdev_prop {
+	VDEV_PROP_PATH,
+	VDEV_PROP_FRU,
+	/* minactive props for queue classes */
+	VDEV_PROP_READ_MINACTIVE,
+	VDEV_PROP_AREAD_MINACTIVE,
+	VDEV_PROP_WRITE_MINACTIVE,
+	VDEV_PROP_AWRITE_MINACTIVE,
+	VDEV_PROP_RESILVER_MINACTIVE,
+	VDEV_PROP_SCRUB_MINACTIVE,
+	/* maxactive props for queue classes */
+	VDEV_PROP_READ_MAXACTIVE,
+	VDEV_PROP_AREAD_MAXACTIVE,
+	VDEV_PROP_WRITE_MAXACTIVE,
+	VDEV_PROP_AWRITE_MAXACTIVE,
+	VDEV_PROP_RESILVER_MAXACTIVE,
+	VDEV_PROP_SCRUB_MAXACTIVE,
+	VDEV_PROP_PREFERRED_READ,
+	VDEV_PROP_COS,
+	VDEV_PROP_SPAREGROUP,
+	VDEV_PROP_L2ADDDT,
+	VDEV_PROP_GUID,
+	VDEV_NUM_PROPS
+} vdev_prop_t;
+
+/*
+ * Note: it is important to keep min/max active properties together in the
+ * same order as the corresponding zio_priority_t definitions as this order
+ * is relied upon when processing in loops. See cos.h for the set of
+ * macros that rely on this dependency.
+ */
+typedef enum cos_prop {
+	COS_PROP_GUID,
+	/* user-defined cos name */
+	COS_PROP_NAME,
+	/* IO tunables */
+	/* minactive props for queue classes */
+	COS_PROP_READ_MINACTIVE,
+	COS_PROP_AREAD_MINACTIVE,
+	COS_PROP_WRITE_MINACTIVE,
+	COS_PROP_AWRITE_MINACTIVE,
+	COS_PROP_RESILVER_MINACTIVE,
+	COS_PROP_SCRUB_MINACTIVE,
+	/* maxactive props for queue classes */
+	COS_PROP_READ_MAXACTIVE,
+	COS_PROP_AREAD_MAXACTIVE,
+	COS_PROP_WRITE_MAXACTIVE,
+	COS_PROP_AWRITE_MAXACTIVE,
+	COS_PROP_RESILVER_MAXACTIVE,
+	COS_PROP_SCRUB_MAXACTIVE,
+	/* preference for read in mirror configurations */
+	COS_PROP_PREFERRED_READ,
+	COS_NUM_PROPS
+} cos_prop_t;
+
 /* Small enough to not hog a whole line of printout in zpool(1M). */
 #define	ZPROP_MAX_COMMENT	32
 
+#define	ZPROP_CONT		-2
+#define	ZPROP_INVAL		-1
+
 #define	ZPROP_VALUE		"value"
 #define	ZPROP_SOURCE		"source"
 
@@ -293,6 +390,31 @@
 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
 
 /*
+ * Vdev property functions shared between libzfs and kernel.
+ */
+vdev_prop_t vdev_name_to_prop(const char *);
+const char *vdev_prop_to_name(vdev_prop_t);
+const char *vdev_prop_default_string(vdev_prop_t);
+uint64_t vdev_prop_default_numeric(vdev_prop_t);
+boolean_t vdev_prop_readonly(vdev_prop_t);
+int vdev_prop_index_to_string(vdev_prop_t, uint64_t, const char **);
+int vdev_prop_string_to_index(vdev_prop_t, const char *, uint64_t *);
+uint64_t vdev_prop_random_value(vdev_prop_t, uint64_t seed);
+
+/*
+ * COS property functions shared between libzfs and kernel.
+ */
+cos_prop_t cos_name_to_prop(const char *);
+const char *cos_prop_to_name(cos_prop_t);
+const char *cos_prop_default_string(cos_prop_t);
+uint64_t cos_prop_default_numeric(cos_prop_t);
+boolean_t cos_prop_readonly(cos_prop_t);
+int cos_prop_index_to_string(cos_prop_t, uint64_t, const char **);
+int cos_prop_string_to_index(cos_prop_t, const char *, uint64_t *);
+uint64_t cos_prop_random_value(cos_prop_t, uint64_t seed);
+
+#define	MAXCOSNAMELEN	(64)
+/*
  * Definitions for the Delegation.
  */
 typedef enum {
@@ -354,7 +476,8 @@
 typedef enum zfs_cache_type {
 	ZFS_CACHE_NONE = 0,
 	ZFS_CACHE_METADATA = 1,
-	ZFS_CACHE_ALL = 2
+	ZFS_CACHE_ALL = 2,
+	ZFS_CACHE_DATA = 3
 } zfs_cache_type_t;
 
 typedef enum {
@@ -368,6 +491,12 @@
 	ZFS_REDUNDANT_METADATA_MOST
 } zfs_redundant_metadata_type_t;
 
+typedef enum {
+	ZFS_WBC_MODE_OFF,
+	ZFS_WBC_MODE_ON,
+	ZFS_WBC_MODE_OFF_DELAYED
+} zfs_wbc_mode_t;
+
 /*
  * On-disk version number.
  */
@@ -508,9 +637,7 @@
 
 /*
  * The following are configuration names used in the nvlist describing a pool's
- * configuration.  New on-disk names should be prefixed with "<reverse-DNS>:"
- * (e.g. "org.open-zfs:") to avoid conflicting names being developed
- * independently.
+ * configuration.
  */
 #define	ZPOOL_CONFIG_VERSION		"version"
 #define	ZPOOL_CONFIG_POOL_NAME		"name"
@@ -524,9 +651,6 @@
 #define	ZPOOL_CONFIG_CHILDREN		"children"
 #define	ZPOOL_CONFIG_ID			"id"
 #define	ZPOOL_CONFIG_GUID		"guid"
-#define	ZPOOL_CONFIG_INDIRECT_OBJECT	"com.delphix:indirect_object"
-#define	ZPOOL_CONFIG_INDIRECT_BIRTHS	"com.delphix:indirect_births"
-#define	ZPOOL_CONFIG_PREV_INDIRECT_VDEV	"com.delphix:prev_indirect_vdev"
 #define	ZPOOL_CONFIG_PATH		"path"
 #define	ZPOOL_CONFIG_DEVID		"devid"
 #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
@@ -535,9 +659,7 @@
 #define	ZPOOL_CONFIG_ASIZE		"asize"
 #define	ZPOOL_CONFIG_DTL		"DTL"
 #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
-#define	ZPOOL_CONFIG_REMOVAL_STATS	"removal_stats"	/* not stored on disk */
 #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
-#define	ZPOOL_CONFIG_INDIRECT_SIZE	"indirect_size"	/* not stored on disk */
 #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
 #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
 #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
@@ -550,7 +672,9 @@
 #define	ZPOOL_CONFIG_UNSPARE		"unspare"
 #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
 #define	ZPOOL_CONFIG_IS_LOG		"is_log"
+#define	ZPOOL_CONFIG_IS_SPECIAL		"is_special"
 #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
+#define	ZPOOL_CONFIG_L2CACHE_PERSISTENT	"l2cache_persistent"
 #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
 #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
 #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
@@ -562,6 +686,7 @@
 #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
 #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
 #define	ZPOOL_CONFIG_REMOVING		"removing"
+#define	ZPOOL_CONFIG_RESILVERING	"resilvering"
 #define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
 #define	ZPOOL_CONFIG_COMMENT		"comment"
 #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
@@ -575,10 +700,10 @@
 #define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
 #define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
 #define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
+#define	ZPOOL_CONFIG_IS_SSD		"is_ssd"	/* not stored on disk */
 #define	ZPOOL_CONFIG_VDEV_TOP_ZAP	"com.delphix:vdev_zap_top"
 #define	ZPOOL_CONFIG_VDEV_LEAF_ZAP	"com.delphix:vdev_zap_leaf"
 #define	ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS	"com.delphix:has_per_vdev_zaps"
-#define	ZPOOL_CONFIG_CACHEFILE		"cachefile"	/* not stored on disk */
 /*
  * The persistent vdev state is stored as separate values rather than a single
  * 'vdev_state' entry.  This is because a device can be in multiple states, such
@@ -590,6 +715,10 @@
 #define	ZPOOL_CONFIG_REMOVED		"removed"
 #define	ZPOOL_CONFIG_FRU		"fru"
 #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
+#define	ZPOOL_CONFIG_TRIM_PROG		"trim_prog"
+#define	ZPOOL_CONFIG_TRIM_RATE		"trim_rate"
+#define	ZPOOL_CONFIG_TRIM_START_TIME	"trim_start_time"
+#define	ZPOOL_CONFIG_TRIM_STOP_TIME	"trim_stop_time"
 
 /* Rewind policy parameters */
 #define	ZPOOL_REWIND_POLICY		"rewind-policy"
@@ -614,14 +743,8 @@
 #define	VDEV_TYPE_SPARE			"spare"
 #define	VDEV_TYPE_LOG			"log"
 #define	VDEV_TYPE_L2CACHE		"l2cache"
-#define	VDEV_TYPE_INDIRECT		"indirect"
+#define	VDEV_TYPE_SPECIAL		"special"
 
-/* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
-#define	VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
-	"com.delphix:indirect_obsolete_sm"
-#define	VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
-	"com.delphix:obsolete_counts_are_precise"
-
 /*
  * This is needed in userland to report the minimum necessary device size.
  *
@@ -679,8 +802,7 @@
 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
-	VDEV_AUX_SPLIT_POOL,	/* vdev was split off into another pool	*/
-	VDEV_AUX_CHILDREN_OFFLINE /* all children are offline		*/
+	VDEV_AUX_SPLIT_POOL	/* vdev was split off into another pool	*/
 } vdev_aux_t;
 
 /*
@@ -707,10 +829,20 @@
 	POOL_SCAN_NONE,
 	POOL_SCAN_SCRUB,
 	POOL_SCAN_RESILVER,
+	POOL_SCAN_MOS,
+	POOL_SCAN_META,
 	POOL_SCAN_FUNCS
 } pool_scan_func_t;
 
 /*
+ * TRIM command configuration info.
+ */
+typedef struct trim_cmd_info_s {
+	uint64_t	tci_start;	/* B_TRUE = start; B_FALSE = stop */
+	uint64_t	tci_rate;	/* requested TRIM rate in bytes/sec */
+} trim_cmd_info_t;
+
+/*
  * Used to control scrub pause and resume.
  */
 typedef enum pool_scrub_cmd {
@@ -719,7 +851,6 @@
 	POOL_SCRUB_FLAGS_END
 } pool_scrub_cmd_t;
 
-
 /*
  * ZIO types.  Needed to interpret vdev statistics below.
  */
@@ -744,7 +875,8 @@
 	uint64_t	pss_start_time;	/* scan start time */
 	uint64_t	pss_end_time;	/* scan end time */
 	uint64_t	pss_to_examine;	/* total bytes to scan */
-	uint64_t	pss_examined;	/* total examined bytes	*/
+	uint64_t	pss_examined;	/* total bytes located by scanner */
+	uint64_t	pss_issued;	/* total bytes checked by scanner */
 	uint64_t	pss_to_process; /* total bytes to process */
 	uint64_t	pss_processed;	/* total processed bytes */
 	uint64_t	pss_errors;	/* scan errors	*/
@@ -751,6 +883,7 @@
 
 	/* values not stored on disk */
 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
+	uint64_t	pss_pass_work;	/* issued bytes per scan pass */
 	uint64_t	pss_pass_start;	/* start time of a scan pass */
 	uint64_t	pss_pass_scrub_pause; /* pause time of a scurb pass */
 	/* cumulative time scrub spent paused, needed for rate calculation */
@@ -757,25 +890,12 @@
 	uint64_t	pss_pass_scrub_spent_paused;
 } pool_scan_stat_t;
 
-typedef struct pool_removal_stat {
-	uint64_t prs_state; /* dsl_scan_state_t */
-	uint64_t prs_removing_vdev;
-	uint64_t prs_start_time;
-	uint64_t prs_end_time;
-	uint64_t prs_to_copy; /* bytes that need to be copied */
-	uint64_t prs_copied; /* bytes copied so far */
-	/*
-	 * bytes of memory used for indirect mappings.
-	 * This includes all removed vdevs.
-	 */
-	uint64_t prs_mapping_memory;
-} pool_removal_stat_t;
-
 typedef enum dsl_scan_state {
 	DSS_NONE,
 	DSS_SCANNING,
 	DSS_FINISHED,
 	DSS_CANCELED,
+	DSS_FINISHING,
 	DSS_NUM_STATES
 } dsl_scan_state_t;
 
@@ -802,6 +922,8 @@
 	uint64_t	vs_scan_removing;	/* removing?	*/
 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
 	uint64_t	vs_fragmentation;	/* device fragmentation */
+	hrtime_t	vs_latency[ZIO_TYPES];	/* moving average of latency */
+	hrtime_t	vs_iotime[ZIO_TYPES];	/* time spent doing i/o */
 } vdev_stat_t;
 
 /*
@@ -870,6 +992,7 @@
 	ZFS_IOC_VDEV_SET_STATE,
 	ZFS_IOC_VDEV_ATTACH,
 	ZFS_IOC_VDEV_DETACH,
+	ZFS_IOC_VDEV_SETL2ADDDT,
 	ZFS_IOC_VDEV_SETPATH,
 	ZFS_IOC_VDEV_SETFRU,
 	ZFS_IOC_OBJSET_STATS,
@@ -924,8 +1047,24 @@
 	ZFS_IOC_BOOKMARK,
 	ZFS_IOC_GET_BOOKMARKS,
 	ZFS_IOC_DESTROY_BOOKMARKS,
+	ZFS_IOC_VDEV_SET_PROPS,
+	ZFS_IOC_VDEV_GET_PROPS,
+	ZFS_IOC_COS_ALLOC,
+	ZFS_IOC_COS_FREE,
+	ZFS_IOC_COS_LIST,
+	ZFS_IOC_COS_SET_PROPS,
+	ZFS_IOC_COS_GET_PROPS,
+	ZFS_IOC_POOL_CONFIGS_NVL,
+	ZFS_IOC_POOL_STATS_NVL,
+	ZFS_IOC_OBJSET_STATS_NVL,
+	ZFS_IOC_DATASET_LIST_NEXT_NVL,
+	ZFS_IOC_SNAPSHOT_LIST_NEXT_NVL,
+	ZFS_IOC_POOL_GET_PROPS_NVL,
+	ZFS_IOC_CHECK_KRRP,
+	ZFS_IOC_BULK_LIST,
+	ZFS_IOC_POOL_TRIM,
 	ZFS_IOC_CHANNEL_PROGRAM,
-	ZFS_IOC_REMAP,
+	ZFS_IOC_SET_PROPS_MDS,
 	ZFS_IOC_LAST
 } zfs_ioc_t;
 
