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.wil...@delphix.com>
  Reviewed by: Alex Reece <a...@delphix.com>
  Reviewed by: Yuri Pankov <yuri.pan...@gmail.com>
  Approved by: Robert Mustacchi <r...@joyent.com>
  Author: Matthew Ahrens <mahr...@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
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to