From 5c29449f4ed63752f891f92b10f7e61d9587c197 Mon Sep 17 00:00:00 2001 From: Mike Gerdts Date: Mon, 20 Dec 2021 16:12:45 +0000 Subject: [PATCH] blob: print extent tables When blobcli is printing blob metadata, extent tables are now printed. Signed-off-by: Mike Gerdts Change-Id: Ie748a2f2b3fbc3e6e5ee06a0f2eb9bd491bfed46 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11259 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto Reviewed-by: Paul Luse Reviewed-by: Jim Harris --- lib/blob/blobstore.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 259efd4895..c3de30a18d 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -4712,6 +4712,30 @@ bs_dump_print_type_flags(struct spdk_bs_load_ctx *ctx, struct spdk_blob_md_descr SPDK_COUNTOF(md_ro)); } +static void +bs_dump_print_extent_table(struct spdk_bs_load_ctx *ctx, struct spdk_blob_md_descriptor *desc) +{ + struct spdk_blob_md_descriptor_extent_table *et_desc; + uint64_t num_extent_pages; + uint32_t et_idx; + + et_desc = (struct spdk_blob_md_descriptor_extent_table *)desc; + num_extent_pages = (et_desc->length - sizeof(et_desc->num_clusters)) / + sizeof(et_desc->extent_page[0]); + + fprintf(ctx->fp, "Extent table:\n"); + for (et_idx = 0; et_idx < num_extent_pages; et_idx++) { + if (et_desc->extent_page[et_idx].page_idx == 0) { + /* Zeroes represent unallocated extent pages. */ + continue; + } + fprintf(ctx->fp, "\tExtent page: %5" PRIu32 " length %3" PRIu32 + " at LBA %" PRIu64 "\n", et_desc->extent_page[et_idx].page_idx, + et_desc->extent_page[et_idx].num_pages, + bs_md_page_to_lba(ctx->bs, et_desc->extent_page[et_idx].page_idx)); + } +} + static void bs_dump_print_md_page(struct spdk_bs_load_ctx *ctx) { @@ -4786,6 +4810,8 @@ bs_dump_print_md_page(struct spdk_bs_load_ctx *ctx) bs_dump_print_xattr(ctx, desc); } else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_FLAGS) { bs_dump_print_type_flags(ctx, desc); + } else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_EXTENT_TABLE) { + bs_dump_print_extent_table(ctx, desc); } else { /* Error */ fprintf(ctx->fp, "Unknown descriptor type %" PRIu8 "\n", desc->type);