mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
OpenZFS 8067 - zdb should be able to dump literal embedded block pointer
Authored by: Matthew Ahrens <mahrens@delphix.com> 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> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/8067 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/8173085 Closes #6319
This commit is contained in:
committed by
Brian Behlendorf
parent
c34efbebd5
commit
a896468c78
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user