xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/dmu_objset.h (revision 76716eaced8d7659d4594350eb3f343c31fe2806)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_DMU_OBJSET_H
27 #define	_SYS_DMU_OBJSET_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/spa.h>
32 #include <sys/txg.h>
33 #include <sys/zfs_context.h>
34 #include <sys/dnode.h>
35 #include <sys/zio.h>
36 #include <sys/zil.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 struct dsl_dataset;
43 struct dmu_tx;
44 struct objset_impl;
45 
46 typedef struct objset_phys {
47 	dnode_phys_t os_meta_dnode;
48 	zil_header_t os_zil_header;
49 	uint64_t os_type;
50 	char os_pad[1024 - sizeof (dnode_phys_t) - sizeof (zil_header_t) -
51 	    sizeof (uint64_t)];
52 } objset_phys_t;
53 
54 struct objset {
55 	struct objset_impl *os;
56 	int os_mode;
57 };
58 
59 typedef struct objset_impl {
60 	/* Immutable: */
61 	struct dsl_dataset *os_dsl_dataset;
62 	spa_t *os_spa;
63 	objset_phys_t *os_phys;
64 	dnode_t *os_meta_dnode;
65 	zilog_t *os_zil;
66 	objset_t os;
67 	uint8_t os_checksum;	/* can change, under dsl_dir's locks */
68 	uint8_t os_compress;	/* can change, under dsl_dir's locks */
69 	uint8_t os_md_checksum;
70 	uint8_t os_md_compress;
71 
72 	/* no lock needed: */
73 	struct dmu_tx *os_synctx; /* XXX sketchy */
74 	blkptr_t os_rootbp;
75 
76 	/* Protected by os_obj_lock */
77 	kmutex_t os_obj_lock;
78 	uint64_t os_obj_next;
79 
80 	/* Protected by os_lock */
81 	kmutex_t os_lock;
82 	list_t os_dirty_dnodes[TXG_SIZE];
83 	list_t os_free_dnodes[TXG_SIZE];
84 	list_t os_dnodes;
85 	list_t os_downgraded_dbufs;
86 } objset_impl_t;
87 
88 #define	DMU_META_DNODE_OBJECT	0
89 
90 /* called from zpl */
91 int dmu_objset_open(const char *name, dmu_objset_type_t type, int mode,
92     objset_t **osp);
93 void dmu_objset_close(objset_t *os);
94 int dmu_objset_create(const char *name, dmu_objset_type_t type,
95     objset_t *clone_parent,
96     void (*func)(objset_t *os, void *arg, dmu_tx_t *tx), void *arg);
97 int dmu_objset_destroy(const char *name);
98 int dmu_objset_rollback(const char *name);
99 void dmu_objset_stats(objset_t *os, dmu_objset_stats_t *dds);
100 void dmu_objset_find(char *name, void func(char *, void *), void *arg,
101     int flags);
102 void dmu_objset_byteswap(void *buf, size_t size);
103 int dmu_objset_evict_dbufs(objset_t *os, int try);
104 
105 /* called from dsl */
106 void dmu_objset_sync(objset_impl_t *os, dmu_tx_t *tx);
107 objset_impl_t *dmu_objset_create_impl(spa_t *spa, struct dsl_dataset *ds,
108     dmu_objset_type_t type, dmu_tx_t *tx);
109 int dmu_objset_open_impl(spa_t *spa, struct dsl_dataset *ds, blkptr_t *bp,
110     objset_impl_t **osip);
111 void dmu_objset_evict(struct dsl_dataset *ds, void *arg);
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif /* _SYS_DMU_OBJSET_H */
118