fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
a2afb611b30628fb74ad9eade4ae465f9031e262Jerry Jelinek * Copyright (c) 2013, Joyent, Inc. All rights reserved.
a7a845e4bf22fd1b2a284729ccd95c7370a0438cSteven Hartland * Copyright (c) 2013 Steven Hartland. All rights reserved.
bc9014e6a81272073b9854d9f65dd59e18d18c35Justin Gibbs * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
c3d26abc9ee97b4f60233556aadeb57e0bd30bb9Matthew Ahrens * Copyright (c) 2014 Integros [integros.com]
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
c1379625401dfbe1c39b79136dd384a571d47fdeJustin T. Gibbs (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_INCONSISTENT)
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * Do not allow this dataset to be promoted.
a9799022bd90b13722204e80112efaa5bf573099ck * DS_FLAG_UNIQUE_ACCURATE is set if ds_unique_bytes has been correctly
a9799022bd90b13722204e80112efaa5bf573099ck * calculated for head datasets (starting with SPA_VERSION_UNIQUE_ACCURATE,
842727c2f41f01b380de4f5e787d905702870f23Chris Kirby * DS_FLAG_DEFER_DESTROY is set after 'zfs destroy -d' has been called
842727c2f41f01b380de4f5e787d905702870f23Chris Kirby * on a dataset. This allows the dataset to be destroyed using 'zfs release'.
c1379625401dfbe1c39b79136dd384a571d47fdeJustin T. Gibbs (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_DEFER_DESTROY)
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * DS_FIELD_* are strings that are used in the "extensified" dataset zap object.
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * They should be of the format <reverse-dns>:<field>.
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrens * This field's value is the object ID of a zap object which contains the
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrens * bookmarks of this dataset. If it is present, then this dataset is counted
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrens * in the refcount of the SPA_FEATURES_BOOKMARKS feature.
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrens#define DS_FIELD_BOOKMARK_NAMES "com.delphix:bookmarks"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens * These fields are set on datasets that are in the middle of a resumable
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens * receive, and allow the sender to resume the send if it is interrupted.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_FROMGUID "com.delphix:resume_fromguid"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_TONAME "com.delphix:resume_toname"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_TOGUID "com.delphix:resume_toguid"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_OBJECT "com.delphix:resume_object"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_OFFSET "com.delphix:resume_offset"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_BYTES "com.delphix:resume_bytes"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel#define DS_FIELD_RESUME_LARGEBLOCK "com.delphix:resume_largeblockok"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#define DS_FIELD_RESUME_EMBEDOK "com.delphix:resume_embedok"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel#define DS_FIELD_RESUME_COMPRESSOK "com.delphix:resume_compressok"
ab04eb8ef60d9dc9614d6cccffc474f24ca1d162timh * DS_FLAG_CI_DATASET is set if the dataset contains a file system whose
ab04eb8ef60d9dc9614d6cccffc474f24ca1d162timh * name lookups should be performed case-insensitively.
088f389458728c464569a5506b58070254fa4f7dahrens uint64_t ds_snapnames_zapobj; /* DMU_OT_DSL_DS_SNAP_MAP 0 for snaps */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t ds_num_children; /* clone/snap children; ==0 for head */
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens uint64_t ds_deadlist_obj; /* DMU_OT_DEADLIST */
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden * ds_referenced_bytes, ds_compressed_bytes, and ds_uncompressed_bytes
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden * include all blocks referenced by this dataset, including those
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden * shared with any other datasets.
63360950109af2ce85a962ca61f40b8782f11100mp uint64_t ds_unique_bytes; /* only relevant to snapshots */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The ds_fsid_guid is a 56-bit ID that can change to avoid
fa9e4066f08beec538e775443c5be79dd423fcabahrens * collisions. The ds_guid is a 64-bit ID that will never
fa9e4066f08beec538e775443c5be79dd423fcabahrens * change, so there is a small probability that it will collide.
bb0ade0978a02d3fe0b0165cd4725fdcb593fbfbahrens uint64_t ds_props_obj; /* DMU_OT_DSL_PROPS for snaps */
842727c2f41f01b380de4f5e787d905702870f23Chris Kirby uint64_t ds_pad[5]; /* pad out to 320 bytes for good measure */
c166b69d29138aed7a415fe7cef698e54c6ae945Paul Dagnelie rrwlock_t ds_bp_rwlock; /* Protects ds_phys->ds_bp */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Immutable: */
74e7dc986c89efca1f2e4451c7a572e05e4a6e4fMatthew Ahrens /* only used in syncing context, only valid for non-snapshots: */
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrens uint64_t ds_bookmarks; /* DMU_OTN_ZAP_METADATA */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* has internal locking: */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* protected by lock on pool's dp_dirty_datasets list */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ds_phys->ds_<accounting> is also protected by ds_lock.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Protected by ds_lock:
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens * Long holds prevent the ds from being destroyed; they allow the
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens * ds to remain held even after dropping the dp_config_rwlock.
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens * Owning counts as a long hold. See the comments above
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens * dsl_pool_hold() for details.
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens /* no locking; only for making guesses */
91ebeef555ce7f899b6270a3c2df47b51f7ad59aahrens /* for objset_open() */
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens * When in the middle of a resumable receive, tracks how much
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens * progress we have made.
03bad06fbb261fd4a7151a70dfeff2f5041cce1fJustin Gibbs /* Protected by our dsl_dir's dd_lock */
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens * For ZFEATURE_FLAG_PER_DATASET features, set if this dataset
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens * uses this feature.
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens * Set if we need to activate the feature on this dataset this txg
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens * (used only in syncing context).
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens uint8_t ds_feature_activation_needed[SPA_FEATURES];
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Protected by ds_lock; keep at end of struct for better locality */
99d5e173470cf967aa87653364ed614299e7b511Tim Haley * The max length of a temporary tag prefix is the number of hex digits
99d5e173470cf967aa87653364ed614299e7b511Tim Haley * required to express UINT64_MAX plus one for the hyphen.
c1379625401dfbe1c39b79136dd384a571d47fdeJustin T. Gibbs ((dsl_dataset_phys(ds)->ds_flags & DS_FLAG_UNIQUE_ACCURATE) != 0)
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_hold(struct dsl_pool *dp, const char *name, void *tag,
e57a022b8f718889ffa92adbde47a8f08abcdb25Justin T. Gibbsboolean_t dsl_dataset_try_add_ref(struct dsl_pool *dp, dsl_dataset_t *ds,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_hold_obj(struct dsl_pool *dp, uint64_t dsobj, void *tag,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_rele(dsl_dataset_t *ds, void *tag);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_own(struct dsl_pool *dp, const char *name,
745cd3c5371d020efae7a911c58c526aa1fd0dbamaybeeint dsl_dataset_own_obj(struct dsl_pool *dp, uint64_t dsobj,
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrensvoid dsl_dataset_disown(dsl_dataset_t *ds, void *tag);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_name(dsl_dataset_t *ds, char *name);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensboolean_t dsl_dataset_tryown(dsl_dataset_t *ds, void *tag);
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensboolean_t dsl_dataset_has_owner(dsl_dataset_t *ds);
745cd3c5371d020efae7a911c58c526aa1fd0dbamaybeeuint64_t dsl_dataset_create_sync(dsl_dir_t *pds, const char *lastname,
745cd3c5371d020efae7a911c58c526aa1fd0dbamaybee dsl_dataset_t *origin, uint64_t flags, cred_t *, dmu_tx_t *);
088f389458728c464569a5506b58070254fa4f7dahrensuint64_t dsl_dataset_create_sync_dd(dsl_dir_t *dd, dsl_dataset_t *origin,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t *errors);
681d9761e8516a7dc5ab6589e2dfe717777e1123Eric Taylorint dsl_dataset_promote(const char *name, char *conflsnap);
3cb34c601f3ef3016f638574f5982e80c3735c71ahrensint dsl_dataset_clone_swap(dsl_dataset_t *clone, dsl_dataset_t *origin_head,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_rename_snapshot(const char *fsname,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens const char *oldsnapname, const char *newsnapname, boolean_t recursive);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_snapshot_tmp(const char *fsname, const char *snapname,
34f2f8cf94052481c81be2e134b94a00b501bf21Matthew Ahrensboolean_t dsl_dataset_modified_since_snap(dsl_dataset_t *ds,
c717a56157ae0e6fca6a1e3689ae1edc385716a3maybeevoid dsl_dataset_sync(dsl_dataset_t *os, zio_t *zio, dmu_tx_t *tx);
bfaed0b91e57062c38bc16b4f89db3c8f0052a9bAndriy Gaponvoid dsl_dataset_sync_done(dsl_dataset_t *os, dmu_tx_t *tx);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickvoid dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp,
c7cd242109c82107ec2e50013369e92be9d77702George Wilsonboolean_t dsl_dataset_block_freeable(dsl_dataset_t *ds, const blkptr_t *bp,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockuint64_t dsl_dataset_prev_snap_txg(dsl_dataset_t *ds);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid dsl_dataset_dirty(dsl_dataset_t *ds, dmu_tx_t *tx);
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrensvoid dsl_dataset_stats(dsl_dataset_t *os, nvlist_t *nv);
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrensvoid dsl_dataset_fast_stat(dsl_dataset_t *ds, dmu_objset_stats_t *stat);
19b94df933188a15d4f0d6c568f0bab3f127892eMatthew Ahrensint dsl_dataset_space_written(dsl_dataset_t *oldsnap, dsl_dataset_t *new,
19b94df933188a15d4f0d6c568f0bab3f127892eMatthew Ahrens uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
19b94df933188a15d4f0d6c568f0bab3f127892eMatthew Ahrensint dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap, dsl_dataset_t *last,
19b94df933188a15d4f0d6c568f0bab3f127892eMatthew Ahrens uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
2e2c135528b3edfe9aaf67d1f004dc0202fa1a54Matthew Ahrensboolean_t dsl_dataset_is_dirty(dsl_dataset_t *ds);
b1b8ab34de515a5e83206da22c3d7e563241b021llingint dsl_dsobj_to_dsname(char *pname, uint64_t obj, char *buf);
a9799022bd90b13722204e80112efaa5bf573099ckint dsl_dataset_check_quota(dsl_dataset_t *ds, boolean_t check_quota,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_set_refquota(const char *dsname, zprop_source_t source,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_set_refreservation(const char *dsname, zprop_source_t source,
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrensboolean_t dsl_dataset_is_before(dsl_dataset_t *later, dsl_dataset_t *earlier,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_long_hold(dsl_dataset_t *ds, void *tag);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_long_rele(dsl_dataset_t *ds, void *tag);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensboolean_t dsl_dataset_long_held(dsl_dataset_t *ds);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
91948b51b8e978ddc88a36b2bc3ae83c20cdc9aaKeith M Wesolowski dsl_dataset_t *origin_head, boolean_t force, void *owner, dmu_tx_t *tx);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_clone_swap_sync_impl(dsl_dataset_t *clone,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_snapshot_check_impl(dsl_dataset_t *ds, const char *snapname,
a2afb611b30628fb74ad9eade4ae465f9031e262Jerry Jelinek dmu_tx_t *tx, boolean_t recv, uint64_t cnt, cred_t *cr);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_snapshot_sync_impl(dsl_dataset_t *ds, const char *snapname,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_remove_from_next_clones(dsl_dataset_t *ds, uint64_t obj,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_get_snapname(dsl_dataset_t *ds);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensint dsl_dataset_snap_lookup(dsl_dataset_t *ds, const char *name,
a2afb611b30628fb74ad9eade4ae465f9031e262Jerry Jelinekint dsl_dataset_snap_remove(dsl_dataset_t *ds, const char *name, dmu_tx_t *tx,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensvoid dsl_dataset_set_refreservation_sync_impl(dsl_dataset_t *ds,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens zprop_source_t source, uint64_t value, dmu_tx_t *tx);
78f171005391b928aaf1642b3206c534ed644332Matthew Ahrensvoid dsl_dataset_zapify(dsl_dataset_t *ds, dmu_tx_t *tx);
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensboolean_t dsl_dataset_is_zapified(dsl_dataset_t *ds);
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensboolean_t dsl_dataset_has_resume_receive_state(dsl_dataset_t *ds);
a7027df17fad220a20367b9d1eb251bc6300d203Matthew Ahrensint dsl_dataset_rollback(const char *fsname, void *owner, nvlist_t *result);
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrensvoid dsl_dataset_deactivate_feature(uint64_t dsobj,
9adfa60d484ce2435f5af77cc99dcd4e692b6660Matthew Ahrens char *__ds_name = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); \
9adfa60d484ce2435f5af77cc99dcd4e692b6660Matthew Ahrens kmem_free(__ds_name, ZFS_MAX_DATASET_NAME_LEN); \
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif /* _SYS_DSL_DATASET_H */