Date: Tue, 8 Aug 2017 11:10:37 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r322235 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zdb vendor/illumos/dist/man/man1m Message-ID: <201708081110.v78BAbbc040031@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Tue Aug 8 11:10:37 2017 New Revision: 322235 URL: https://svnweb.freebsd.org/changeset/base/322235 Log: 8067 zdb should be able to dump literal embedded block pointer illumos/illumos-gate@4923c69fddc0887da5604a262585af3efd82ee20 https://github.com/illumos/illumos-gate/commit/4923c69fddc0887da5604a262585af3efd82ee20 https://www.illumos.org/issues/8067 Add an option to zdb to print a literal embedded block pointer supplied on the command line: zdb -E [-A] word0:word1:...:word15 Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Alex Reece <alex@delphix.com> Reviewed by: Yuri Pankov <yuri.pankov@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com> Author: Matthew Ahrens <mahrens@delphix.com> Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/blkptr.c vendor-sys/illumos/dist/uts/common/fs/zfs/sys/blkptr.h Changes in other areas also in this revision: Modified: vendor/illumos/dist/cmd/zdb/zdb.c vendor/illumos/dist/man/man1m/zdb.1m Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/blkptr.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/blkptr.c Tue Aug 8 11:07:34 2017 (r322234) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/blkptr.c Tue Aug 8 11:10:37 2017 (r322235) @@ -117,3 +117,36 @@ decode_embedded_bp_compressed(const blkptr_t *bp, void 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); +} Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/sys/blkptr.h ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/sys/blkptr.h Tue Aug 8 11:07:34 2017 (r322234) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/sys/blkptr.h Tue Aug 8 11:10:37 2017 (r322235) @@ -30,6 +30,7 @@ extern "C" { void encode_embedded_bp_compressed(blkptr_t *, void *, enum zio_compress, int, int); void decode_embedded_bp_compressed(const blkptr_t *, void *); +int decode_embedded_bp(const blkptr_t *, void *, int); #ifdef __cplusplus }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708081110.v78BAbbc040031>