4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_DMU_OBJSET_H
27 #define _SYS_DMU_OBJSET_H
32 #include <sys/zfs_context.h>
33 #include <sys/dnode.h>
45 #define OBJSET_PHYS_SIZE 2048
46 #define OBJSET_OLD_PHYS_SIZE 1024
48 #define OBJSET_FLAG_USERACCOUNTING_COMPLETE (1ULL<<0)
50 typedef struct objset_phys
{
51 dnode_phys_t os_meta_dnode
;
52 zil_header_t os_zil_header
;
55 char os_pad
[OBJSET_PHYS_SIZE
- sizeof (dnode_phys_t
)*3 -
56 sizeof (zil_header_t
) - sizeof (uint64_t)*2];
57 dnode_phys_t os_userused_dnode
;
58 dnode_phys_t os_groupused_dnode
;
62 struct objset_impl
*os
;
66 typedef struct objset_impl
{
68 struct dsl_dataset
*os_dsl_dataset
;
70 arc_buf_t
*os_phys_buf
;
71 objset_phys_t
*os_phys
;
72 dnode_t
*os_meta_dnode
;
73 dnode_t
*os_userused_dnode
;
74 dnode_t
*os_groupused_dnode
;
77 uint8_t os_checksum
; /* can change, under dsl_dir's locks */
78 uint8_t os_compress
; /* can change, under dsl_dir's locks */
79 uint8_t os_copies
; /* can change, under dsl_dir's locks */
80 uint8_t os_primary_cache
; /* can change, under dsl_dir's locks */
81 uint8_t os_secondary_cache
; /* can change, under dsl_dir's locks */
84 struct dmu_tx
*os_synctx
; /* XXX sketchy */
86 zil_header_t os_zil_header
;
87 list_t os_synced_dnodes
;
90 /* Protected by os_obj_lock */
94 /* Protected by os_lock */
96 list_t os_dirty_dnodes
[TXG_SIZE
];
97 list_t os_free_dnodes
[TXG_SIZE
];
99 list_t os_downgraded_dbufs
;
101 /* stuff we store for the user */
102 kmutex_t os_user_ptr_lock
;
106 #define DMU_META_DNODE_OBJECT 0
107 #define DMU_OBJECT_IS_SPECIAL(obj) ((int64_t)(obj) <= 0)
109 #define DMU_OS_IS_L2CACHEABLE(os) \
110 ((os)->os_secondary_cache == ZFS_CACHE_ALL || \
111 (os)->os_secondary_cache == ZFS_CACHE_METADATA)
113 /* called from zpl */
114 int dmu_objset_open(const char *name
, dmu_objset_type_t type
, int mode
,
116 void dmu_objset_close(objset_t
*os
);
117 int dmu_objset_create(const char *name
, dmu_objset_type_t type
,
118 objset_t
*clone_parent
, uint64_t flags
,
119 void (*func
)(objset_t
*os
, void *arg
, cred_t
*cr
, dmu_tx_t
*tx
), void *arg
);
120 int dmu_objset_destroy(const char *name
, boolean_t defer
);
121 int dmu_objset_rollback(objset_t
*os
);
122 int dmu_objset_snapshot(char *fsname
, char *snapname
, nvlist_t
*props
,
123 boolean_t recursive
);
124 void dmu_objset_stats(objset_t
*os
, nvlist_t
*nv
);
125 void dmu_objset_fast_stat(objset_t
*os
, dmu_objset_stats_t
*stat
);
126 void dmu_objset_space(objset_t
*os
, uint64_t *refdbytesp
, uint64_t *availbytesp
,
127 uint64_t *usedobjsp
, uint64_t *availobjsp
);
128 uint64_t dmu_objset_fsid_guid(objset_t
*os
);
129 int dmu_objset_find(char *name
, int func(char *, void *), void *arg
,
131 int dmu_objset_find_spa(spa_t
*spa
, const char *name
,
132 int func(spa_t
*, uint64_t, const char *, void *), void *arg
, int flags
);
133 int dmu_objset_prefetch(char *name
, void *arg
);
134 void dmu_objset_byteswap(void *buf
, size_t size
);
135 int dmu_objset_evict_dbufs(objset_t
*os
);
137 /* called from dsl */
138 void dmu_objset_sync(objset_impl_t
*os
, zio_t
*zio
, dmu_tx_t
*tx
);
139 objset_impl_t
*dmu_objset_create_impl(spa_t
*spa
, struct dsl_dataset
*ds
,
140 blkptr_t
*bp
, dmu_objset_type_t type
, dmu_tx_t
*tx
);
141 int dmu_objset_open_impl(spa_t
*spa
, struct dsl_dataset
*ds
, blkptr_t
*bp
,
142 objset_impl_t
**osip
);
143 void dmu_objset_evict(struct dsl_dataset
*ds
, void *arg
);
144 void dmu_objset_do_userquota_callbacks(objset_impl_t
*os
, dmu_tx_t
*tx
);
145 boolean_t
dmu_objset_userused_enabled(objset_impl_t
*os
);
146 int dmu_objset_userspace_upgrade(objset_t
*os
);
147 boolean_t
dmu_objset_userspace_present(objset_t
*os
);
153 #endif /* _SYS_DMU_OBJSET_H */