126
131
* +-------+-------+-------+-------+-------+-------+-------+-------+
127
132
* 5 |G| offset3 |
128
133
* +-------+-------+-------+-------+-------+-------+-------+-------+
129
* 6 |E| lvl | type | cksum | comp | PSIZE | LSIZE |
134
* 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE |
130
135
* +-------+-------+-------+-------+-------+-------+-------+-------+
132
137
* +-------+-------+-------+-------+-------+-------+-------+-------+
134
139
* +-------+-------+-------+-------+-------+-------+-------+-------+
140
* 9 | physical birth txg |
136
141
* +-------+-------+-------+-------+-------+-------+-------+-------+
142
* a | logical birth txg |
138
143
* +-------+-------+-------+-------+-------+-------+-------+-------+
139
144
* b | fill count |
140
145
* +-------+-------+-------+-------+-------+-------+-------+-------+
158
163
* cksum checksum function
159
164
* comp compression function
160
165
* G gang block indicator
166
* B byteorder (endianness)
169
* lvl level of indirection
162
170
* type DMU object type
163
* lvl level of indirection
164
* birth txg transaction group in which the block was born
171
* phys birth txg of block allocation; zero if same as logical birth txg
172
* log. birth transaction group in which the block was logically born
165
173
* fill count number of non-zero blocks under this bp
166
174
* checksum[4] 256-bit checksum of the data this bp describes
176
#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */
177
#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */
168
179
typedef struct blkptr {
169
dva_t blk_dva[3]; /* 128-bit Data Virtual Address */
170
grub_uint64_t blk_prop; /* size, compression, type, etc */
171
grub_uint64_t blk_pad[3]; /* Extra space for the future */
172
grub_uint64_t blk_birth; /* transaction group at birth */
173
grub_uint64_t blk_fill; /* fill count */
174
zio_cksum_t blk_cksum; /* 256-bit checksum */
180
dva_t blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */
181
grub_uint64_t blk_prop; /* size, compression, type, etc */
182
grub_uint64_t blk_pad[2]; /* Extra space for the future */
183
grub_uint64_t blk_phys_birth; /* txg when block was allocated */
184
grub_uint64_t blk_birth; /* transaction group at birth */
185
grub_uint64_t blk_fill; /* fill count */
186
zio_cksum_t blk_cksum; /* 256-bit checksum */
177
#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */
178
#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */
181
190
* Macros to get and set fields in a bp or DVA.
195
204
#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x)
197
206
#define BP_GET_LSIZE(bp) \
198
(BP_IS_HOLE(bp) ? 0 : \
199
BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1))
207
BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
200
208
#define BP_SET_LSIZE(bp, x) \
201
209
BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
203
#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8)
204
#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x)
206
#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8)
207
#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x)
209
#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
210
#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x)
212
#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5)
213
#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x)
215
#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1))
216
#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x)
211
#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8)
212
#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x)
214
#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8)
215
#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x)
217
#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
218
#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x)
220
#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5)
221
#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x)
223
#define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1)
224
#define BP_SET_PROP_BIT_61(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x)
226
#define BP_GET_DEDUP(bp) BF64_GET((bp)->blk_prop, 62, 1)
227
#define BP_SET_DEDUP(bp, x) BF64_SET((bp)->blk_prop, 62, 1, x)
229
#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1))
230
#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x)
232
#define BP_PHYSICAL_BIRTH(bp) \
233
((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
235
#define BP_SET_BIRTH(bp, logical, physical) \
237
(bp)->blk_birth = (logical); \
238
(bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \
218
241
#define BP_GET_ASIZE(bp) \
219
242
(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
237
260
((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
238
261
(dva1)->dva_word[0] == (dva2)->dva_word[0])
263
#define BP_EQUAL(bp1, bp2) \
264
(BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) && \
265
DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) && \
266
DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) && \
267
DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
240
269
#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \
241
270
(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
242
271
((zc1).zc_word[1] - (zc2).zc_word[1]) | \
243
272
((zc1).zc_word[2] - (zc2).zc_word[2]) | \
244
273
((zc1).zc_word[3] - (zc2).zc_word[3])))
247
275
#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0)
249
277
#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \