Fixes for SNPRINTF_BLKPTR with encrypted BP's

mdb doesn't have dmu_ot[], so we need a different mechanism for its
SNPRINTF_BLKPTR() to determine if the BP is encrypted vs authenticated.

Additionally, since it already relies on BP_IS_ENCRYPTED (etc),
SNPRINTF_BLKPTR might as well figure out the "crypt_type" on its own,
rather than making the caller do so.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #7390
This commit is contained in:
Matthew Ahrens
2018-04-06 13:30:26 -07:00
committed by Brian Behlendorf
parent 0ba106e75c
commit 5c27ec1088
3 changed files with 27 additions and 17 deletions
+1 -11
View File
@@ -1421,7 +1421,6 @@ snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp)
char type[256];
char *checksum = NULL;
char *compress = NULL;
char *crypt_type = NULL;
if (bp != NULL) {
if (BP_GET_TYPE(bp) & DMU_OT_NEWTYPE) {
@@ -1435,15 +1434,6 @@ snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp)
(void) strlcpy(type, dmu_ot[BP_GET_TYPE(bp)].ot_name,
sizeof (type));
}
if (BP_IS_ENCRYPTED(bp)) {
crypt_type = "encrypted";
} else if (BP_IS_AUTHENTICATED(bp)) {
crypt_type = "authenticated";
} else if (BP_HAS_INDIRECT_MAC_CKSUM(bp)) {
crypt_type = "indirect-MAC";
} else {
crypt_type = "unencrypted";
}
if (!BP_IS_EMBEDDED(bp)) {
checksum =
zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name;
@@ -1452,7 +1442,7 @@ snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp)
}
SNPRINTF_BLKPTR(snprintf, ' ', buf, buflen, bp, type, checksum,
crypt_type, compress);
compress);
}
void