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/*
216e1f5caNeil Perrin * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
22b1b8ab3lling * Use is subject to license terms.
23b1b8ab3lling */
24b1b8ab3lling
25ad135b5Christopher Siden/*
26dcbf3bdGeorge Wilson * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
27c3d26abMatthew Ahrens * Copyright (c) 2014 Integros [integros.com]
28ad135b5Christopher Siden */
29ad135b5Christopher Siden
30b1b8ab3lling#ifndef _SYS_SPA_H
31b1b8ab3lling#define	_SYS_SPA_H
32b1b8ab3lling
33b1b8ab3lling/*
34b1b8ab3lling * General-purpose 32-bit and 64-bit bitfield encodings.
35b1b8ab3lling */
36b1b8ab3lling#define	BF32_DECODE(x, low, len)	P2PHASE((x) >> (low), 1U << (len))
37b1b8ab3lling#define	BF64_DECODE(x, low, len)	P2PHASE((x) >> (low), 1ULL << (len))
38b1b8ab3lling#define	BF32_ENCODE(x, low, len)	(P2PHASE((x), 1U << (len)) << (low))
39b1b8ab3lling#define	BF64_ENCODE(x, low, len)	(P2PHASE((x), 1ULL << (len)) << (low))
40b1b8ab3lling
41b1b8ab3lling#define	BF32_GET(x, low, len)		BF32_DECODE(x, low, len)
42b1b8ab3lling#define	BF64_GET(x, low, len)		BF64_DECODE(x, low, len)
43b1b8ab3lling
44b1b8ab3lling#define	BF32_SET(x, low, len, val)	\
45b1b8ab3lling	((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))
46b1b8ab3lling#define	BF64_SET(x, low, len, val)	\
47b1b8ab3lling	((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))
48b1b8ab3lling
49b1b8ab3lling#define	BF32_GET_SB(x, low, len, shift, bias)	\
50b1b8ab3lling	((BF32_GET(x, low, len) + (bias)) << (shift))
51b1b8ab3lling#define	BF64_GET_SB(x, low, len, shift, bias)	\
52b1b8ab3lling	((BF64_GET(x, low, len) + (bias)) << (shift))
53b1b8ab3lling
54b1b8ab3lling#define	BF32_SET_SB(x, low, len, shift, bias, val)	\
55b1b8ab3lling	BF32_SET(x, low, len, ((val) >> (shift)) - (bias))
56b1b8ab3lling#define	BF64_SET_SB(x, low, len, shift, bias, val)	\
57b1b8ab3lling	BF64_SET(x, low, len, ((val) >> (shift)) - (bias))
58b1b8ab3lling
59b1b8ab3lling/*
60b515258Matthew Ahrens * Note: GRUB can't actually read blocks larger than 128KB, due to lack
61b515258Matthew Ahrens * of memory.  Therefore its SPA_MAXBLOCKSIZE is still 128KB.
62b1b8ab3lling */
63b1b8ab3lling#define	SPA_MINBLOCKSHIFT	9
64b1b8ab3lling#define	SPA_MAXBLOCKSHIFT	17
65b1b8ab3lling#define	SPA_MINBLOCKSIZE	(1ULL << SPA_MINBLOCKSHIFT)
66b1b8ab3lling#define	SPA_MAXBLOCKSIZE	(1ULL << SPA_MAXBLOCKSHIFT)
67b1b8ab3lling
68b1b8ab3lling/*
69b24ab67Jeff Bonwick * Size of block to hold the configuration data (a packed nvlist)
70b24ab67Jeff Bonwick */
71ad135b5Christopher Siden#define	SPA_CONFIG_BLOCKSIZE	(1ULL << 14)
72b24ab67Jeff Bonwick
73b24ab67Jeff Bonwick/*
74b1b8ab3lling * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
75b1b8ab3lling * The ASIZE encoding should be at least 64 times larger (6 more bits)
76b1b8ab3lling * to support up to 4-way RAID-Z mirror mode with worst-case gang block
77b1b8ab3lling * overhead, three DVAs per bp, plus one more bit in case we do anything
78b1b8ab3lling * else that expands the ASIZE.
79b1b8ab3lling */
80b1b8ab3lling#define	SPA_LSIZEBITS		16	/* LSIZE up to 32M (2^16 * 512)	*/
81b1b8ab3lling#define	SPA_PSIZEBITS		16	/* PSIZE up to 32M (2^16 * 512)	*/
82b1b8ab3lling#define	SPA_ASIZEBITS		24	/* ASIZE up to 64 times larger	*/
83b1b8ab3lling
84dcbf3bdGeorge Wilson#define	SPA_COMPRESSBITS	7
85dcbf3bdGeorge Wilson
86b1b8ab3lling/*
87b1b8ab3lling * All SPA data is represented by 128-bit data virtual addresses (DVAs).
88b1b8ab3lling * The members of the dva_t should be considered opaque outside the SPA.
89b1b8ab3lling */
90b1b8ab3llingtypedef struct dva {
91b1b8ab3lling	uint64_t	dva_word[2];
92b1b8ab3lling} dva_t;
93b1b8ab3lling
94b1b8ab3lling/*
95b1b8ab3lling * Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
96b1b8ab3lling */
97b1b8ab3llingtypedef struct zio_cksum {
98b1b8ab3lling	uint64_t	zc_word[4];
99b1b8ab3lling} zio_cksum_t;
100b1b8ab3lling
101b1b8ab3lling/*
102b1b8ab3lling * Each block is described by its DVAs, time of birth, checksum, etc.
103b1b8ab3lling * The word-by-word, bit-by-bit layout of the blkptr is as follows:
104b1b8ab3lling *
105b1b8ab3lling *	64	56	48	40	32	24	16	8	0
106b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
107b1b8ab3lling * 0	|		vdev1		| GRID  |	  ASIZE		|
108b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
109b1b8ab3lling * 1	|G|			 offset1				|
110b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
111b1b8ab3lling * 2	|		vdev2		| GRID  |	  ASIZE		|
112b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
113b1b8ab3lling * 3	|G|			 offset2				|
114b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
115b1b8ab3lling * 4	|		vdev3		| GRID  |	  ASIZE		|
116b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
117b1b8ab3lling * 5	|G|			 offset3				|
118b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
1195d7b4d4Matthew Ahrens * 6	|BDX|lvl| type	| cksum |E| comp|    PSIZE	|     LSIZE	|
120b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
121b1b8ab3lling * 7	|			padding					|
122b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
123b1b8ab3lling * 8	|			padding					|
124b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
125b24ab67Jeff Bonwick * 9	|			physical birth txg			|
126b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
127b24ab67Jeff Bonwick * a	|			logical birth txg			|
128b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
129b1b8ab3lling * b	|			fill count				|
130b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
131b1b8ab3lling * c	|			checksum[0]				|
132b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
133b1b8ab3lling * d	|			checksum[1]				|
134b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
135b1b8ab3lling * e	|			checksum[2]				|
136b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
137b1b8ab3lling * f	|			checksum[3]				|
138b1b8ab3lling *	+-------+-------+-------+-------+-------+-------+-------+-------+
139b1b8ab3lling *
140b1b8ab3lling * Legend:
141b1b8ab3lling *
142b1b8ab3lling * vdev		virtual device ID
143b1b8ab3lling * offset	offset into virtual device
144b1b8ab3lling * LSIZE	logical size
145b1b8ab3lling * PSIZE	physical size (after compression)
146b1b8ab3lling * ASIZE	allocated size (including RAID-Z parity and gang block headers)
147b1b8ab3lling * GRID		RAID-Z layout information (reserved for future use)
148b1b8ab3lling * cksum	checksum function
149b1b8ab3lling * comp		compression function
150b1b8ab3lling * G		gang block indicator
151b24ab67Jeff Bonwick * B		byteorder (endianness)
152b24ab67Jeff Bonwick * D		dedup
1535d7b4d4Matthew Ahrens * X		encryption (on version 30, which is not supported)
1545d7b4d4Matthew Ahrens * E		blkptr_t contains embedded data
155b1b8ab3lling * lvl		level of indirection
156b24ab67Jeff Bonwick * type		DMU object type
157b24ab67Jeff Bonwick * phys birth	txg of block allocation; zero if same as logical birth txg
158b24ab67Jeff Bonwick * log. birth	transaction group in which the block was logically born
159b1b8ab3lling * fill count	number of non-zero blocks under this bp
160b1b8ab3lling * checksum[4]	256-bit checksum of the data this bp describes
161b1b8ab3lling */
162b1b8ab3lling#define	SPA_BLKPTRSHIFT	7		/* blkptr_t is 128 bytes	*/
163b1b8ab3lling#define	SPA_DVAS_PER_BP	3		/* Number of DVAs in a bp	*/
164b1b8ab3lling
165b24ab67Jeff Bonwicktypedef struct blkptr {
166b24ab67Jeff Bonwick	dva_t		blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */
167b24ab67Jeff Bonwick	uint64_t	blk_prop;	/* size, compression, type, etc	    */
168b24ab67Jeff Bonwick	uint64_t	blk_pad[2];	/* Extra space for the future	    */
169b24ab67Jeff Bonwick	uint64_t	blk_phys_birth;	/* txg when block was allocated	    */
170b24ab67Jeff Bonwick	uint64_t	blk_birth;	/* transaction group at birth	    */
171b24ab67Jeff Bonwick	uint64_t	blk_fill;	/* fill count			    */
172b24ab67Jeff Bonwick	zio_cksum_t	blk_cksum;	/* 256-bit checksum		    */
173b24ab67Jeff Bonwick} blkptr_t;
174b24ab67Jeff Bonwick
175b1b8ab3lling/*
176b1b8ab3lling * Macros to get and set fields in a bp or DVA.
177b1b8ab3lling */
178b1b8ab3lling#define	DVA_GET_ASIZE(dva)	\
17943466aaMax Grossman	BF64_GET_SB((dva)->dva_word[0], 0, SPA_ASIZEBITS, SPA_MINBLOCKSHIFT, 0)
180b1b8ab3lling#define	DVA_SET_ASIZE(dva, x)	\
18143466aaMax Grossman	BF64_SET_SB((dva)->dva_word[0], 0, SPA_ASIZEBITS, \
18243466aaMax Grossman	SPA_MINBLOCKSHIFT, 0, x)
183b1b8ab3lling
184b1b8ab3lling#define	DVA_GET_GRID(dva)	BF64_GET((dva)->dva_word[0], 24, 8)
185b1b8ab3lling#define	DVA_SET_GRID(dva, x)	BF64_SET((dva)->dva_word[0], 24, 8, x)
186b1b8ab3lling
187b1b8ab3lling#define	DVA_GET_VDEV(dva)	BF64_GET((dva)->dva_word[0], 32, 32)
188b1b8ab3lling#define	DVA_SET_VDEV(dva, x)	BF64_SET((dva)->dva_word[0], 32, 32, x)
189b1b8ab3lling
190b1b8ab3lling#define	DVA_GET_OFFSET(dva)	\
191b1b8ab3lling	BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)
192b1b8ab3lling#define	DVA_SET_OFFSET(dva, x)	\
193b1b8ab3lling	BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x)
194b1b8ab3lling
195b1b8ab3lling#define	DVA_GET_GANG(dva)	BF64_GET((dva)->dva_word[1], 63, 1)
196b1b8ab3lling#define	DVA_SET_GANG(dva, x)	BF64_SET((dva)->dva_word[1], 63, 1, x)
197b1b8ab3lling
198b1b8ab3lling#define	BP_GET_LSIZE(bp)	\
19943466aaMax Grossman	BF64_GET_SB((bp)->blk_prop, 0, SPA_LSIZEBITS, SPA_MINBLOCKSHIFT, 1)
200b1b8ab3lling#define	BP_SET_LSIZE(bp, x)	\
20143466aaMax Grossman	BF64_SET_SB((bp)->blk_prop, 0, SPA_LSIZEBITS, SPA_MINBLOCKSHIFT, 1, x)
202b1b8ab3lling
203b1b8ab3lling#define	BP_GET_PSIZE(bp)	\
20443466aaMax Grossman	BF64_GET_SB((bp)->blk_prop, 16, SPA_PSIZEBITS, SPA_MINBLOCKSHIFT, 1)
205b1b8ab3lling#define	BP_SET_PSIZE(bp, x)	\
20643466aaMax Grossman	BF64_SET_SB((bp)->blk_prop, 16, SPA_PSIZEBITS, SPA_MINBLOCKSHIFT, 1, x)
207b1b8ab3lling
208dcbf3bdGeorge Wilson#define	BP_GET_COMPRESS(bp)		\
209dcbf3bdGeorge Wilson	BF64_GET((bp)->blk_prop, 32, SPA_COMPRESSBITS)
210dcbf3bdGeorge Wilson#define	BP_SET_COMPRESS(bp, x)		\
211dcbf3bdGeorge Wilson	BF64_SET((bp)->blk_prop, 32, SPA_COMPRESSBITS, x)
212b24ab67Jeff Bonwick
213b24ab67Jeff Bonwick#define	BP_GET_CHECKSUM(bp)		BF64_GET((bp)->blk_prop, 40, 8)
214b24ab67Jeff Bonwick#define	BP_SET_CHECKSUM(bp, x)		BF64_SET((bp)->blk_prop, 40, 8, x)
215b24ab67Jeff Bonwick
216b24ab67Jeff Bonwick#define	BP_GET_TYPE(bp)			BF64_GET((bp)->blk_prop, 48, 8)
217b24ab67Jeff Bonwick#define	BP_SET_TYPE(bp, x)		BF64_SET((bp)->blk_prop, 48, 8, x)
218b24ab67Jeff Bonwick
219b24ab67Jeff Bonwick#define	BP_GET_LEVEL(bp)		BF64_GET((bp)->blk_prop, 56, 5)
220b24ab67Jeff Bonwick#define	BP_SET_LEVEL(bp, x)		BF64_SET((bp)->blk_prop, 56, 5, x)
221b1b8ab3lling
2225d7b4d4Matthew Ahrens#define	BP_IS_EMBEDDED(bp)		BF64_GET((bp)->blk_prop, 39, 1)
2235d7b4d4Matthew Ahrens
224b24ab67Jeff Bonwick#define	BP_GET_DEDUP(bp)		BF64_GET((bp)->blk_prop, 62, 1)
225b24ab67Jeff Bonwick#define	BP_SET_DEDUP(bp, x)		BF64_SET((bp)->blk_prop, 62, 1, x)
226b1b8ab3lling
22743466aaMax Grossman#define	BP_GET_BYTEORDER(bp)		BF64_GET((bp)->blk_prop, 63, 1)
228b24ab67Jeff Bonwick#define	BP_SET_BYTEORDER(bp, x)		BF64_SET((bp)->blk_prop, 63, 1, x)
229b1b8ab3lling
230b24ab67Jeff Bonwick#define	BP_PHYSICAL_BIRTH(bp)		\
231b24ab67Jeff Bonwick	((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
232b24ab67Jeff Bonwick
233b24ab67Jeff Bonwick#define	BP_SET_BIRTH(bp, logical, physical)	\
234b24ab67Jeff Bonwick{						\
235b24ab67Jeff Bonwick	(bp)->blk_birth = (logical);		\
236b24ab67Jeff Bonwick	(bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \
237b24ab67Jeff Bonwick}
238b1b8ab3lling
239b1b8ab3lling#define	BP_GET_ASIZE(bp)	\
240b1b8ab3lling	(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
241b1b8ab3lling		DVA_GET_ASIZE(&(bp)->blk_dva[2]))
242b1b8ab3lling
243b1b8ab3lling#define	BP_GET_UCSIZE(bp) \
244b1b8ab3lling	((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \
245b1b8ab3lling	BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp));
246b1b8ab3lling
247b1b8ab3lling#define	BP_GET_NDVAS(bp)	\
248b1b8ab3lling	(!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
249b1b8ab3lling	!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
250b1b8ab3lling	!!DVA_GET_ASIZE(&(bp)->blk_dva[2]))
251b1b8ab3lling
252b1b8ab3lling#define	DVA_EQUAL(dva1, dva2)	\
253b1b8ab3lling	((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
254b1b8ab3lling	(dva1)->dva_word[0] == (dva2)->dva_word[0])
255b1b8ab3lling
256b24ab67Jeff Bonwick#define	BP_EQUAL(bp1, bp2)	\
257b24ab67Jeff Bonwick	(BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) &&	\
258b24ab67Jeff Bonwick	DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) &&	\
259b24ab67Jeff Bonwick	DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) &&	\
260b24ab67Jeff Bonwick	DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
261b24ab67Jeff Bonwick
262b1b8ab3lling#define	ZIO_CHECKSUM_EQUAL(zc1, zc2) \
263b1b8ab3lling	(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
264b1b8ab3lling	((zc1).zc_word[1] - (zc2).zc_word[1]) | \
265b1b8ab3lling	((zc1).zc_word[2] - (zc2).zc_word[2]) | \
266b1b8ab3lling	((zc1).zc_word[3] - (zc2).zc_word[3])))
267b1b8ab3lling
268b1b8ab3lling#define	DVA_IS_VALID(dva)	(DVA_GET_ASIZE(dva) != 0)
269b1b8ab3lling
270b1b8ab3lling#define	ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3)	\
271b1b8ab3lling{						\
272b1b8ab3lling	(zcp)->zc_word[0] = w0;			\
273b1b8ab3lling	(zcp)->zc_word[1] = w1;			\
274b1b8ab3lling	(zcp)->zc_word[2] = w2;			\
275b1b8ab3lling	(zcp)->zc_word[3] = w3;			\
276b1b8ab3lling}
277b1b8ab3lling
278b1b8ab3lling#define	BP_IDENTITY(bp)		(&(bp)->blk_dva[0])
279b1b8ab3lling#define	BP_IS_GANG(bp)		DVA_GET_GANG(BP_IDENTITY(bp))
28043466aaMax Grossman#define	DVA_IS_EMPTY(dva)	((dva)->dva_word[0] == 0ULL &&	\
28143466aaMax Grossman				(dva)->dva_word[1] == 0ULL)
28243466aaMax Grossman#define	BP_IS_HOLE(bp)		DVA_IS_EMPTY(BP_IDENTITY(bp))
283b1b8ab3lling
2846e1f5caNeil Perrin/* BP_IS_RAIDZ(bp) assumes no block compression */
2856e1f5caNeil Perrin#define	BP_IS_RAIDZ(bp)		(DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
2866e1f5caNeil Perrin				BP_GET_PSIZE(bp))
2876e1f5caNeil Perrin
288b1b8ab3lling#define	BP_ZERO(bp)				\
289b1b8ab3lling{						\
290b1b8ab3lling	(bp)->blk_dva[0].dva_word[0] = 0;	\
291b1b8ab3lling	(bp)->blk_dva[0].dva_word[1] = 0;	\
292b1b8ab3lling	(bp)->blk_dva[1].dva_word[0] = 0;	\
293b1b8ab3lling	(bp)->blk_dva[1].dva_word[1] = 0;	\
294b1b8ab3lling	(bp)->blk_dva[2].dva_word[0] = 0;	\
295b1b8ab3lling	(bp)->blk_dva[2].dva_word[1] = 0;	\
296b1b8ab3lling	(bp)->blk_prop = 0;			\
297b1b8ab3lling	(bp)->blk_pad[0] = 0;			\
298b1b8ab3lling	(bp)->blk_pad[1] = 0;			\
299b24ab67Jeff Bonwick	(bp)->blk_phys_birth = 0;		\
300b1b8ab3lling	(bp)->blk_birth = 0;			\
301b1b8ab3lling	(bp)->blk_fill = 0;			\
302b1b8ab3lling	ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0);	\
303b1b8ab3lling}
304b1b8ab3lling
3055d7b4d4Matthew Ahrens#define	BPE_GET_ETYPE(bp)	BP_GET_CHECKSUM(bp)
3065d7b4d4Matthew Ahrens#define	BPE_GET_LSIZE(bp)	\
3075d7b4d4Matthew Ahrens	BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1)
3085d7b4d4Matthew Ahrens#define	BPE_GET_PSIZE(bp)	\
3095d7b4d4Matthew Ahrens	BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1)
3105d7b4d4Matthew Ahrens
3115d7b4d4Matthew Ahrenstypedef enum bp_embedded_type {
3125d7b4d4Matthew Ahrens	BP_EMBEDDED_TYPE_DATA,
3135d7b4d4Matthew Ahrens	NUM_BP_EMBEDDED_TYPES
3145d7b4d4Matthew Ahrens} bp_embedded_type_t;
3155d7b4d4Matthew Ahrens
3165d7b4d4Matthew Ahrens#define	BPE_NUM_WORDS 14
3175d7b4d4Matthew Ahrens#define	BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof (uint64_t))
3185d7b4d4Matthew Ahrens#define	BPE_IS_PAYLOADWORD(bp, wp) \
3195d7b4d4Matthew Ahrens	((wp) != &(bp)->blk_prop && (wp) != &(bp)->blk_birth)
3205d7b4d4Matthew Ahrens
321b1b8ab3lling#ifdef _BIG_ENDIAN
322b1b8ab3lling#define	ZFS_HOST_BYTEORDER	(0ULL)
323b1b8ab3lling#else
32443466aaMax Grossman#define	ZFS_HOST_BYTEORDER	(1ULL)
325b1b8ab3lling#endif
326b1b8ab3lling
327b1b8ab3lling#define	BP_SHOULD_BYTESWAP(bp)	(BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)
328b1b8ab3lling
329b1b8ab3lling#define	BP_SPRINTF_LEN	320
330b1b8ab3lling
331b1b8ab3lling#endif	/* _SYS_SPA_H */
332