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