4 * This file and its contents are supplied under the terms of the
5 * Common Development and Distribution License ("CDDL"), version 1.0.
6 * You may only use this file in accordance with the terms of version
9 * A full copy of the text of the CDDL should have accompanied this
10 * source. A copy of the CDDL is also available via the Internet at
11 * http://www.illumos.org/license/CDDL.
17 * Copyright (c) 2013 by Delphix. All rights reserved.
21 * Embedded-data Block Pointers
23 * Normally, block pointers point (via their DVAs) to a block which holds data.
24 * If the data that we need to store is very small, this is an inefficient
25 * use of space, because a block must be at minimum 1 sector (typically 512
26 * bytes or 4KB). Additionally, reading these small blocks tends to generate
29 * Embedded-data Block Pointers allow small pieces of data (the "payload",
30 * up to 112 bytes) to be stored in the block pointer itself, instead of
31 * being pointed to. The "Pointer" part of this name is a bit of a
32 * misnomer, as nothing is pointed to.
34 * BP_EMBEDDED_TYPE_DATA block pointers allow highly-compressible data to
35 * be embedded in the block pointer. The logic for this is handled in
36 * the SPA, by the zio pipeline. Therefore most code outside the zio
37 * pipeline doesn't need special-cases to handle these block pointers.
39 * See spa.h for details on the exact layout of embedded block pointers.
43 * buf must be at least BPE_GET_PSIZE(bp) bytes long (which will never be
44 * more than BPE_PAYLOAD_SIZE bytes).
47 decode_embedded_bp_compressed(const blkptr_t *bp, void *buf)
52 const uint64_t *bp64 = (const uint64_t *)bp;
54 ASSERT(BP_IS_EMBEDDED(bp));
56 psize = BPE_GET_PSIZE(bp);
59 * Decode the words of the block pointer into the byte array.
60 * Low bits of first word are the first byte (little endian).
62 for (int i = 0; i < psize; i++) {
63 if (i % sizeof (w) == 0) {
64 /* beginning of a word */
65 ASSERT3P(bp64, <, bp + 1);
68 if (!BPE_IS_PAYLOADWORD(bp, bp64))
71 buf8[i] = BF64_GET(w, (i % sizeof (w)) * NBBY, NBBY);