Skip to content

Commit ca7feb1

Browse files
feat(blobstore): add function to return max growable size of the blobstore
Signed-off-by: Abhilash Shetty <[email protected]>
1 parent 725f441 commit ca7feb1

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

include/spdk/blob.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,16 @@ uint64_t spdk_bs_get_md_len(struct spdk_blob_store *bs);
494494
*/
495495
uint64_t spdk_bs_get_used_md(struct spdk_blob_store *bs);
496496

497+
/**
498+
* Get the maximum growable size of blobstore. floored to GiB value, in bytes
499+
*
500+
* \param bs blobstore to query.
501+
*
502+
* \return the maximum growable size in bytes
503+
*/
504+
uint64_t
505+
spdk_bs_get_max_growable_size(struct spdk_blob_store *bs);
506+
497507
/**
498508
* Get the blob id.
499509
*

lib/blob/blobstore.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6185,6 +6185,25 @@ spdk_bs_get_used_md(struct spdk_blob_store *bs)
61856185
return res;
61866186
}
61876187

6188+
uint64_t
6189+
spdk_bs_get_max_growable_size(struct spdk_blob_store *bs)
6190+
{
6191+
uint64_t max_used_cluster_mask, max_growable_size;
6192+
6193+
/* Calculate max number of pages for used_cluster_mask. This is immutable.
6194+
*/
6195+
max_used_cluster_mask = spdk_divide_round_up(sizeof(struct spdk_bs_md_mask) +
6196+
spdk_divide_round_up(bs->md_len, 8),
6197+
SPDK_BS_PAGE_SIZE);
6198+
6199+
/* max growable size = Total number of bits * cluster size */
6200+
max_growable_size = max_used_cluster_mask * (SPDK_BS_PAGE_SIZE - sizeof(struct spdk_bs_md_mask)) * 8 * bs->cluster_sz;
6201+
6202+
/* Floor to the nearest GiB, in bytes */
6203+
max_growable_size &= ~((1ULL << 30) - 1);
6204+
return max_growable_size;
6205+
}
6206+
61886207
static int
61896208
bs_register_md_thread(struct spdk_blob_store *bs)
61906209
{

0 commit comments

Comments
 (0)