--- old/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h	Mon Aug  5 17:26:59 2019
+++ new/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h	Mon Aug  5 17:26:59 2019
@@ -25,6 +25,7 @@
  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
  */
 
 #ifndef	_SYS_DSL_DATASET_H
@@ -101,11 +102,6 @@
 #define	DS_FIELD_RESUME_COMPRESSOK "com.delphix:resume_compressok"
 
 /*
- * This field is set to the object number of the remap deadlist if one exists.
- */
-#define	DS_FIELD_REMAP_DEADLIST	"com.delphix:remap_deadlist"
-
-/*
  * DS_FLAG_CI_DATASET is set if the dataset contains a file system whose
  * name lookups should be performed case-insensitively.
  */
@@ -113,6 +109,14 @@
 
 #define	DS_CREATE_FLAG_NODIRTY	(1ULL<<24)
 
+typedef struct dsl_dataset_snapshot_arg {
+	nvlist_t *ddsa_snaps;
+	nvlist_t *ddsa_props;
+	nvlist_t *ddsa_errors;
+	cred_t *ddsa_cr;
+	boolean_t ddsa_autosnap;
+} dsl_dataset_snapshot_arg_t;
+
 typedef struct dsl_dataset_phys {
 	uint64_t ds_dir_obj;		/* DMU_OT_DSL_DIR */
 	uint64_t ds_prev_snap_obj;	/* DMU_OT_DSL_DATASET */
@@ -166,24 +170,6 @@
 	dsl_deadlist_t ds_deadlist;
 	bplist_t ds_pending_deadlist;
 
-	/*
-	 * The remap deadlist contains blocks (DVA's, really) that are
-	 * referenced by the previous snapshot and point to indirect vdevs,
-	 * but in this dataset they have been remapped to point to concrete
-	 * (or at least, less-indirect) vdevs.  In other words, the
-	 * physical DVA is referenced by the previous snapshot but not by
-	 * this dataset.  Logically, the DVA continues to be referenced,
-	 * but we are using a different (less indirect) physical DVA.
-	 * This deadlist is used to determine when physical DVAs that
-	 * point to indirect vdevs are no longer referenced anywhere,
-	 * and thus should be marked obsolete.
-	 *
-	 * This is only used if SPA_FEATURE_OBSOLETE_COUNTS is enabled.
-	 */
-	dsl_deadlist_t ds_remap_deadlist;
-	/* protects creation of the ds_remap_deadlist */
-	kmutex_t ds_remap_deadlist_lock;
-
 	/* protected by lock on pool's dp_dirty_datasets list */
 	txg_node_t ds_dirty_link;
 	list_node_t ds_synced_link;
@@ -198,11 +184,27 @@
 	void *ds_owner;
 
 	/*
+	 * NOTE: for pool with special device only
+	 * Last transaction data was moved from special devices
+	 * to other (regular) devices in a pool.
+	 */
+	uint64_t ds_lstxg;
+
+	/*
+	 * NOTE: for pool with special device only
+	 * Level 0 bookmark we remembered when we were interrupted
+	 * during traversal process. Used to resume traversal
+	 * later.
+	 */
+	zbookmark_phys_t ds_lszb;
+
+	/*
 	 * Long holds prevent the ds from being destroyed; they allow the
 	 * ds to remain held even after dropping the dp_config_rwlock.
 	 * Owning counts as a long hold.  See the comments above
 	 * dsl_pool_hold() for details.
 	 */
+
 	refcount_t ds_longholds;
 
 	/* no locking; only for making guesses */
@@ -267,13 +269,6 @@
 	nvlist_t *ddra_result;
 } dsl_dataset_rollback_arg_t;
 
-typedef struct dsl_dataset_snapshot_arg {
-	nvlist_t *ddsa_snaps;
-	nvlist_t *ddsa_props;
-	nvlist_t *ddsa_errors;
-	cred_t *ddsa_cr;
-} dsl_dataset_snapshot_arg_t;
-
 /*
  * The max length of a temporary tag prefix is the number of hex digits
  * required to express UINT64_MAX plus one for the hyphen.
@@ -333,8 +328,6 @@
     dmu_tx_t *tx);
 int dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp,
     dmu_tx_t *tx, boolean_t async);
-void dsl_dataset_block_remapped(dsl_dataset_t *ds, uint64_t vdev,
-    uint64_t offset, uint64_t size, uint64_t birth, dmu_tx_t *tx);
 
 void dsl_dataset_dirty(dsl_dataset_t *ds, dmu_tx_t *tx);
 
@@ -422,11 +415,28 @@
 int dsl_dataset_rollback(const char *fsname, const char *tosnap, void *owner,
     nvlist_t *result);
 
-uint64_t dsl_dataset_get_remap_deadlist_object(dsl_dataset_t *ds);
-void dsl_dataset_create_remap_deadlist(dsl_dataset_t *ds, dmu_tx_t *tx);
-boolean_t dsl_dataset_remap_deadlist_exists(dsl_dataset_t *ds);
-void dsl_dataset_destroy_remap_deadlist(dsl_dataset_t *ds, dmu_tx_t *tx);
+int dsl_dataset_snapshot_check(void *arg, dmu_tx_t *tx);
+void dsl_dataset_snapshot_sync(void *arg, dmu_tx_t *tx);
 
+typedef struct {
+	char name[ZFS_MAX_DATASET_NAME_LEN];
+	char origin_name[ZFS_MAX_DATASET_NAME_LEN];
+	uint64_t origin_guid;
+	uint64_t cookie;
+	boolean_t cookie_is_snap;
+	boolean_t top_level_ds;
+	dsl_dataset_t *ds;
+	list_node_t node;
+	avl_tree_t snapshots;
+} zfs_ds_collector_entry_t;
+
+uint64_t dsl_dataset_creation_txg(const char *name);
+
+boolean_t dataset_name_hidden(const char *name);
+
+zfs_ds_collector_entry_t *dsl_dataset_collector_cache_alloc();
+void dsl_dataset_collector_cache_free(zfs_ds_collector_entry_t *entry);
+
 void dsl_dataset_deactivate_feature(uint64_t dsobj,
     spa_feature_t f, dmu_tx_t *tx);
 
