dmu.h revision ad135b5d644628e791c3188a6ecbd9c257961ef8
17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate *  GRUB  --  GRand Unified Bootloader
37c478bdstevel@tonic-gate *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
47c478bdstevel@tonic-gate *
59ba4fd8rshoaib *  This program is free software; you can redistribute it and/or modify
69ba4fd8rshoaib *  it under the terms of the GNU General Public License as published by
77c478bdstevel@tonic-gate *  the Free Software Foundation; either version 2 of the License, or
87c478bdstevel@tonic-gate *  (at your option) any later version.
97c478bdstevel@tonic-gate *
107c478bdstevel@tonic-gate *  This program is distributed in the hope that it will be useful,
117c478bdstevel@tonic-gate *  but WITHOUT ANY WARRANTY; without even the implied warranty of
127c478bdstevel@tonic-gate *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
137c478bdstevel@tonic-gate *  GNU General Public License for more details.
147c478bdstevel@tonic-gate *
157c478bdstevel@tonic-gate *  You should have received a copy of the GNU General Public License
167c478bdstevel@tonic-gate *  along with this program; if not, write to the Free Software
177c478bdstevel@tonic-gate *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
187c478bdstevel@tonic-gate */
197c478bdstevel@tonic-gate
207c478bdstevel@tonic-gate/*
219ba4fd8rshoaib * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
227c478bdstevel@tonic-gate * Use is subject to license terms.
236e91bbaGirish Moodalbail */
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate/*
267c478bdstevel@tonic-gate * Copyright (c) 2012 by Delphix. All rights reserved.
27a36f6bdDan McDonald */
28a36f6bdDan McDonald
29a36f6bdDan McDonald#ifndef	_SYS_DMU_H
30a36f6bdDan McDonald#define	_SYS_DMU_H
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate/*
337c478bdstevel@tonic-gate * This file describes the interface that the DMU provides for its
347c478bdstevel@tonic-gate * consumers.
357c478bdstevel@tonic-gate *
36d04ccbbcarlsonj * The DMU also interacts with the SPA.  That interface is described in
37d04ccbbcarlsonj * dmu_spa.h.
38d04ccbbcarlsonj */
397c478bdstevel@tonic-gate
407c478bdstevel@tonic-gate#define	B_FALSE	0
417c478bdstevel@tonic-gate#define	B_TRUE	1
427c478bdstevel@tonic-gate
437c478bdstevel@tonic-gate#define	DMU_OT_NEWTYPE 0x80
447c478bdstevel@tonic-gate#define	DMU_OT_METADATA 0x40
457c478bdstevel@tonic-gate#define	DMU_OT_BYTESWAP_MASK 0x3f
467c478bdstevel@tonic-gate
477c478bdstevel@tonic-gate#define	DMU_OT(byteswap, metadata) \
487c478bdstevel@tonic-gate	(DMU_OT_NEWTYPE | \
49d04ccbbcarlsonj	((metadata) ? DMU_OT_METADATA : 0) | \
507c478bdstevel@tonic-gate	((byteswap) & DMU_OT_BYTESWAP_MASK))
517c478bdstevel@tonic-gate
52d04ccbbcarlsonj#define	DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \
537c478bdstevel@tonic-gate	((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \
547c478bdstevel@tonic-gate	(ot) < DMU_OT_NUMTYPES)
557c478bdstevel@tonic-gate
567c478bdstevel@tonic-gate#define	DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
577c478bdstevel@tonic-gate	((ot) & DMU_OT_METADATA) : \
587c478bdstevel@tonic-gate	dmu_ot[(ot)].ot_metadata)
597c478bdstevel@tonic-gate
607c478bdstevel@tonic-gatetypedef enum dmu_object_byteswap {
617c478bdstevel@tonic-gate	DMU_BSWAP_UINT8,
627c478bdstevel@tonic-gate	DMU_BSWAP_UINT16,
637c478bdstevel@tonic-gate	DMU_BSWAP_UINT32,
647c478bdstevel@tonic-gate	DMU_BSWAP_UINT64,
657c478bdstevel@tonic-gate	DMU_BSWAP_ZAP,
667c478bdstevel@tonic-gate	DMU_BSWAP_DNODE,
677c478bdstevel@tonic-gate	DMU_BSWAP_OBJSET,
687c478bdstevel@tonic-gate	DMU_BSWAP_ZNODE,
697c478bdstevel@tonic-gate	DMU_BSWAP_OLDACL,
707c478bdstevel@tonic-gate	DMU_BSWAP_ACL,
717c478bdstevel@tonic-gate	DMU_BSWAP_NUMFUNCS
727c478bdstevel@tonic-gate} dmu_object_byteswap_t;
73b0f490fmh
746b27086ddtypedef enum dmu_object_type {
756b27086dd	DMU_OT_NONE,
767c478bdstevel@tonic-gate	/* general: */
777c478bdstevel@tonic-gate	DMU_OT_OBJECT_DIRECTORY,	/* ZAP */
787c478bdstevel@tonic-gate	DMU_OT_OBJECT_ARRAY,		/* UINT64 */
797c478bdstevel@tonic-gate	DMU_OT_PACKED_NVLIST,		/* UINT8 (XDR by nvlist_pack/unpack) */
807c478bdstevel@tonic-gate	DMU_OT_PACKED_NVLIST_SIZE,	/* UINT64 */
817c478bdstevel@tonic-gate	DMU_OT_BPOBJ,			/* UINT64 */
827c478bdstevel@tonic-gate	DMU_OT_BPOBJ_HDR,		/* UINT64 */
837c478bdstevel@tonic-gate	/* spa: */
847c478bdstevel@tonic-gate	DMU_OT_SPACE_MAP_HEADER,	/* UINT64 */
857c478bdstevel@tonic-gate	DMU_OT_SPACE_MAP,		/* UINT64 */
867c478bdstevel@tonic-gate	/* zil: */
877c478bdstevel@tonic-gate	DMU_OT_INTENT_LOG,		/* UINT64 */
887c478bdstevel@tonic-gate	/* dmu: */
897c478bdstevel@tonic-gate	DMU_OT_DNODE,			/* DNODE */
907c478bdstevel@tonic-gate	DMU_OT_OBJSET,			/* OBJSET */
917c478bdstevel@tonic-gate	/* dsl: */
927c478bdstevel@tonic-gate	DMU_OT_DSL_DIR,			/* UINT64 */
937c478bdstevel@tonic-gate	DMU_OT_DSL_DIR_CHILD_MAP,	/* ZAP */
947c478bdstevel@tonic-gate	DMU_OT_DSL_DS_SNAP_MAP,		/* ZAP */
957c478bdstevel@tonic-gate	DMU_OT_DSL_PROPS,		/* ZAP */
967c478bdstevel@tonic-gate	DMU_OT_DSL_DATASET,		/* UINT64 */
977c478bdstevel@tonic-gate	/* zpl: */
987c478bdstevel@tonic-gate	DMU_OT_ZNODE,			/* ZNODE */
997c478bdstevel@tonic-gate	DMU_OT_OLDACL,			/* Old ACL */
1007c478bdstevel@tonic-gate	DMU_OT_PLAIN_FILE_CONTENTS,	/* UINT8 */
1017c478bdstevel@tonic-gate	DMU_OT_DIRECTORY_CONTENTS,	/* ZAP */
1027c478bdstevel@tonic-gate	DMU_OT_MASTER_NODE,		/* ZAP */
1037c478bdstevel@tonic-gate	DMU_OT_UNLINKED_SET,		/* ZAP */
1047c478bdstevel@tonic-gate	/* zvol: */
1057c478bdstevel@tonic-gate	DMU_OT_ZVOL,			/* UINT8 */
1067c478bdstevel@tonic-gate	DMU_OT_ZVOL_PROP,		/* ZAP */
1077c478bdstevel@tonic-gate	/* other; for testing only! */
1087c478bdstevel@tonic-gate	DMU_OT_PLAIN_OTHER,		/* UINT8 */
1097c478bdstevel@tonic-gate	DMU_OT_UINT64_OTHER,		/* UINT64 */
1107c478bdstevel@tonic-gate	DMU_OT_ZAP_OTHER,		/* ZAP */
1117c478bdstevel@tonic-gate	/* new object types: */
1127c478bdstevel@tonic-gate	DMU_OT_ERROR_LOG,		/* ZAP */
1137c478bdstevel@tonic-gate	DMU_OT_SPA_HISTORY,		/* UINT8 */
1147c478bdstevel@tonic-gate	DMU_OT_SPA_HISTORY_OFFSETS,	/* spa_his_phys_t */
1157c478bdstevel@tonic-gate	DMU_OT_POOL_PROPS,		/* ZAP */
1167c478bdstevel@tonic-gate	DMU_OT_DSL_PERMS,		/* ZAP */
1177c478bdstevel@tonic-gate	DMU_OT_ACL,			/* ACL */
1187c478bdstevel@tonic-gate	DMU_OT_SYSACL,			/* SYSACL */
1197c478bdstevel@tonic-gate	DMU_OT_FUID,			/* FUID table (Packed NVLIST UINT8) */
1207c478bdstevel@tonic-gate	DMU_OT_FUID_SIZE,		/* FUID table size UINT64 */
1217c478bdstevel@tonic-gate	DMU_OT_NEXT_CLONES,		/* ZAP */
1227c478bdstevel@tonic-gate	DMU_OT_SCAN_QUEUE,		/* ZAP */
1237c478bdstevel@tonic-gate	DMU_OT_USERGROUP_USED,		/* ZAP */
1247c478bdstevel@tonic-gate	DMU_OT_USERGROUP_QUOTA,		/* ZAP */
1257c478bdstevel@tonic-gate	DMU_OT_USERREFS,		/* ZAP */
1267c478bdstevel@tonic-gate	DMU_OT_DDT_ZAP,			/* ZAP */
1277c478bdstevel@tonic-gate	DMU_OT_DDT_STATS,		/* ZAP */
1287c478bdstevel@tonic-gate	DMU_OT_SA,			/* System attr */
1297c478bdstevel@tonic-gate	DMU_OT_SA_MASTER_NODE,		/* ZAP */
1307c478bdstevel@tonic-gate	DMU_OT_SA_ATTR_REGISTRATION,	/* ZAP */
1317c478bdstevel@tonic-gate	DMU_OT_SA_ATTR_LAYOUTS,		/* ZAP */
1327c478bdstevel@tonic-gate	DMU_OT_SCAN_XLATE,		/* ZAP */
1337c478bdstevel@tonic-gate	DMU_OT_DEDUP,			/* fake dedup BP from ddt_bp_create() */
1347c478bdstevel@tonic-gate	DMU_OT_DEADLIST,		/* ZAP */
1357c478bdstevel@tonic-gate	DMU_OT_DEADLIST_HDR,		/* UINT64 */
1367c478bdstevel@tonic-gate	DMU_OT_DSL_CLONES,		/* ZAP */
1377c478bdstevel@tonic-gate	DMU_OT_BPOBJ_SUBOBJ,		/* UINT64 */
1387c478bdstevel@tonic-gate	DMU_OT_NUMTYPES,
1397c478bdstevel@tonic-gate
1407c478bdstevel@tonic-gate	DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE),
1417c478bdstevel@tonic-gate	DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE),
1427c478bdstevel@tonic-gate	DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE),
1437c478bdstevel@tonic-gate	DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE),
1447c478bdstevel@tonic-gate	DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE),
1457c478bdstevel@tonic-gate	DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE),
1467c478bdstevel@tonic-gate	DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE),
1477c478bdstevel@tonic-gate	DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE),
1487c478bdstevel@tonic-gate	DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE),
1497c478bdstevel@tonic-gate	DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE),
1507c478bdstevel@tonic-gate} dmu_object_type_t;
1517c478bdstevel@tonic-gate
1527c478bdstevel@tonic-gatetypedef enum dmu_objset_type {
1537c478bdstevel@tonic-gate	DMU_OST_NONE,
1547c478bdstevel@tonic-gate	DMU_OST_META,
1557c478bdstevel@tonic-gate	DMU_OST_ZFS,
1567c478bdstevel@tonic-gate	DMU_OST_ZVOL,
1577c478bdstevel@tonic-gate	DMU_OST_OTHER,			/* For testing only! */
1587c478bdstevel@tonic-gate	DMU_OST_ANY,			/* Be careful! */
1597c478bdstevel@tonic-gate	DMU_OST_NUMTYPES
1607c478bdstevel@tonic-gate} dmu_objset_type_t;
1617c478bdstevel@tonic-gate
1627c478bdstevel@tonic-gate/*
1637c478bdstevel@tonic-gate * The names of zap entries in the DIRECTORY_OBJECT of the MOS.
1647c478bdstevel@tonic-gate */
1657c478bdstevel@tonic-gate#define	DMU_POOL_DIRECTORY_OBJECT	1
1667c478bdstevel@tonic-gate#define	DMU_POOL_CONFIG			"config"
1677c478bdstevel@tonic-gate#define	DMU_POOL_FEATURES_FOR_READ	"features_for_read"
1687c478bdstevel@tonic-gate#define	DMU_POOL_FEATURES_FOR_WRITE	"features_for_write"
1697c478bdstevel@tonic-gate#define	DMU_POOL_FEATURE_DESCRIPTIONS	"feature_descriptions"
1707c478bdstevel@tonic-gate#define	DMU_POOL_ROOT_DATASET		"root_dataset"
1717c478bdstevel@tonic-gate#define	DMU_POOL_SYNC_BPLIST		"sync_bplist"
1727c478bdstevel@tonic-gate#define	DMU_POOL_ERRLOG_SCRUB		"errlog_scrub"
1737c478bdstevel@tonic-gate#define	DMU_POOL_ERRLOG_LAST		"errlog_last"
1747c478bdstevel@tonic-gate#define	DMU_POOL_SPARES			"spares"
1757c478bdstevel@tonic-gate#define	DMU_POOL_DEFLATE		"deflate"
1767c478bdstevel@tonic-gate#define	DMU_POOL_HISTORY		"history"
1777c478bdstevel@tonic-gate#define	DMU_POOL_PROPS			"pool_props"
1787c478bdstevel@tonic-gate#define	DMU_POOL_L2CACHE		"l2cache"
1797c478bdstevel@tonic-gate
1807c478bdstevel@tonic-gate#endif	/* _SYS_DMU_H */
1817c478bdstevel@tonic-gate