From 1b23560fcd64801be5528a2fedd5588a033f5c45 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Fri, 10 Jan 2020 05:30:08 -0500 Subject: [PATCH] lib/blob: add _spdk_bs_cluster_to_extent_page() for easy conversion Signed-off-by: Tomasz Zawadzki Change-Id: I3e49c398d9bdf9f4eacba65061cc7fe4b300fb56 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479963 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Paul Luse Reviewed-by: Jim Harris --- lib/blob/blobstore.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/blob/blobstore.h b/lib/blob/blobstore.h index dc738e454..73107ab30 100644 --- a/lib/blob/blobstore.h +++ b/lib/blob/blobstore.h @@ -518,6 +518,24 @@ _spdk_bs_back_dev_lba_to_io_unit(struct spdk_blob *blob, uint64_t lba) return lba * (blob->back_bs_dev->blocklen / blob->bs->io_unit_size); } +static inline uint64_t +_spdk_bs_cluster_to_extent_table_id(uint64_t cluster_num) +{ + return cluster_num / SPDK_EXTENTS_PER_EP; +} + +static inline uint32_t * +_spdk_bs_cluster_to_extent_page(struct spdk_blob *blob, uint64_t cluster_num) +{ + uint64_t extent_table_id = _spdk_bs_cluster_to_extent_table_id(cluster_num); + + if (extent_table_id >= blob->active.extent_pages_array_size) { + return NULL; + } + + return &blob->active.extent_pages[extent_table_id]; +} + /* End basic conversions */ static inline uint64_t