The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/cddl/boot/zfs/blkptr.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * CDDL HEADER START
    3  *
    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
    7  * 1.0 of the CDDL.
    8  *
    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.
   12  *
   13  * CDDL HEADER END
   14  */
   15 
   16 /*
   17  * Copyright (c) 2013 by Delphix. All rights reserved.
   18  */
   19 
   20 /*
   21  * Embedded-data Block Pointers
   22  *
   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
   27  * more random reads.
   28  *
   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.
   33  *
   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.
   38  *
   39  * See spa.h for details on the exact layout of embedded block pointers.
   40  */
   41 
   42 /*
   43  * buf must be at least BPE_GET_PSIZE(bp) bytes long (which will never be
   44  * more than BPE_PAYLOAD_SIZE bytes).
   45  */
   46 void
   47 decode_embedded_bp_compressed(const blkptr_t *bp, void *buf)
   48 {
   49         int psize;
   50         uint8_t *buf8 = buf;
   51         uint64_t w = 0;
   52         const uint64_t *bp64 = (const uint64_t *)bp;
   53 
   54         ASSERT(BP_IS_EMBEDDED(bp));
   55 
   56         psize = BPE_GET_PSIZE(bp);
   57 
   58         /*
   59          * Decode the words of the block pointer into the byte array.
   60          * Low bits of first word are the first byte (little endian).
   61          */
   62         for (int i = 0; i < psize; i++) {
   63                 if (i % sizeof (w) == 0) {
   64                         /* beginning of a word */
   65                         ASSERT3P(bp64, <, bp + 1);
   66                         w = *bp64;
   67                         bp64++;
   68                         if (!BPE_IS_PAYLOADWORD(bp, bp64))
   69                                 bp64++;
   70                 }
   71                 buf8[i] = BF64_GET(w, (i % sizeof (w)) * NBBY, NBBY);
   72         }
   73 }

Cache object: 88ebd11f2c3f1f029e708a4ec36b676c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.