xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h (revision 77b171372ed21642e04c873ef1e87fe2365520df)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
223f9d6ad7SLin Ling  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23ca0cc391SMatthew Ahrens  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
24a2afb611SJerry Jelinek  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
25a7a845e4SSteven Hartland  * Copyright (c) 2013 Steven Hartland. All rights reserved.
26bc9014e6SJustin Gibbs  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
27c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
28fa9e4066Sahrens  */
29fa9e4066Sahrens 
30fa9e4066Sahrens #ifndef	_SYS_DSL_DATASET_H
31fa9e4066Sahrens #define	_SYS_DSL_DATASET_H
32fa9e4066Sahrens 
33fa9e4066Sahrens #include <sys/dmu.h>
34fa9e4066Sahrens #include <sys/spa.h>
35fa9e4066Sahrens #include <sys/txg.h>
36c717a561Smaybee #include <sys/zio.h>
37fa9e4066Sahrens #include <sys/bplist.h>
381d452cf5Sahrens #include <sys/dsl_synctask.h>
39fa9e4066Sahrens #include <sys/zfs_context.h>
40cde58dbcSMatthew Ahrens #include <sys/dsl_deadlist.h>
413b2aab18SMatthew Ahrens #include <sys/refcount.h>
42c166b69dSPaul Dagnelie #include <sys/rrwlock.h>
43ca0cc391SMatthew Ahrens #include <zfeature_common.h>
44fa9e4066Sahrens 
45fa9e4066Sahrens #ifdef	__cplusplus
46fa9e4066Sahrens extern "C" {
47fa9e4066Sahrens #endif
48fa9e4066Sahrens 
49fa9e4066Sahrens struct dsl_dataset;
50fa9e4066Sahrens struct dsl_dir;
51fa9e4066Sahrens struct dsl_pool;
52fa9e4066Sahrens 
5399653d4eSeschrock #define	DS_FLAG_INCONSISTENT	(1ULL<<0)
54745cd3c5Smaybee #define	DS_IS_INCONSISTENT(ds)	\
55c1379625SJustin T. Gibbs 	(dsl_dataset_phys(ds)->ds_flags & DS_FLAG_INCONSISTENT)
562acef22dSMatthew Ahrens 
5799653d4eSeschrock /*
582acef22dSMatthew Ahrens  * Do not allow this dataset to be promoted.
5999653d4eSeschrock  */
6099653d4eSeschrock #define	DS_FLAG_NOPROMOTE	(1ULL<<1)
6199653d4eSeschrock 
62a9799022Sck /*
63a9799022Sck  * DS_FLAG_UNIQUE_ACCURATE is set if ds_unique_bytes has been correctly
64a9799022Sck  * calculated for head datasets (starting with SPA_VERSION_UNIQUE_ACCURATE,
65a9799022Sck  * refquota/refreservations).
66a9799022Sck  */
67a9799022Sck #define	DS_FLAG_UNIQUE_ACCURATE	(1ULL<<2)
68a9799022Sck 
69842727c2SChris Kirby /*
70842727c2SChris Kirby  * DS_FLAG_DEFER_DESTROY is set after 'zfs destroy -d' has been called
71842727c2SChris Kirby  * on a dataset. This allows the dataset to be destroyed using 'zfs release'.
72842727c2SChris Kirby  */
73842727c2SChris Kirby #define	DS_FLAG_DEFER_DESTROY	(1ULL<<3)
74842727c2SChris Kirby #define	DS_IS_DEFER_DESTROY(ds)	\
75c1379625SJustin T. Gibbs 	(dsl_dataset_phys(ds)->ds_flags & DS_FLAG_DEFER_DESTROY)
76842727c2SChris Kirby 
772acef22dSMatthew Ahrens /*
782acef22dSMatthew Ahrens  * DS_FIELD_* are strings that are used in the "extensified" dataset zap object.
792acef22dSMatthew Ahrens  * They should be of the format <reverse-dns>:<field>.
802acef22dSMatthew Ahrens  */
812acef22dSMatthew Ahrens 
8278f17100SMatthew Ahrens /*
8378f17100SMatthew Ahrens  * This field's value is the object ID of a zap object which contains the
8478f17100SMatthew Ahrens  * bookmarks of this dataset.  If it is present, then this dataset is counted
8578f17100SMatthew Ahrens  * in the refcount of the SPA_FEATURES_BOOKMARKS feature.
8678f17100SMatthew Ahrens  */
8778f17100SMatthew Ahrens #define	DS_FIELD_BOOKMARK_NAMES "com.delphix:bookmarks"
8878f17100SMatthew Ahrens 
899c3fd121SMatthew Ahrens /*
909c3fd121SMatthew Ahrens  * These fields are set on datasets that are in the middle of a resumable
919c3fd121SMatthew Ahrens  * receive, and allow the sender to resume the send if it is interrupted.
929c3fd121SMatthew Ahrens  */
939c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_FROMGUID "com.delphix:resume_fromguid"
949c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_TONAME "com.delphix:resume_toname"
959c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_TOGUID "com.delphix:resume_toguid"
969c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_OBJECT "com.delphix:resume_object"
979c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_OFFSET "com.delphix:resume_offset"
989c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_BYTES "com.delphix:resume_bytes"
995602294fSDan Kimmel #define	DS_FIELD_RESUME_LARGEBLOCK "com.delphix:resume_largeblockok"
1009c3fd121SMatthew Ahrens #define	DS_FIELD_RESUME_EMBEDOK "com.delphix:resume_embedok"
1015602294fSDan Kimmel #define	DS_FIELD_RESUME_COMPRESSOK "com.delphix:resume_compressok"
1029c3fd121SMatthew Ahrens 
103ab04eb8eStimh /*
104ab04eb8eStimh  * DS_FLAG_CI_DATASET is set if the dataset contains a file system whose
105ab04eb8eStimh  * name lookups should be performed case-insensitively.
106ab04eb8eStimh  */
107ab04eb8eStimh #define	DS_FLAG_CI_DATASET	(1ULL<<16)
108ab04eb8eStimh 
1093b2aab18SMatthew Ahrens #define	DS_CREATE_FLAG_NODIRTY	(1ULL<<24)
1103b2aab18SMatthew Ahrens 
111fa9e4066Sahrens typedef struct dsl_dataset_phys {
112088f3894Sahrens 	uint64_t ds_dir_obj;		/* DMU_OT_DSL_DIR */
113088f3894Sahrens 	uint64_t ds_prev_snap_obj;	/* DMU_OT_DSL_DATASET */
114fa9e4066Sahrens 	uint64_t ds_prev_snap_txg;
115088f3894Sahrens 	uint64_t ds_next_snap_obj;	/* DMU_OT_DSL_DATASET */
116088f3894Sahrens 	uint64_t ds_snapnames_zapobj;	/* DMU_OT_DSL_DS_SNAP_MAP 0 for snaps */
117fa9e4066Sahrens 	uint64_t ds_num_children;	/* clone/snap children; ==0 for head */
118fa9e4066Sahrens 	uint64_t ds_creation_time;	/* seconds since 1970 */
119fa9e4066Sahrens 	uint64_t ds_creation_txg;
120cde58dbcSMatthew Ahrens 	uint64_t ds_deadlist_obj;	/* DMU_OT_DEADLIST */
121ad135b5dSChristopher Siden 	/*
122ad135b5dSChristopher Siden 	 * ds_referenced_bytes, ds_compressed_bytes, and ds_uncompressed_bytes
123ad135b5dSChristopher Siden 	 * include all blocks referenced by this dataset, including those
124ad135b5dSChristopher Siden 	 * shared with any other datasets.
125ad135b5dSChristopher Siden 	 */
126ad135b5dSChristopher Siden 	uint64_t ds_referenced_bytes;
127fa9e4066Sahrens 	uint64_t ds_compressed_bytes;
128fa9e4066Sahrens 	uint64_t ds_uncompressed_bytes;
12963360950Smp 	uint64_t ds_unique_bytes;	/* only relevant to snapshots */
130fa9e4066Sahrens 	/*
131fa9e4066Sahrens 	 * The ds_fsid_guid is a 56-bit ID that can change to avoid
132fa9e4066Sahrens 	 * collisions.  The ds_guid is a 64-bit ID that will never
133fa9e4066Sahrens 	 * change, so there is a small probability that it will collide.
134fa9e4066Sahrens 	 */
135fa9e4066Sahrens 	uint64_t ds_fsid_guid;
136fa9e4066Sahrens 	uint64_t ds_guid;
137088f3894Sahrens 	uint64_t ds_flags;		/* DS_FLAG_* */
138fa9e4066Sahrens 	blkptr_t ds_bp;
139bb0ade09Sahrens 	uint64_t ds_next_clones_obj;	/* DMU_OT_DSL_CLONES */
140bb0ade09Sahrens 	uint64_t ds_props_obj;		/* DMU_OT_DSL_PROPS for snaps */
141842727c2SChris Kirby 	uint64_t ds_userrefs_obj;	/* DMU_OT_USERREFS */
142842727c2SChris Kirby 	uint64_t ds_pad[5]; /* pad out to 320 bytes for good measure */
143fa9e4066Sahrens } dsl_dataset_phys_t;
144fa9e4066Sahrens 
145fa9e4066Sahrens typedef struct dsl_dataset {
146bc9014e6SJustin Gibbs 	dmu_buf_user_t ds_dbu;
147c166b69dSPaul Dagnelie 	rrwlock_t ds_bp_rwlock; /* Protects ds_phys->ds_bp */
148bc9014e6SJustin Gibbs 
149fa9e4066Sahrens 	/* Immutable: */
150fa9e4066Sahrens 	struct dsl_dir *ds_dir;
151fa9e4066Sahrens 	dmu_buf_t *ds_dbuf;
152fa9e4066Sahrens 	uint64_t ds_object;
15391ebeef5Sahrens 	uint64_t ds_fsid_guid;
154bc9014e6SJustin Gibbs 	boolean_t ds_is_snapshot;
155fa9e4066Sahrens 
15674e7dc98SMatthew Ahrens 	/* only used in syncing context, only valid for non-snapshots: */
15774e7dc98SMatthew Ahrens 	struct dsl_dataset *ds_prev;
15878f17100SMatthew Ahrens 	uint64_t ds_bookmarks;  /* DMU_OTN_ZAP_METADATA */
159fa9e4066Sahrens 
160fa9e4066Sahrens 	/* has internal locking: */
161cde58dbcSMatthew Ahrens 	dsl_deadlist_t ds_deadlist;
162cde58dbcSMatthew Ahrens 	bplist_t ds_pending_deadlist;
163fa9e4066Sahrens 
164fa9e4066Sahrens 	/* protected by lock on pool's dp_dirty_datasets list */
165fa9e4066Sahrens 	txg_node_t ds_dirty_link;
166fa9e4066Sahrens 	list_node_t ds_synced_link;
167fa9e4066Sahrens 
168fa9e4066Sahrens 	/*
169fa9e4066Sahrens 	 * ds_phys->ds_<accounting> is also protected by ds_lock.
170fa9e4066Sahrens 	 * Protected by ds_lock:
171fa9e4066Sahrens 	 */
172fa9e4066Sahrens 	kmutex_t ds_lock;
173503ad85cSMatthew Ahrens 	objset_t *ds_objset;
174842727c2SChris Kirby 	uint64_t ds_userrefs;
1753b2aab18SMatthew Ahrens 	void *ds_owner;
176745cd3c5Smaybee 
177745cd3c5Smaybee 	/*
1783b2aab18SMatthew Ahrens 	 * Long holds prevent the ds from being destroyed; they allow the
1793b2aab18SMatthew Ahrens 	 * ds to remain held even after dropping the dp_config_rwlock.
1803b2aab18SMatthew Ahrens 	 * Owning counts as a long hold.  See the comments above
1813b2aab18SMatthew Ahrens 	 * dsl_pool_hold() for details.
182745cd3c5Smaybee 	 */
1833b2aab18SMatthew Ahrens 	refcount_t ds_longholds;
184fa9e4066Sahrens 
1851d452cf5Sahrens 	/* no locking; only for making guesses */
1861d452cf5Sahrens 	uint64_t ds_trysnap_txg;
1871d452cf5Sahrens 
18891ebeef5Sahrens 	/* for objset_open() */
18991ebeef5Sahrens 	kmutex_t ds_opening_lock;
19091ebeef5Sahrens 
191a9799022Sck 	uint64_t ds_reserved;	/* cached refreservation */
192a9799022Sck 	uint64_t ds_quota;	/* cached refquota */
193a9799022Sck 
1944e3c9f44SBill Pijewski 	kmutex_t ds_sendstream_lock;
1954e3c9f44SBill Pijewski 	list_t ds_sendstreams;
1964e3c9f44SBill Pijewski 
1979c3fd121SMatthew Ahrens 	/*
1989c3fd121SMatthew Ahrens 	 * When in the middle of a resumable receive, tracks how much
1999c3fd121SMatthew Ahrens 	 * progress we have made.
2009c3fd121SMatthew Ahrens 	 */
2019c3fd121SMatthew Ahrens 	uint64_t ds_resume_object[TXG_SIZE];
2029c3fd121SMatthew Ahrens 	uint64_t ds_resume_offset[TXG_SIZE];
2039c3fd121SMatthew Ahrens 	uint64_t ds_resume_bytes[TXG_SIZE];
2049c3fd121SMatthew Ahrens 
20503bad06fSJustin Gibbs 	/* Protected by our dsl_dir's dd_lock */
20603bad06fSJustin Gibbs 	list_t ds_prop_cbs;
20703bad06fSJustin Gibbs 
208ca0cc391SMatthew Ahrens 	/*
209ca0cc391SMatthew Ahrens 	 * For ZFEATURE_FLAG_PER_DATASET features, set if this dataset
210ca0cc391SMatthew Ahrens 	 * uses this feature.
211ca0cc391SMatthew Ahrens 	 */
212ca0cc391SMatthew Ahrens 	uint8_t ds_feature_inuse[SPA_FEATURES];
213ca0cc391SMatthew Ahrens 
214ca0cc391SMatthew Ahrens 	/*
215ca0cc391SMatthew Ahrens 	 * Set if we need to activate the feature on this dataset this txg
216ca0cc391SMatthew Ahrens 	 * (used only in syncing context).
217ca0cc391SMatthew Ahrens 	 */
218ca0cc391SMatthew Ahrens 	uint8_t ds_feature_activation_needed[SPA_FEATURES];
219ca0cc391SMatthew Ahrens 
220fa9e4066Sahrens 	/* Protected by ds_lock; keep at end of struct for better locality */
2219adfa60dSMatthew Ahrens 	char ds_snapname[ZFS_MAX_DATASET_NAME_LEN];
222fa9e4066Sahrens } dsl_dataset_t;
223fa9e4066Sahrens 
224c1379625SJustin T. Gibbs inline dsl_dataset_phys_t *
225c1379625SJustin T. Gibbs dsl_dataset_phys(dsl_dataset_t *ds)
226c1379625SJustin T. Gibbs {
227c1379625SJustin T. Gibbs 	return (ds->ds_dbuf->db_data);
228c1379625SJustin T. Gibbs }
229c1379625SJustin T. Gibbs 
230dfc11533SChris Williamson typedef struct dsl_dataset_promote_arg {
231dfc11533SChris Williamson 	const char *ddpa_clonename;
232dfc11533SChris Williamson 	dsl_dataset_t *ddpa_clone;
233dfc11533SChris Williamson 	list_t shared_snaps, origin_snaps, clone_snaps;
234dfc11533SChris Williamson 	dsl_dataset_t *origin_origin; /* origin of the origin */
235dfc11533SChris Williamson 	uint64_t used, comp, uncomp, unique, cloneusedsnap, originusedsnap;
236dfc11533SChris Williamson 	nvlist_t *err_ds;
237dfc11533SChris Williamson 	cred_t *cr;
238dfc11533SChris Williamson } dsl_dataset_promote_arg_t;
239dfc11533SChris Williamson 
24099d5e173STim Haley /*
24199d5e173STim Haley  * The max length of a temporary tag prefix is the number of hex digits
24299d5e173STim Haley  * required to express UINT64_MAX plus one for the hyphen.
24399d5e173STim Haley  */
24499d5e173STim Haley #define	MAX_TAG_PREFIX_LEN	17
24599d5e173STim Haley 
246643da460SMax Grossman #define	dsl_dataset_is_snapshot(ds) \
247643da460SMax Grossman 	(dsl_dataset_phys(ds)->ds_num_children != 0)
248643da460SMax Grossman 
249a9799022Sck #define	DS_UNIQUE_IS_ACCURATE(ds)	\
250c1379625SJustin T. Gibbs 	((dsl_dataset_phys(ds)->ds_flags & DS_FLAG_UNIQUE_ACCURATE) != 0)
251a9799022Sck 
2523b2aab18SMatthew Ahrens int dsl_dataset_hold(struct dsl_pool *dp, const char *name, void *tag,
2533b2aab18SMatthew Ahrens     dsl_dataset_t **dsp);
254e57a022bSJustin T. Gibbs boolean_t dsl_dataset_try_add_ref(struct dsl_pool *dp, dsl_dataset_t *ds,
255e57a022bSJustin T. Gibbs     void *tag);
2563b2aab18SMatthew Ahrens int dsl_dataset_hold_obj(struct dsl_pool *dp, uint64_t dsobj, void *tag,
2573b2aab18SMatthew Ahrens     dsl_dataset_t **);
2583b2aab18SMatthew Ahrens void dsl_dataset_rele(dsl_dataset_t *ds, void *tag);
2593b2aab18SMatthew Ahrens int dsl_dataset_own(struct dsl_pool *dp, const char *name,
260503ad85cSMatthew Ahrens     void *tag, dsl_dataset_t **dsp);
261745cd3c5Smaybee int dsl_dataset_own_obj(struct dsl_pool *dp, uint64_t dsobj,
2623b2aab18SMatthew Ahrens     void *tag, dsl_dataset_t **dsp);
263503ad85cSMatthew Ahrens void dsl_dataset_disown(dsl_dataset_t *ds, void *tag);
2643b2aab18SMatthew Ahrens void dsl_dataset_name(dsl_dataset_t *ds, char *name);
2653b2aab18SMatthew Ahrens boolean_t dsl_dataset_tryown(dsl_dataset_t *ds, void *tag);
2669adfa60dSMatthew Ahrens int dsl_dataset_namelen(dsl_dataset_t *ds);
2679c3fd121SMatthew Ahrens boolean_t dsl_dataset_has_owner(dsl_dataset_t *ds);
268745cd3c5Smaybee uint64_t dsl_dataset_create_sync(dsl_dir_t *pds, const char *lastname,
269745cd3c5Smaybee     dsl_dataset_t *origin, uint64_t flags, cred_t *, dmu_tx_t *);
270088f3894Sahrens uint64_t dsl_dataset_create_sync_dd(dsl_dir_t *dd, dsl_dataset_t *origin,
271088f3894Sahrens     uint64_t flags, dmu_tx_t *tx);
2723b2aab18SMatthew Ahrens int dsl_dataset_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t *errors);
273dfc11533SChris Williamson void dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx);
274dfc11533SChris Williamson int dsl_dataset_promote_check(void *arg, dmu_tx_t *tx);
275681d9761SEric Taylor int dsl_dataset_promote(const char *name, char *conflsnap);
2763cb34c60Sahrens int dsl_dataset_clone_swap(dsl_dataset_t *clone, dsl_dataset_t *origin_head,
2773cb34c60Sahrens     boolean_t force);
2783b2aab18SMatthew Ahrens int dsl_dataset_rename_snapshot(const char *fsname,
2793b2aab18SMatthew Ahrens     const char *oldsnapname, const char *newsnapname, boolean_t recursive);
2803b2aab18SMatthew Ahrens int dsl_dataset_snapshot_tmp(const char *fsname, const char *snapname,
2813b2aab18SMatthew Ahrens     minor_t cleanup_minor, const char *htag);
282fa9e4066Sahrens 
283c717a561Smaybee blkptr_t *dsl_dataset_get_blkptr(dsl_dataset_t *ds);
284fa9e4066Sahrens 
285fa9e4066Sahrens spa_t *dsl_dataset_get_spa(dsl_dataset_t *ds);
286fa9e4066Sahrens 
28734f2f8cfSMatthew Ahrens boolean_t dsl_dataset_modified_since_snap(dsl_dataset_t *ds,
28834f2f8cfSMatthew Ahrens     dsl_dataset_t *snap);
289f18faf3fSek 
290c717a561Smaybee void dsl_dataset_sync(dsl_dataset_t *os, zio_t *zio, dmu_tx_t *tx);
291bfaed0b9SAndriy Gapon void dsl_dataset_sync_done(dsl_dataset_t *os, dmu_tx_t *tx);
292fa9e4066Sahrens 
293b24ab676SJeff Bonwick void dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp,
294c717a561Smaybee     dmu_tx_t *tx);
295b24ab676SJeff Bonwick int dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp,
296b24ab676SJeff Bonwick     dmu_tx_t *tx, boolean_t async);
297fa9e4066Sahrens 
298fa9e4066Sahrens void dsl_dataset_dirty(dsl_dataset_t *ds, dmu_tx_t *tx);
299dfc11533SChris Williamson 
300dfc11533SChris Williamson int get_clones_stat_impl(dsl_dataset_t *ds, nvlist_t *val);
301dfc11533SChris Williamson char *get_receive_resume_stats_impl(dsl_dataset_t *ds);
302dfc11533SChris Williamson char *get_child_receive_stats(dsl_dataset_t *ds);
303dfc11533SChris Williamson uint64_t dsl_get_refratio(dsl_dataset_t *ds);
304dfc11533SChris Williamson uint64_t dsl_get_logicalreferenced(dsl_dataset_t *ds);
305dfc11533SChris Williamson uint64_t dsl_get_compressratio(dsl_dataset_t *ds);
306dfc11533SChris Williamson uint64_t dsl_get_used(dsl_dataset_t *ds);
307dfc11533SChris Williamson uint64_t dsl_get_creation(dsl_dataset_t *ds);
308dfc11533SChris Williamson uint64_t dsl_get_creationtxg(dsl_dataset_t *ds);
309dfc11533SChris Williamson uint64_t dsl_get_refquota(dsl_dataset_t *ds);
310dfc11533SChris Williamson uint64_t dsl_get_refreservation(dsl_dataset_t *ds);
311dfc11533SChris Williamson uint64_t dsl_get_guid(dsl_dataset_t *ds);
312dfc11533SChris Williamson uint64_t dsl_get_unique(dsl_dataset_t *ds);
313dfc11533SChris Williamson uint64_t dsl_get_objsetid(dsl_dataset_t *ds);
314dfc11533SChris Williamson uint64_t dsl_get_userrefs(dsl_dataset_t *ds);
315dfc11533SChris Williamson uint64_t dsl_get_defer_destroy(dsl_dataset_t *ds);
316dfc11533SChris Williamson uint64_t dsl_get_referenced(dsl_dataset_t *ds);
317dfc11533SChris Williamson uint64_t dsl_get_numclones(dsl_dataset_t *ds);
318dfc11533SChris Williamson uint64_t dsl_get_inconsistent(dsl_dataset_t *ds);
319dfc11533SChris Williamson uint64_t dsl_get_available(dsl_dataset_t *ds);
320dfc11533SChris Williamson int dsl_get_written(dsl_dataset_t *ds, uint64_t *written);
321dfc11533SChris Williamson int dsl_get_prev_snap(dsl_dataset_t *ds, char *snap);
322dfc11533SChris Williamson int dsl_get_mountpoint(dsl_dataset_t *ds, const char *dsname, char *value,
323dfc11533SChris Williamson     char *source);
324dfc11533SChris Williamson 
325dfc11533SChris Williamson void get_clones_stat(dsl_dataset_t *ds, nvlist_t *nv);
326dfc11533SChris Williamson 
327a2eea2e1Sahrens void dsl_dataset_stats(dsl_dataset_t *os, nvlist_t *nv);
328dfc11533SChris Williamson 
329a2eea2e1Sahrens void dsl_dataset_fast_stat(dsl_dataset_t *ds, dmu_objset_stats_t *stat);
330a2eea2e1Sahrens void dsl_dataset_space(dsl_dataset_t *ds,
331a2eea2e1Sahrens     uint64_t *refdbytesp, uint64_t *availbytesp,
332a2eea2e1Sahrens     uint64_t *usedobjsp, uint64_t *availobjsp);
333a2eea2e1Sahrens uint64_t dsl_dataset_fsid_guid(dsl_dataset_t *ds);
33419b94df9SMatthew Ahrens int dsl_dataset_space_written(dsl_dataset_t *oldsnap, dsl_dataset_t *new,
33519b94df9SMatthew Ahrens     uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
33619b94df9SMatthew Ahrens int dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap, dsl_dataset_t *last,
33719b94df9SMatthew Ahrens     uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
3382e2c1355SMatthew Ahrens boolean_t dsl_dataset_is_dirty(dsl_dataset_t *ds);
339fa9e4066Sahrens 
340b1b8ab34Slling int dsl_dsobj_to_dsname(char *pname, uint64_t obj, char *buf);
341b1b8ab34Slling 
342a9799022Sck int dsl_dataset_check_quota(dsl_dataset_t *ds, boolean_t check_quota,
3439082849eSck     uint64_t asize, uint64_t inflight, uint64_t *used,
3449082849eSck     uint64_t *ref_rsrv);
3453b2aab18SMatthew Ahrens int dsl_dataset_set_refquota(const char *dsname, zprop_source_t source,
34692241e0bSTom Erickson     uint64_t quota);
3473b2aab18SMatthew Ahrens int dsl_dataset_set_refreservation(const char *dsname, zprop_source_t source,
34892241e0bSTom Erickson     uint64_t reservation);
349a9799022Sck 
35078f17100SMatthew Ahrens boolean_t dsl_dataset_is_before(dsl_dataset_t *later, dsl_dataset_t *earlier,
35178f17100SMatthew Ahrens     uint64_t earlier_txg);
3523b2aab18SMatthew Ahrens void dsl_dataset_long_hold(dsl_dataset_t *ds, void *tag);
3533b2aab18SMatthew Ahrens void dsl_dataset_long_rele(dsl_dataset_t *ds, void *tag);
3543b2aab18SMatthew Ahrens boolean_t dsl_dataset_long_held(dsl_dataset_t *ds);
3553b2aab18SMatthew Ahrens 
3563b2aab18SMatthew Ahrens int dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
35791948b51SKeith M Wesolowski     dsl_dataset_t *origin_head, boolean_t force, void *owner, dmu_tx_t *tx);
3583b2aab18SMatthew Ahrens void dsl_dataset_clone_swap_sync_impl(dsl_dataset_t *clone,
3593b2aab18SMatthew Ahrens     dsl_dataset_t *origin_head, dmu_tx_t *tx);
3603b2aab18SMatthew Ahrens int dsl_dataset_snapshot_check_impl(dsl_dataset_t *ds, const char *snapname,
361a2afb611SJerry Jelinek     dmu_tx_t *tx, boolean_t recv, uint64_t cnt, cred_t *cr);
3623b2aab18SMatthew Ahrens void dsl_dataset_snapshot_sync_impl(dsl_dataset_t *ds, const char *snapname,
3633b2aab18SMatthew Ahrens     dmu_tx_t *tx);
3643b2aab18SMatthew Ahrens 
3653b2aab18SMatthew Ahrens void dsl_dataset_remove_from_next_clones(dsl_dataset_t *ds, uint64_t obj,
3663b2aab18SMatthew Ahrens     dmu_tx_t *tx);
3673b2aab18SMatthew Ahrens void dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds);
3683b2aab18SMatthew Ahrens int dsl_dataset_get_snapname(dsl_dataset_t *ds);
3693b2aab18SMatthew Ahrens int dsl_dataset_snap_lookup(dsl_dataset_t *ds, const char *name,
3703b2aab18SMatthew Ahrens     uint64_t *value);
371a2afb611SJerry Jelinek int dsl_dataset_snap_remove(dsl_dataset_t *ds, const char *name, dmu_tx_t *tx,
372a2afb611SJerry Jelinek     boolean_t adj_cnt);
3733b2aab18SMatthew Ahrens void dsl_dataset_set_refreservation_sync_impl(dsl_dataset_t *ds,
3743b2aab18SMatthew Ahrens     zprop_source_t source, uint64_t value, dmu_tx_t *tx);
37578f17100SMatthew Ahrens void dsl_dataset_zapify(dsl_dataset_t *ds, dmu_tx_t *tx);
3769c3fd121SMatthew Ahrens boolean_t dsl_dataset_is_zapified(dsl_dataset_t *ds);
3779c3fd121SMatthew Ahrens boolean_t dsl_dataset_has_resume_receive_state(dsl_dataset_t *ds);
378*77b17137SAndriy Gapon int dsl_dataset_rollback(const char *fsname, const char *tosnap, void *owner,
379*77b17137SAndriy Gapon     nvlist_t *result);
380503ad85cSMatthew Ahrens 
381ca0cc391SMatthew Ahrens void dsl_dataset_deactivate_feature(uint64_t dsobj,
382ca0cc391SMatthew Ahrens     spa_feature_t f, dmu_tx_t *tx);
383ca0cc391SMatthew Ahrens 
384fa9e4066Sahrens #ifdef ZFS_DEBUG
385fa9e4066Sahrens #define	dprintf_ds(ds, fmt, ...) do { \
386fa9e4066Sahrens 	if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
3879adfa60dSMatthew Ahrens 	char *__ds_name = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); \
388fa9e4066Sahrens 	dsl_dataset_name(ds, __ds_name); \
389fa9e4066Sahrens 	dprintf("ds=%s " fmt, __ds_name, __VA_ARGS__); \
3909adfa60dSMatthew Ahrens 	kmem_free(__ds_name, ZFS_MAX_DATASET_NAME_LEN); \
391fa9e4066Sahrens 	} \
392fa9e4066Sahrens _NOTE(CONSTCOND) } while (0)
393fa9e4066Sahrens #else
394fa9e4066Sahrens #define	dprintf_ds(dd, fmt, ...)
395fa9e4066Sahrens #endif
396fa9e4066Sahrens 
397fa9e4066Sahrens #ifdef	__cplusplus
398fa9e4066Sahrens }
399fa9e4066Sahrens #endif
400fa9e4066Sahrens 
401fa9e4066Sahrens #endif /* _SYS_DSL_DATASET_H */
402