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 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 00023 */ 00024 00025 /* Portions Copyright 2010 Robert Milkowski */ 00026 00027 #ifndef _SYS_DMU_OBJSET_H 00028 #define _SYS_DMU_OBJSET_H 00029 00030 #include <sys/spa.h> 00031 #include <sys/arc.h> 00032 #include <sys/txg.h> 00033 #include <sys/zfs_context.h> 00034 #include <sys/dnode.h> 00035 #include <sys/zio.h> 00036 #include <sys/zil.h> 00037 #include <sys/sa.h> 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 extern krwlock_t os_lock; 00044 00045 struct dsl_dataset; 00046 struct dmu_tx; 00047 00048 #define OBJSET_PHYS_SIZE 2048 00049 #define OBJSET_OLD_PHYS_SIZE 1024 00050 00051 #define OBJSET_BUF_HAS_USERUSED(buf) \ 00052 (arc_buf_size(buf) > OBJSET_OLD_PHYS_SIZE) 00053 00054 #define OBJSET_FLAG_USERACCOUNTING_COMPLETE (1ULL<<0) 00055 00056 typedef struct objset_phys { 00057 dnode_phys_t os_meta_dnode; 00058 zil_header_t os_zil_header; 00059 uint64_t os_type; 00060 uint64_t os_flags; 00061 char os_pad[OBJSET_PHYS_SIZE - sizeof (dnode_phys_t)*3 - 00062 sizeof (zil_header_t) - sizeof (uint64_t)*2]; 00063 dnode_phys_t os_userused_dnode; 00064 dnode_phys_t os_groupused_dnode; 00065 } objset_phys_t; 00066 00067 struct objset { 00071 struct dsl_dataset *os_dsl_dataset; 00072 spa_t *os_spa; 00073 arc_buf_t *os_phys_buf; 00074 objset_phys_t *os_phys; 00075 /* 00076 * The following "special" dnodes have no parent and are exempt from 00077 * dnode_move(), but they root their descendents in this objset using 00078 * handles anyway, so that all access to dnodes from dbufs consistently 00079 * uses handles. 00080 */ 00081 dnode_handle_t os_meta_dnode; 00082 dnode_handle_t os_userused_dnode; 00083 dnode_handle_t os_groupused_dnode; 00084 zilog_t *os_zil; 00085 00090 uint8_t os_checksum; 00091 uint8_t os_compress; 00092 uint8_t os_copies; 00093 uint8_t os_dedup_checksum; 00094 uint8_t os_dedup_verify; 00095 uint8_t os_logbias; 00096 uint8_t os_primary_cache; 00097 uint8_t os_secondary_cache; 00098 uint8_t os_sync; 00099 00104 struct dmu_tx *os_synctx; 00105 blkptr_t *os_rootbp; 00106 zil_header_t os_zil_header; 00107 list_t os_synced_dnodes; 00108 uint64_t os_flags; 00109 00114 kmutex_t os_obj_lock; 00115 uint64_t os_obj_next; 00116 00121 kmutex_t os_lock; 00122 list_t os_dirty_dnodes[TXG_SIZE]; 00123 list_t os_free_dnodes[TXG_SIZE]; 00124 list_t os_dnodes; 00125 list_t os_downgraded_dbufs; 00126 00131 kmutex_t os_user_ptr_lock; 00132 void *os_user_ptr; 00133 00138 sa_os_t *os_sa; 00140 }; 00141 00142 #define DMU_META_OBJSET 0 00143 #define DMU_META_DNODE_OBJECT 0 00144 #define DMU_OBJECT_IS_SPECIAL(obj) ((int64_t)(obj) <= 0) 00145 #define DMU_META_DNODE(os) ((os)->os_meta_dnode.dnh_dnode) 00146 #define DMU_USERUSED_DNODE(os) ((os)->os_userused_dnode.dnh_dnode) 00147 #define DMU_GROUPUSED_DNODE(os) ((os)->os_groupused_dnode.dnh_dnode) 00148 00149 #define DMU_OS_IS_L2CACHEABLE(os) \ 00150 ((os)->os_secondary_cache == ZFS_CACHE_ALL || \ 00151 (os)->os_secondary_cache == ZFS_CACHE_METADATA) 00152 00153 /* called from zpl */ 00154 int dmu_objset_hold(const char *name, void *tag, objset_t **osp); 00155 int dmu_objset_own(const char *name, dmu_objset_type_t type, 00156 boolean_t readonly, void *tag, objset_t **osp); 00157 void dmu_objset_rele(objset_t *os, void *tag); 00158 void dmu_objset_disown(objset_t *os, void *tag); 00159 int dmu_objset_from_ds(struct dsl_dataset *ds, objset_t **osp); 00160 00161 int dmu_objset_create(const char *name, dmu_objset_type_t type, uint64_t flags, 00162 void (*func)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx), void *arg); 00163 int dmu_objset_clone(const char *name, struct dsl_dataset *clone_origin, 00164 uint64_t flags); 00165 int dmu_objset_destroy(const char *name, boolean_t defer); 00166 int dmu_objset_snapshot(char *fsname, char *snapname, char *tag, 00167 struct nvlist *props, boolean_t recursive, boolean_t temporary, int fd); 00168 void dmu_objset_stats(objset_t *os, nvlist_t *nv); 00169 void dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat); 00170 void dmu_objset_space(objset_t *os, uint64_t *refdbytesp, uint64_t *availbytesp, 00171 uint64_t *usedobjsp, uint64_t *availobjsp); 00172 uint64_t dmu_objset_fsid_guid(objset_t *os); 00173 int dmu_objset_find(const char *name, int func(const char *, void *), void *arg, 00174 int flags); 00175 int dmu_objset_find_spa(spa_t *spa, const char *name, 00176 int func(spa_t *, uint64_t, const char *, void *), void *arg, int flags); 00177 int dmu_objset_prefetch(const char *name, void *arg); 00178 void dmu_objset_byteswap(void *buf, size_t size); 00179 int dmu_objset_evict_dbufs(objset_t *os); 00180 timestruc_t dmu_objset_snap_cmtime(objset_t *os); 00181 00182 /* called from dsl */ 00183 void dmu_objset_sync(objset_t *os, zio_t *zio, dmu_tx_t *tx); 00184 boolean_t dmu_objset_is_dirty(objset_t *os, uint64_t txg); 00185 objset_t *dmu_objset_create_impl(spa_t *spa, struct dsl_dataset *ds, 00186 blkptr_t *bp, dmu_objset_type_t type, dmu_tx_t *tx); 00187 int dmu_objset_open_impl(spa_t *spa, struct dsl_dataset *ds, blkptr_t *bp, 00188 objset_t **osp); 00189 void dmu_objset_evict(objset_t *os); 00190 void dmu_objset_do_userquota_updates(objset_t *os, dmu_tx_t *tx); 00191 void dmu_objset_userquota_get_ids(dnode_t *dn, boolean_t before, dmu_tx_t *tx); 00192 boolean_t dmu_objset_userused_enabled(objset_t *os); 00193 int dmu_objset_userspace_upgrade(objset_t *os); 00194 boolean_t dmu_objset_userspace_present(objset_t *os); 00195 00196 void dmu_objset_init(void); 00197 void dmu_objset_fini(void); 00198 00199 #ifdef __cplusplus 00200 } 00201 #endif 00202 00203 #endif /* _SYS_DMU_OBJSET_H */