blob: print invalid, data_ro, and md_ro flags

When blobcli prints blob metadata, it will now Print invalid_flags,
data_ro_flags, and md_ro_flags when printing blob metadata.  The
complete mask is printed as well as the meaning of each bit or set of
bits.  If unknown bits are set, that will be indicated in the output
as well.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I743a843a5d23b0e81c04482304515ab3c3b4c7bc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11257
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Mike Gerdts 2021-12-20 15:59:34 +00:00 committed by Jim Harris
parent 94cbdf5340
commit 6e440ff1d1

View File

@ -4646,6 +4646,72 @@ bs_dump_print_xattr(struct spdk_bs_load_ctx *ctx, struct spdk_blob_md_descriptor
}
}
struct type_flag_desc {
uint64_t mask;
uint64_t val;
const char *name;
};
static void
bs_dump_print_type_bits(struct spdk_bs_load_ctx *ctx, uint64_t flags,
struct type_flag_desc *desc, size_t numflags)
{
uint64_t covered = 0;
size_t i;
for (i = 0; i < numflags; i++) {
if ((desc[i].mask & flags) != desc[i].val) {
continue;
}
fprintf(ctx->fp, "\t\t 0x%016" PRIx64 " %s", desc[i].val, desc[i].name);
if (desc[i].mask != desc[i].val) {
fprintf(ctx->fp, " (mask 0x%" PRIx64 " value 0x%" PRIx64 ")",
desc[i].mask, desc[i].val);
}
fprintf(ctx->fp, "\n");
covered |= desc[i].mask;
}
if ((flags & ~covered) != 0) {
fprintf(ctx->fp, "\t\t 0x%016" PRIx64 " Unknown\n", flags & ~covered);
}
}
static void
bs_dump_print_type_flags(struct spdk_bs_load_ctx *ctx, struct spdk_blob_md_descriptor *desc)
{
struct spdk_blob_md_descriptor_flags *type_desc;
#define ADD_FLAG(f) { f, f, #f }
#define ADD_MASK_VAL(m, v) { m, v, #v }
static struct type_flag_desc invalid[] = {
ADD_FLAG(SPDK_BLOB_THIN_PROV),
ADD_FLAG(SPDK_BLOB_INTERNAL_XATTR),
ADD_FLAG(SPDK_BLOB_EXTENT_TABLE),
};
static struct type_flag_desc data_ro[] = {
ADD_FLAG(SPDK_BLOB_READ_ONLY),
};
static struct type_flag_desc md_ro[] = {
ADD_MASK_VAL(SPDK_BLOB_MD_RO_FLAGS_MASK, BLOB_CLEAR_WITH_DEFAULT),
ADD_MASK_VAL(SPDK_BLOB_MD_RO_FLAGS_MASK, BLOB_CLEAR_WITH_NONE),
ADD_MASK_VAL(SPDK_BLOB_MD_RO_FLAGS_MASK, BLOB_CLEAR_WITH_UNMAP),
ADD_MASK_VAL(SPDK_BLOB_MD_RO_FLAGS_MASK, BLOB_CLEAR_WITH_WRITE_ZEROES),
};
#undef ADD_FLAG
#undef ADD_MASK_VAL
type_desc = (struct spdk_blob_md_descriptor_flags *)desc;
fprintf(ctx->fp, "Flags:\n");
fprintf(ctx->fp, "\tinvalid: 0x%016" PRIx64 "\n", type_desc->invalid_flags);
bs_dump_print_type_bits(ctx, type_desc->invalid_flags, invalid,
SPDK_COUNTOF(invalid));
fprintf(ctx->fp, "\tdata_ro: 0x%016" PRIx64 "\n", type_desc->data_ro_flags);
bs_dump_print_type_bits(ctx, type_desc->data_ro_flags, data_ro,
SPDK_COUNTOF(data_ro));
fprintf(ctx->fp, "\t md_ro: 0x%016" PRIx64 "\n", type_desc->md_ro_flags);
bs_dump_print_type_bits(ctx, type_desc->md_ro_flags, md_ro,
SPDK_COUNTOF(md_ro));
}
static void
bs_dump_print_md_page(struct spdk_bs_load_ctx *ctx)
{
@ -4719,7 +4785,7 @@ bs_dump_print_md_page(struct spdk_bs_load_ctx *ctx)
} else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_XATTR_INTERNAL) {
bs_dump_print_xattr(ctx, desc);
} else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_FLAGS) {
/* TODO */
bs_dump_print_type_flags(ctx, desc);
} else {
/* Error */
}