diff options
author | Matthew Ahrens <[email protected]> | 2017-05-01 11:06:07 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-07-07 11:28:01 -0700 |
commit | a896468c7872dc7277fd0171c65bd2c185bfcaab (patch) | |
tree | 2b1717330a458554d736de028bb4e299eec2d438 /module/zfs | |
parent | c34efbebd577644674a7cf543b3e0540c9f0fa9f (diff) |
OpenZFS 8067 - zdb should be able to dump literal embedded block pointer
Authored by: Matthew Ahrens <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Alex Reece <[email protected]>
Reviewed by: Yuri Pankov <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Ported-by: Giuseppe Di Natale <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/8067
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/8173085
Closes #6319
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/blkptr.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/module/zfs/blkptr.c b/module/zfs/blkptr.c index 99accfa0f..bb407af03 100644 --- a/module/zfs/blkptr.c +++ b/module/zfs/blkptr.c @@ -119,3 +119,36 @@ decode_embedded_bp_compressed(const blkptr_t *bp, void *buf) buf8[i] = BF64_GET(w, (i % sizeof (w)) * NBBY, NBBY); } } + +/* + * Fill in the buffer with the (decompressed) payload of the embedded + * blkptr_t. Takes into account compression and byteorder (the payload is + * treated as a stream of bytes). + * Return 0 on success, or ENOSPC if it won't fit in the buffer. + */ +int +decode_embedded_bp(const blkptr_t *bp, void *buf, int buflen) +{ + int lsize, psize; + + ASSERT(BP_IS_EMBEDDED(bp)); + + lsize = BPE_GET_LSIZE(bp); + psize = BPE_GET_PSIZE(bp); + + if (lsize > buflen) + return (ENOSPC); + ASSERT3U(lsize, ==, buflen); + + if (BP_GET_COMPRESS(bp) != ZIO_COMPRESS_OFF) { + uint8_t dstbuf[BPE_PAYLOAD_SIZE]; + decode_embedded_bp_compressed(bp, dstbuf); + VERIFY0(zio_decompress_data_buf(BP_GET_COMPRESS(bp), + dstbuf, buf, psize, buflen)); + } else { + ASSERT3U(lsize, ==, psize); + decode_embedded_bp_compressed(bp, buf); + } + + return (0); +} |