1b1b8ab3lling/*
2b1b8ab3lling *  GRUB  --  GRand Unified Bootloader
3b1b8ab3lling *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
4b1b8ab3lling *
5b1b8ab3lling *  This program is free software; you can redistribute it and/or modify
6b1b8ab3lling *  it under the terms of the GNU General Public License as published by
7b1b8ab3lling *  the Free Software Foundation; either version 2 of the License, or
8b1b8ab3lling *  (at your option) any later version.
9b1b8ab3lling *
10b1b8ab3lling *  This program is distributed in the hope that it will be useful,
11b1b8ab3lling *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12b1b8ab3lling *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13b1b8ab3lling *  GNU General Public License for more details.
14b1b8ab3lling *
15b1b8ab3lling *  You should have received a copy of the GNU General Public License
16b1b8ab3lling *  along with this program; if not, write to the Free Software
17b1b8ab3lling *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18b1b8ab3lling */
19ad135b5Christopher Siden
20b1b8ab3lling/*
210a586ceMark Shellenbaum * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
22b1b8ab3lling * Use is subject to license terms.
23b1b8ab3lling */
24b1b8ab3lling
25ad135b5Christopher Siden/*
26ad135b5Christopher Siden * Copyright (c) 2012 by Delphix. All rights reserved.
27ad135b5Christopher Siden */
28ad135b5Christopher Siden
29b1b8ab3lling#ifndef	_SYS_DMU_H
30b1b8ab3lling#define	_SYS_DMU_H
31b1b8ab3lling
32b1b8ab3lling/*
33b1b8ab3lling * This file describes the interface that the DMU provides for its
34b1b8ab3lling * consumers.
35b1b8ab3lling *
36b1b8ab3lling * The DMU also interacts with the SPA.  That interface is described in
37b1b8ab3lling * dmu_spa.h.
38b1b8ab3lling */
39ad135b5Christopher Siden
40ad135b5Christopher Siden#define	B_FALSE	0
41ad135b5Christopher Siden#define	B_TRUE	1
42ad135b5Christopher Siden
43ad135b5Christopher Siden#define	DMU_OT_NEWTYPE 0x80
44ad135b5Christopher Siden#define	DMU_OT_METADATA 0x40
45ad135b5Christopher Siden#define	DMU_OT_BYTESWAP_MASK 0x3f
46ad135b5Christopher Siden
47ad135b5Christopher Siden#define	DMU_OT(byteswap, metadata) \
48ad135b5Christopher Siden	(DMU_OT_NEWTYPE | \
49ad135b5Christopher Siden	((metadata) ? DMU_OT_METADATA : 0) | \
50ad135b5Christopher Siden	((byteswap) & DMU_OT_BYTESWAP_MASK))
51ad135b5Christopher Siden
52ad135b5Christopher Siden#define	DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \
53ad135b5Christopher Siden	((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \
54ad135b5Christopher Siden	(ot) < DMU_OT_NUMTYPES)
55ad135b5Christopher Siden
56ad135b5Christopher Siden#define	DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
57ad135b5Christopher Siden	((ot) & DMU_OT_METADATA) : \
58ad135b5Christopher Siden	dmu_ot[(ot)].ot_metadata)
59ad135b5Christopher Siden
60ad135b5Christopher Sidentypedef enum dmu_object_byteswap {
61ad135b5Christopher Siden	DMU_BSWAP_UINT8,
62ad135b5Christopher Siden	DMU_BSWAP_UINT16,
63ad135b5Christopher Siden	DMU_BSWAP_UINT32,
64ad135b5Christopher Siden	DMU_BSWAP_UINT64,
65ad135b5Christopher Siden	DMU_BSWAP_ZAP,
66ad135b5Christopher Siden	DMU_BSWAP_DNODE,
67ad135b5Christopher Siden	DMU_BSWAP_OBJSET,
68ad135b5Christopher Siden	DMU_BSWAP_ZNODE,
69ad135b5Christopher Siden	DMU_BSWAP_OLDACL,
70ad135b5Christopher Siden	DMU_BSWAP_ACL,
71ad135b5Christopher Siden	DMU_BSWAP_NUMFUNCS
72ad135b5Christopher Siden} dmu_object_byteswap_t;
73ad135b5Christopher Siden
74b1b8ab3llingtypedef enum dmu_object_type {
75b1b8ab3lling	DMU_OT_NONE,
76b1b8ab3lling	/* general: */
77b1b8ab3lling	DMU_OT_OBJECT_DIRECTORY,	/* ZAP */
78b1b8ab3lling	DMU_OT_OBJECT_ARRAY,		/* UINT64 */
79b1b8ab3lling	DMU_OT_PACKED_NVLIST,		/* UINT8 (XDR by nvlist_pack/unpack) */
80b1b8ab3lling	DMU_OT_PACKED_NVLIST_SIZE,	/* UINT64 */
81ad135b5Christopher Siden	DMU_OT_BPOBJ,			/* UINT64 */
82ad135b5Christopher Siden	DMU_OT_BPOBJ_HDR,		/* UINT64 */
83b1b8ab3lling	/* spa: */
84b1b8ab3lling	DMU_OT_SPACE_MAP_HEADER,	/* UINT64 */
85b1b8ab3lling	DMU_OT_SPACE_MAP,		/* UINT64 */
86b1b8ab3lling	/* zil: */
87b1b8ab3lling	DMU_OT_INTENT_LOG,		/* UINT64 */
88b1b8ab3lling	/* dmu: */
89b1b8ab3lling	DMU_OT_DNODE,			/* DNODE */
90b1b8ab3lling	DMU_OT_OBJSET,			/* OBJSET */
91b1b8ab3lling	/* dsl: */
92b1b8ab3lling	DMU_OT_DSL_DIR,			/* UINT64 */
93b1b8ab3lling	DMU_OT_DSL_DIR_CHILD_MAP,	/* ZAP */
94b1b8ab3lling	DMU_OT_DSL_DS_SNAP_MAP,		/* ZAP */
95b1b8ab3lling	DMU_OT_DSL_PROPS,		/* ZAP */
96b1b8ab3lling	DMU_OT_DSL_DATASET,		/* UINT64 */
97b1b8ab3lling	/* zpl: */
98b1b8ab3lling	DMU_OT_ZNODE,			/* ZNODE */
99ad135b5Christopher Siden	DMU_OT_OLDACL,			/* Old ACL */
100b1b8ab3lling	DMU_OT_PLAIN_FILE_CONTENTS,	/* UINT8 */
101b1b8ab3lling	DMU_OT_DIRECTORY_CONTENTS,	/* ZAP */
102b1b8ab3lling	DMU_OT_MASTER_NODE,		/* ZAP */
103b1b8ab3lling	DMU_OT_UNLINKED_SET,		/* ZAP */
104b1b8ab3lling	/* zvol: */
105b1b8ab3lling	DMU_OT_ZVOL,			/* UINT8 */
106b1b8ab3lling	DMU_OT_ZVOL_PROP,		/* ZAP */
107b1b8ab3lling	/* other; for testing only! */
108b1b8ab3lling	DMU_OT_PLAIN_OTHER,		/* UINT8 */
109b1b8ab3lling	DMU_OT_UINT64_OTHER,		/* UINT64 */
110b1b8ab3lling	DMU_OT_ZAP_OTHER,		/* ZAP */
111b1b8ab3lling	/* new object types: */
112b1b8ab3lling	DMU_OT_ERROR_LOG,		/* ZAP */
113b1b8ab3lling	DMU_OT_SPA_HISTORY,		/* UINT8 */
114b1b8ab3lling	DMU_OT_SPA_HISTORY_OFFSETS,	/* spa_his_phys_t */
115b1b8ab3lling	DMU_OT_POOL_PROPS,		/* ZAP */
1160a586ceMark Shellenbaum	DMU_OT_DSL_PERMS,		/* ZAP */
1170a586ceMark Shellenbaum	DMU_OT_ACL,			/* ACL */
1180a586ceMark Shellenbaum	DMU_OT_SYSACL,			/* SYSACL */
1190a586ceMark Shellenbaum	DMU_OT_FUID,			/* FUID table (Packed NVLIST UINT8) */
1200a586ceMark Shellenbaum	DMU_OT_FUID_SIZE,		/* FUID table size UINT64 */
1210a586ceMark Shellenbaum	DMU_OT_NEXT_CLONES,		/* ZAP */
122ad135b5Christopher Siden	DMU_OT_SCAN_QUEUE,		/* ZAP */
1230a586ceMark Shellenbaum	DMU_OT_USERGROUP_USED,		/* ZAP */
1240a586ceMark Shellenbaum	DMU_OT_USERGROUP_QUOTA,		/* ZAP */
1250a586ceMark Shellenbaum	DMU_OT_USERREFS,		/* ZAP */
1260a586ceMark Shellenbaum	DMU_OT_DDT_ZAP,			/* ZAP */
1270a586ceMark Shellenbaum	DMU_OT_DDT_STATS,		/* ZAP */
1280a586ceMark Shellenbaum	DMU_OT_SA,			/* System attr */
1290a586ceMark Shellenbaum	DMU_OT_SA_MASTER_NODE,		/* ZAP */
1300a586ceMark Shellenbaum	DMU_OT_SA_ATTR_REGISTRATION,	/* ZAP */
1310a586ceMark Shellenbaum	DMU_OT_SA_ATTR_LAYOUTS,		/* ZAP */
132ad135b5Christopher Siden	DMU_OT_SCAN_XLATE,		/* ZAP */
133ad135b5Christopher Siden	DMU_OT_DEDUP,			/* fake dedup BP from ddt_bp_create() */
134ad135b5Christopher Siden	DMU_OT_DEADLIST,		/* ZAP */
135ad135b5Christopher Siden	DMU_OT_DEADLIST_HDR,		/* UINT64 */
136ad135b5Christopher Siden	DMU_OT_DSL_CLONES,		/* ZAP */
137ad135b5Christopher Siden	DMU_OT_BPOBJ_SUBOBJ,		/* UINT64 */
138ad135b5Christopher Siden	DMU_OT_NUMTYPES,
139ad135b5Christopher Siden
140ad135b5Christopher Siden	DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE),
141ad135b5Christopher Siden	DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE),
142ad135b5Christopher Siden	DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE),
143ad135b5Christopher Siden	DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE),
144ad135b5Christopher Siden	DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE),
145ad135b5Christopher Siden	DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE),
146ad135b5Christopher Siden	DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE),
147ad135b5Christopher Siden	DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE),
148ad135b5Christopher Siden	DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE),
149ad135b5Christopher Siden	DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE),
150b1b8ab3lling} dmu_object_type_t;
151b1b8ab3lling
152b1b8ab3llingtypedef enum dmu_objset_type {
153b1b8ab3lling	DMU_OST_NONE,
154b1b8ab3lling	DMU_OST_META,
155b1b8ab3lling	DMU_OST_ZFS,
156b1b8ab3lling	DMU_OST_ZVOL,
157b1b8ab3lling	DMU_OST_OTHER,			/* For testing only! */
158b1b8ab3lling	DMU_OST_ANY,			/* Be careful! */
159b1b8ab3lling	DMU_OST_NUMTYPES
160b1b8ab3lling} dmu_objset_type_t;
161b1b8ab3lling
162b1b8ab3lling/*
163b1b8ab3lling * The names of zap entries in the DIRECTORY_OBJECT of the MOS.
164b1b8ab3lling */
165b1b8ab3lling#define	DMU_POOL_DIRECTORY_OBJECT	1
166b1b8ab3lling#define	DMU_POOL_CONFIG			"config"
167ad135b5Christopher Siden#define	DMU_POOL_FEATURES_FOR_READ	"features_for_read"
168ad135b5Christopher Siden#define	DMU_POOL_FEATURES_FOR_WRITE	"features_for_write"
169ad135b5Christopher Siden#define	DMU_POOL_FEATURE_DESCRIPTIONS	"feature_descriptions"
170b1b8ab3lling#define	DMU_POOL_ROOT_DATASET		"root_dataset"
171b1b8ab3lling#define	DMU_POOL_SYNC_BPLIST		"sync_bplist"
172b1b8ab3lling#define	DMU_POOL_ERRLOG_SCRUB		"errlog_scrub"
173b1b8ab3lling#define	DMU_POOL_ERRLOG_LAST		"errlog_last"
174b1b8ab3lling#define	DMU_POOL_SPARES			"spares"
175b1b8ab3lling#define	DMU_POOL_DEFLATE		"deflate"
176b1b8ab3lling#define	DMU_POOL_HISTORY		"history"
177b1b8ab3lling#define	DMU_POOL_PROPS			"pool_props"
178fa94a07brendan#define	DMU_POOL_L2CACHE		"l2cache"
179b1b8ab3lling
180b1b8ab3lling#endif	/* _SYS_DMU_H */
181