FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 00022 /* 00023 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 00024 * Copyright (c) 2012 by Delphix. All rights reserved. 00025 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 00026 * Copyright (c) 2012, Joyent, Inc. All rights reserved. 00027 */ 00028 00029 /* Portions Copyright 2010 Robert Milkowski */ 00030 00031 #ifndef _SYS_DMU_H 00032 #define _SYS_DMU_H 00033 00044 #include <sys/types.h> 00045 #include <sys/param.h> 00046 #include <sys/cred.h> 00047 #include <sys/time.h> 00048 00049 #ifdef __cplusplus 00050 extern "C" { 00051 #endif 00052 00053 struct uio; 00054 struct xuio; 00055 struct page; 00056 struct vnode; 00057 struct spa; 00058 struct zilog; 00059 struct zio; 00060 struct blkptr; 00061 struct zap_cursor; 00062 struct dsl_dataset; 00063 struct dsl_pool; 00064 struct dnode; 00065 struct drr_begin; 00066 struct drr_end; 00067 struct zbookmark; 00068 struct spa; 00069 struct nvlist; 00070 struct arc_buf; 00071 struct zio_prop; 00072 struct sa_handle; 00073 struct file; 00074 00075 typedef struct objset objset_t; 00076 typedef struct dmu_tx dmu_tx_t; 00077 typedef struct dsl_dir dsl_dir_t; 00078 00079 typedef enum dmu_object_byteswap { 00080 DMU_BSWAP_UINT8, 00081 DMU_BSWAP_UINT16, 00082 DMU_BSWAP_UINT32, 00083 DMU_BSWAP_UINT64, 00084 DMU_BSWAP_ZAP, 00085 DMU_BSWAP_DNODE, 00086 DMU_BSWAP_OBJSET, 00087 DMU_BSWAP_ZNODE, 00088 DMU_BSWAP_OLDACL, 00089 DMU_BSWAP_ACL, 00090 /* 00091 * Allocating a new byteswap type number makes the on-disk format 00092 * incompatible with any other format that uses the same number. 00093 * 00094 * Data can usually be structured to work with one of the 00095 * DMU_BSWAP_UINT* or DMU_BSWAP_ZAP types. 00096 */ 00097 DMU_BSWAP_NUMFUNCS 00098 } dmu_object_byteswap_t; 00099 00100 #define DMU_OT_NEWTYPE 0x80 00101 #define DMU_OT_METADATA 0x40 00102 #define DMU_OT_BYTESWAP_MASK 0x3f 00103 00109 #define DMU_OT(byteswap, metadata) \ 00110 (DMU_OT_NEWTYPE | \ 00111 ((metadata) ? DMU_OT_METADATA : 0) | \ 00112 ((byteswap) & DMU_OT_BYTESWAP_MASK)) 00113 00114 #define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \ 00115 ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \ 00116 (ot) < DMU_OT_NUMTYPES) 00117 00118 #define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \ 00119 ((ot) & DMU_OT_METADATA) : \ 00120 dmu_ot[(ot)].ot_metadata) 00121 00122 #define DMU_OT_BYTESWAP(ot) (((ot) & DMU_OT_NEWTYPE) ? \ 00123 ((ot) & DMU_OT_BYTESWAP_MASK) : \ 00124 dmu_ot[(ot)].ot_byteswap) 00125 00126 typedef enum dmu_object_type { 00127 DMU_OT_NONE, 00128 /* general: */ 00129 DMU_OT_OBJECT_DIRECTORY, 00130 DMU_OT_OBJECT_ARRAY, 00131 DMU_OT_PACKED_NVLIST, 00132 DMU_OT_PACKED_NVLIST_SIZE, 00133 DMU_OT_BPOBJ, 00134 DMU_OT_BPOBJ_HDR, 00135 /* spa: */ 00136 DMU_OT_SPACE_MAP_HEADER, 00137 DMU_OT_SPACE_MAP, 00138 /* zil: */ 00139 DMU_OT_INTENT_LOG, 00140 /* dmu: */ 00141 DMU_OT_DNODE, 00142 DMU_OT_OBJSET, 00143 /* dsl: */ 00144 DMU_OT_DSL_DIR, 00145 DMU_OT_DSL_DIR_CHILD_MAP, 00146 DMU_OT_DSL_DS_SNAP_MAP, 00147 DMU_OT_DSL_PROPS, 00148 DMU_OT_DSL_DATASET, 00149 /* zpl: */ 00150 DMU_OT_ZNODE, 00151 DMU_OT_OLDACL, 00152 DMU_OT_PLAIN_FILE_CONTENTS, 00153 DMU_OT_DIRECTORY_CONTENTS, 00154 DMU_OT_MASTER_NODE, 00155 DMU_OT_UNLINKED_SET, 00156 /* zvol: */ 00157 DMU_OT_ZVOL, 00158 DMU_OT_ZVOL_PROP, 00159 /* other; for testing only! */ 00160 DMU_OT_PLAIN_OTHER, 00161 DMU_OT_UINT64_OTHER, 00162 DMU_OT_ZAP_OTHER, 00163 /* new object types: */ 00164 DMU_OT_ERROR_LOG, 00165 DMU_OT_SPA_HISTORY, 00166 DMU_OT_SPA_HISTORY_OFFSETS, 00167 DMU_OT_POOL_PROPS, 00168 DMU_OT_DSL_PERMS, 00169 DMU_OT_ACL, 00170 DMU_OT_SYSACL, 00171 DMU_OT_FUID, 00172 DMU_OT_FUID_SIZE, 00173 DMU_OT_NEXT_CLONES, 00174 DMU_OT_SCAN_QUEUE, 00175 DMU_OT_USERGROUP_USED, 00176 DMU_OT_USERGROUP_QUOTA, 00177 DMU_OT_USERREFS, 00178 DMU_OT_DDT_ZAP, 00179 DMU_OT_DDT_STATS, 00180 DMU_OT_SA, 00181 DMU_OT_SA_MASTER_NODE, 00182 DMU_OT_SA_ATTR_REGISTRATION, 00183 DMU_OT_SA_ATTR_LAYOUTS, 00184 DMU_OT_SCAN_XLATE, 00185 DMU_OT_DEDUP, 00186 DMU_OT_DEADLIST, 00187 DMU_OT_DEADLIST_HDR, 00188 DMU_OT_DSL_CLONES, 00189 DMU_OT_BPOBJ_SUBOBJ, 00190 /* 00191 * Do not allocate new object types here. Doing so makes the on-disk 00192 * format incompatible with any other format that uses the same object 00193 * type number. 00194 * 00195 * When creating an object which does not have one of the above types 00196 * use the DMU_OTN_* type with the correct byteswap and metadata 00197 * values. 00198 * 00199 * The DMU_OTN_* types do not have entries in the dmu_ot table, 00200 * use the DMU_OT_IS_METDATA() and DMU_OT_BYTESWAP() macros instead 00201 * of indexing into dmu_ot directly (this works for both DMU_OT_* types 00202 * and DMU_OTN_* types). 00203 */ 00204 DMU_OT_NUMTYPES, 00205 00206 /* 00207 * Names for valid types declared with DMU_OT(). 00208 */ 00209 DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE), 00210 DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE), 00211 DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE), 00212 DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE), 00213 DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE), 00214 DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE), 00215 DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE), 00216 DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE), 00217 DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE), 00218 DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE), 00219 } dmu_object_type_t; 00220 00221 typedef enum dmu_objset_type { 00222 DMU_OST_NONE, 00223 DMU_OST_META, 00224 DMU_OST_ZFS, 00225 DMU_OST_ZVOL, 00226 DMU_OST_OTHER, 00227 DMU_OST_ANY, 00228 DMU_OST_NUMTYPES 00229 } dmu_objset_type_t; 00230 00231 void byteswap_uint64_array(void *buf, size_t size); 00232 void byteswap_uint32_array(void *buf, size_t size); 00233 void byteswap_uint16_array(void *buf, size_t size); 00234 void byteswap_uint8_array(void *buf, size_t size); 00235 void zap_byteswap(void *buf, size_t size); 00236 void zfs_oldacl_byteswap(void *buf, size_t size); 00237 void zfs_acl_byteswap(void *buf, size_t size); 00238 void zfs_znode_byteswap(void *buf, size_t size); 00239 00240 #define DS_FIND_SNAPSHOTS (1<<0) 00241 #define DS_FIND_CHILDREN (1<<1) 00242 00247 #define DMU_MAX_ACCESS (10<<20) /* 10MB */ 00248 #define DMU_MAX_DELETEBLKCNT (20480) /* ~5MB of indirect blocks */ 00249 00250 #define DMU_USERUSED_OBJECT (-1ULL) 00251 #define DMU_GROUPUSED_OBJECT (-2ULL) 00252 #define DMU_DEADLIST_OBJECT (-3ULL) 00253 00257 #define DMU_BONUS_BLKID (-1ULL) 00258 00261 #define DMU_SPILL_BLKID (-2ULL) 00262 /* 00263 * Public routines to create, destroy, open, and close objsets. 00264 */ 00265 int dmu_objset_hold(const char *name, void *tag, objset_t **osp); 00266 int dmu_objset_own(const char *name, dmu_objset_type_t type, 00267 boolean_t readonly, void *tag, objset_t **osp); 00268 void dmu_objset_rele(objset_t *os, void *tag); 00269 void dmu_objset_disown(objset_t *os, void *tag); 00270 int dmu_objset_open_ds(struct dsl_dataset *ds, objset_t **osp); 00271 00272 int dmu_objset_evict_dbufs(objset_t *os); 00273 int dmu_objset_create(const char *name, dmu_objset_type_t type, uint64_t flags, 00274 void (*func)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx), void *arg); 00275 int dmu_objset_clone(const char *name, struct dsl_dataset *clone_origin, 00276 uint64_t flags); 00277 int dmu_objset_destroy(const char *name, boolean_t defer); 00278 int dmu_get_recursive_snaps_nvl(const char *fsname, const char *snapname, 00279 struct nvlist *snaps); 00280 int dmu_snapshots_destroy_nvl(struct nvlist *snaps, boolean_t defer, char *); 00281 int dmu_objset_snapshot(char *fsname, char *snapname, char *tag, 00282 struct nvlist *props, boolean_t recursive, boolean_t temporary, int fd); 00283 int dmu_objset_rename(const char *name, const char *newname, 00284 boolean_t recursive); 00285 int dmu_objset_find(const char *name, int func(const char *, void *), void *arg, 00286 int flags); 00287 void dmu_objset_byteswap(void *buf, size_t size); 00288 00289 typedef struct dmu_buf { 00290 uint64_t db_object; 00291 uint64_t db_offset; 00292 uint64_t db_size; 00293 void *db_data; 00294 } dmu_buf_t; 00295 00296 typedef void dmu_buf_evict_func_t(struct dmu_buf *db, void *user_ptr); 00297 00298 /* 00299 * The names of zap entries in the DIRECTORY_OBJECT of the MOS. 00300 */ 00301 #define DMU_POOL_DIRECTORY_OBJECT 1 00302 #define DMU_POOL_CONFIG "config" 00303 #define DMU_POOL_FEATURES_FOR_WRITE "features_for_write" 00304 #define DMU_POOL_FEATURES_FOR_READ "features_for_read" 00305 #define DMU_POOL_FEATURE_DESCRIPTIONS "feature_descriptions" 00306 #define DMU_POOL_ROOT_DATASET "root_dataset" 00307 #define DMU_POOL_SYNC_BPOBJ "sync_bplist" 00308 #define DMU_POOL_ERRLOG_SCRUB "errlog_scrub" 00309 #define DMU_POOL_ERRLOG_LAST "errlog_last" 00310 #define DMU_POOL_SPARES "spares" 00311 #define DMU_POOL_DEFLATE "deflate" 00312 #define DMU_POOL_HISTORY "history" 00313 #define DMU_POOL_PROPS "pool_props" 00314 #define DMU_POOL_L2CACHE "l2cache" 00315 #define DMU_POOL_TMP_USERREFS "tmp_userrefs" 00316 #define DMU_POOL_DDT "DDT-%s-%s-%s" 00317 #define DMU_POOL_DDT_STATS "DDT-statistics" 00318 #define DMU_POOL_CREATION_VERSION "creation_version" 00319 #define DMU_POOL_SCAN "scan" 00320 #define DMU_POOL_FREE_BPOBJ "free_bpobj" 00321 #define DMU_POOL_BPTREE_OBJ "bptree_obj" 00322 #define DMU_POOL_EMPTY_BPOBJ "empty_bpobj" 00323 00337 uint64_t dmu_object_alloc(objset_t *os, dmu_object_type_t ot, 00338 int blocksize, dmu_object_type_t bonus_type, int bonus_len, dmu_tx_t *tx); 00339 00346 int dmu_object_claim(objset_t *os, uint64_t object, dmu_object_type_t ot, 00347 int blocksize, dmu_object_type_t bonus_type, int bonus_len, dmu_tx_t *tx); 00348 int dmu_object_reclaim(objset_t *os, uint64_t object, dmu_object_type_t ot, 00349 int blocksize, dmu_object_type_t bonustype, int bonuslen); 00350 00365 int dmu_object_free(objset_t *os, uint64_t object, dmu_tx_t *tx); 00366 00380 int dmu_object_next(objset_t *os, uint64_t *objectp, 00381 boolean_t hole, uint64_t txg); 00382 00395 int dmu_object_set_blocksize(objset_t *os, uint64_t object, uint64_t size, 00396 int ibs, dmu_tx_t *tx); 00397 00402 void dmu_object_set_checksum(objset_t *os, uint64_t object, uint8_t checksum, 00403 dmu_tx_t *tx); 00404 00409 void dmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress, 00410 dmu_tx_t *tx); 00411 00412 #define WP_NOFILL 0x1 00413 #define WP_DMU_SYNC 0x2 00414 #define WP_SPILL 0x4 00415 00421 void dmu_write_policy(objset_t *os, struct dnode *dn, int level, int wp, 00422 struct zio_prop *zp); 00423 00436 int dmu_bonus_hold(objset_t *os, uint64_t object, void *tag, dmu_buf_t **); 00437 int dmu_bonus_max(void); 00438 int dmu_set_bonus(dmu_buf_t *, int, dmu_tx_t *); 00439 int dmu_set_bonustype(dmu_buf_t *, dmu_object_type_t, dmu_tx_t *); 00440 dmu_object_type_t dmu_get_bonustype(dmu_buf_t *); 00441 int dmu_rm_spill(objset_t *, uint64_t, dmu_tx_t *); 00442 00443 /* 00444 * Special spill buffer support used by "SA" framework 00445 */ 00446 00447 int dmu_spill_hold_by_bonus(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp); 00448 int dmu_spill_hold_by_dnode(struct dnode *dn, uint32_t flags, 00449 void *tag, dmu_buf_t **dbp); 00450 int dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp); 00451 00466 int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset, 00467 void *tag, dmu_buf_t **, int flags); 00468 void dmu_buf_add_ref(dmu_buf_t *db, void* tag); 00469 void dmu_buf_rele(dmu_buf_t *db, void *tag); 00470 uint64_t dmu_buf_refcount(dmu_buf_t *db); 00471 00476 int dmu_buf_hold_array_by_bonus(dmu_buf_t *db, uint64_t offset, 00477 uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp); 00478 00484 void dmu_buf_rele_array(dmu_buf_t **, int numbufs, void *tag); 00485 00510 void *dmu_buf_set_user(dmu_buf_t *db, void *user_ptr, void *user_data_ptr_ptr, 00511 dmu_buf_evict_func_t *evict_func); 00512 00517 void *dmu_buf_set_user_ie(dmu_buf_t *db, void *user_ptr, 00518 void *user_data_ptr_ptr, dmu_buf_evict_func_t *pageout_func); 00519 void *dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, 00520 void *user_ptr, void *user_data_ptr_ptr, 00521 dmu_buf_evict_func_t *pageout_func); 00522 void dmu_evict_user(objset_t *os, dmu_buf_evict_func_t *func); 00523 00527 void *dmu_buf_get_user(dmu_buf_t *db); 00528 00536 void dmu_buf_will_dirty(dmu_buf_t *db, dmu_tx_t *tx); 00537 00541 boolean_t dmu_buf_freeable(dmu_buf_t *); 00542 00564 #define DMU_NEW_OBJECT (-1ULL) 00565 #define DMU_OBJECT_END (-1ULL) 00566 00567 dmu_tx_t *dmu_tx_create(objset_t *os); 00568 void dmu_tx_hold_write(dmu_tx_t *tx, uint64_t object, uint64_t off, int len); 00569 void dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, 00570 uint64_t len); 00571 void dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name); 00572 void dmu_tx_hold_bonus(dmu_tx_t *tx, uint64_t object); 00573 void dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object); 00574 void dmu_tx_hold_sa(dmu_tx_t *tx, struct sa_handle *hdl, boolean_t may_grow); 00575 void dmu_tx_hold_sa_create(dmu_tx_t *tx, int total_size); 00576 void dmu_tx_abort(dmu_tx_t *tx); 00577 int dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how); 00578 void dmu_tx_wait(dmu_tx_t *tx); 00579 void dmu_tx_commit(dmu_tx_t *tx); 00580 00581 typedef void dmu_tx_callback_func_t(void *dcb_data, int error); 00582 00600 void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *func, 00601 void *data); 00602 00607 int dmu_free_range(objset_t *os, uint64_t object, uint64_t offset, 00608 uint64_t size, dmu_tx_t *tx); 00609 int dmu_free_long_range(objset_t *os, uint64_t object, uint64_t offset, 00610 uint64_t size); 00611 int dmu_free_object(objset_t *os, uint64_t object); 00612 00613 /* 00614 * Convenience functions. 00615 * 00616 * Canfail routines will return 0 on success, or an errno if there is a 00617 * nonrecoverable I/O error. 00618 */ 00619 #define DMU_READ_PREFETCH 0 /* prefetch */ 00620 #define DMU_READ_NO_PREFETCH 1 /* don't prefetch */ 00621 int dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, 00622 void *buf, uint32_t flags); 00623 void dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, 00624 const void *buf, dmu_tx_t *tx); 00625 void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, 00626 dmu_tx_t *tx); 00627 int dmu_read_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size); 00628 int dmu_write_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size, 00629 dmu_tx_t *tx); 00630 int dmu_write_uio_dbuf(dmu_buf_t *zdb, struct uio *uio, uint64_t size, 00631 dmu_tx_t *tx); 00632 int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, 00633 uint64_t size, struct page *pp, dmu_tx_t *tx); 00634 struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size); 00635 void dmu_return_arcbuf(struct arc_buf *buf); 00636 void dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf, 00637 dmu_tx_t *tx); 00638 int dmu_xuio_init(struct xuio *uio, int niov); 00639 void dmu_xuio_fini(struct xuio *uio); 00640 int dmu_xuio_add(struct xuio *uio, struct arc_buf *abuf, offset_t off, 00641 size_t n); 00642 int dmu_xuio_cnt(struct xuio *uio); 00643 struct arc_buf *dmu_xuio_arcbuf(struct xuio *uio, int i); 00644 void dmu_xuio_clear(struct xuio *uio, int i); 00645 void xuio_stat_wbuf_copied(); 00646 void xuio_stat_wbuf_nocopy(); 00647 00648 extern int zfs_prefetch_disable; 00649 00653 void dmu_prefetch(objset_t *os, uint64_t object, uint64_t offset, 00654 uint64_t len); 00655 00657 typedef struct dmu_object_info { 00658 uint32_t doi_data_block_size; 00659 uint32_t doi_metadata_block_size; 00660 dmu_object_type_t doi_type; 00661 dmu_object_type_t doi_bonus_type; 00662 uint64_t doi_bonus_size; 00663 uint8_t doi_indirection; 00664 uint8_t doi_checksum; 00665 uint8_t doi_compress; 00666 uint8_t doi_pad[5]; 00667 uint64_t doi_physical_blocks_512; 00668 uint64_t doi_max_offset; 00669 uint64_t doi_fill_count; 00670 } dmu_object_info_t; 00671 00672 typedef void arc_byteswap_func_t(void *buf, size_t size); 00673 00674 typedef struct dmu_object_type_info { 00675 dmu_object_byteswap_t ot_byteswap; 00676 boolean_t ot_metadata; 00677 char *ot_name; 00678 } dmu_object_type_info_t; 00679 00680 typedef struct dmu_object_byteswap_info { 00681 arc_byteswap_func_t *ob_func; 00682 char *ob_name; 00683 } dmu_object_byteswap_info_t; 00684 00685 extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES]; 00686 extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS]; 00687 00695 int dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi); 00696 00704 void dmu_object_info_from_dnode(struct dnode *dn, dmu_object_info_t *doi); 00705 00711 void dmu_object_info_from_db(dmu_buf_t *db, dmu_object_info_t *doi); 00712 00719 void dmu_object_size_from_db(dmu_buf_t *db, uint32_t *blksize, 00720 u_longlong_t *nblk512); 00721 00722 typedef struct dmu_objset_stats { 00723 uint64_t dds_num_clones; 00724 uint64_t dds_creation_txg; 00725 uint64_t dds_guid; 00726 dmu_objset_type_t dds_type; 00727 uint8_t dds_is_snapshot; 00728 uint8_t dds_inconsistent; 00729 char dds_origin[MAXNAMELEN]; 00730 } dmu_objset_stats_t; 00731 00735 void dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat); 00736 00741 void dmu_objset_stats(objset_t *os, struct nvlist *nv); 00742 00755 void dmu_objset_space(objset_t *os, uint64_t *refdbytesp, uint64_t *availbytesp, 00756 uint64_t *usedobjsp, uint64_t *availobjsp); 00757 00763 uint64_t dmu_objset_fsid_guid(objset_t *os); 00764 00765 /* 00766 * Get the [cm]time for an objset's snapshot dir 00767 */ 00768 timestruc_t dmu_objset_snap_cmtime(objset_t *os); 00769 00770 int dmu_objset_is_snapshot(objset_t *os); 00771 00772 extern struct spa *dmu_objset_spa(objset_t *os); 00773 extern struct zilog *dmu_objset_zil(objset_t *os); 00774 extern struct dsl_pool *dmu_objset_pool(objset_t *os); 00775 extern struct dsl_dataset *dmu_objset_ds(objset_t *os); 00776 extern void dmu_objset_name(objset_t *os, char *buf); 00777 extern dmu_objset_type_t dmu_objset_type(objset_t *os); 00778 extern uint64_t dmu_objset_id(objset_t *os); 00779 extern uint64_t dmu_objset_syncprop(objset_t *os); 00780 extern uint64_t dmu_objset_logbias(objset_t *os); 00781 extern int dmu_snapshot_list_next(objset_t *os, int namelen, char *name, 00782 uint64_t *id, uint64_t *offp, boolean_t *case_conflict); 00783 extern int dmu_snapshot_realname(objset_t *os, char *name, char *real, 00784 int maxlen, boolean_t *conflict); 00785 extern int dmu_dir_list_next(objset_t *os, int namelen, char *name, 00786 uint64_t *idp, uint64_t *offp); 00787 00788 typedef int objset_used_cb_t(dmu_object_type_t bonustype, 00789 void *bonus, uint64_t *userp, uint64_t *groupp); 00790 extern void dmu_objset_register_type(dmu_objset_type_t ost, 00791 objset_used_cb_t *cb); 00792 extern void dmu_objset_set_user(objset_t *os, void *user_ptr); 00793 extern void *dmu_objset_get_user(objset_t *os); 00794 00798 uint64_t dmu_tx_get_txg(dmu_tx_t *tx); 00799 00803 typedef struct zgd { 00804 struct zilog *zgd_zilog; 00805 struct blkptr *zgd_bp; 00806 dmu_buf_t *zgd_db; 00807 struct rl *zgd_rl; 00808 void *zgd_private; 00809 } zgd_t; 00810 00811 typedef void dmu_sync_cb_t(zgd_t *arg, int error); 00812 00841 int dmu_sync(struct zio *zio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd); 00842 00848 int dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, 00849 uint64_t *off); 00850 00854 extern void dmu_init(void); 00855 00859 extern void dmu_fini(void); 00860 00861 typedef void (*dmu_traverse_cb_t)(objset_t *os, void *arg, struct blkptr *bp, 00862 uint64_t object, uint64_t offset, int len); 00863 void dmu_traverse_objset(objset_t *os, uint64_t txg_start, 00864 dmu_traverse_cb_t cb, void *arg); 00865 00866 int dmu_send(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin, 00867 int outfd, struct file *fp, offset_t *off); 00868 int dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, 00869 boolean_t fromorigin, uint64_t *sizep); 00870 00878 typedef struct dmu_recv_cookie { 00879 struct dsl_dataset *drc_logical_ds; 00880 struct dsl_dataset *drc_real_ds; 00881 struct drr_begin *drc_drrb; 00882 char *drc_tosnap; 00883 char *drc_top_ds; 00884 boolean_t drc_newfs; 00885 boolean_t drc_force; 00886 struct avl_tree *drc_guid_to_ds_map; 00887 } dmu_recv_cookie_t; 00888 00889 int dmu_recv_begin(char *tofs, char *tosnap, char *topds, struct drr_begin *, 00890 boolean_t force, objset_t *origin, dmu_recv_cookie_t *); 00891 int dmu_recv_stream(dmu_recv_cookie_t *drc, struct file *fp, offset_t *voffp, 00892 int cleanup_fd, uint64_t *action_handlep); 00893 int dmu_recv_end(dmu_recv_cookie_t *drc); 00894 00895 int dmu_diff(objset_t *tosnap, objset_t *fromsnap, struct file *fp, 00896 offset_t *off); 00897 00898 #define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL 00899 /* CRC64 table */ 00900 extern uint64_t zfs_crc64_table[256]; 00901 00902 #ifdef __cplusplus 00903 } 00904 #endif 00905 00906 #endif /* _SYS_DMU_H */