Commit 423e41f0 authored by Abhilash Shetty's avatar Abhilash Shetty Committed by Jim Harris
Browse files

blobstore: add function to get max growable size



Introduce spdk_bs_get_max_growable_size() in blobstore.
This provides the maximum number of bytes a blobstore can grow upto,
taking cluster size and metadata limits into account.

We fail the grow request if bdev grows beyond the growable size. Most
storage solution doesnt allow shrink so it's diffcult to get around this
error without recreating lvs.

expose max_growable_size from bdev_lvol_get_lvstores rpc. update jsonrpc
documentation.

Change-Id: I83e817c5ae340ebc99843e80a717d66f613a3639
Signed-off-by: default avatarAbhilash Shetty <abhilash.shetty@datacore.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26416


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
parent c21780b7
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -9519,7 +9519,8 @@ wanting to support future growth. For example,
num_md_pages_per_cluster_ratio = 200 would support future 2x growth of
the logical volume store, and would result in 0.2% of the underlying
block device allocated for metadata (with a default 4MiB cluster
size).
size). The amount of future growth can be determined with the `max_growable_size`
parameter from the bdev_lvol_get_lvstores RPC.

{{ bdev_lvol_create_lvstore_params }}

@@ -9630,7 +9631,8 @@ Example response:
      "cluster_size": 4194304,
      "total_data_clusters": 31,
      "block_size": 4096,
      "name": "LVS0"
      "name": "LVS0",
      "max_growable_size": 137271181312
   }
  ]
}
@@ -9674,6 +9676,12 @@ Example response:

Grow the logical volume store to fill the underlying bdev

Growth is limited by the number of metadata pages allocated when the lvstore was created,
and its specific max size can be found using the `max_growable_size` parameter from the
bdev_lvol_get_lvstores RPC.

This RPC can be called to grow an lvolstore when the underlying bdev has increased in size.

#### Parameters

Either uuid or lvs_name must be specified, but not both.
+10 −0
Original line number Diff line number Diff line
@@ -449,6 +449,16 @@ uint64_t spdk_bs_get_cluster_size(struct spdk_blob_store *bs);
 */
uint64_t spdk_bs_get_page_size(struct spdk_blob_store *bs);

/**
 * Get the maximum growable size of blobstore, in bytes.
 *
 * \param bs blobstore to query.
 *
 * \return the maximum growable size in bytes
 */
uint64_t
spdk_bs_get_max_growable_size(struct spdk_blob_store *bs);

/**
 * Get the io unit size in bytes.
 *
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 13
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = blobstore.c request.c zeroes.c blob_bs_dev.c
LIBNAME = blob
+18 −0
Original line number Diff line number Diff line
@@ -6129,6 +6129,24 @@ spdk_bs_get_page_size(struct spdk_blob_store *bs)
	return bs->md_page_size;
}

uint64_t
spdk_bs_get_max_growable_size(struct spdk_blob_store *bs)
{
	uint64_t max_used_cluster_mask, max_number_of_clusters;

	/* Calculate maximum number of pages reserved for used_cluster_mask,
	 * This is immutable.
	 */
	max_used_cluster_mask = spdk_divide_round_up(sizeof(struct spdk_bs_md_mask) +
				spdk_divide_round_up(bs->md_len, 8),
				spdk_bs_get_page_size(bs));
	/* In used_cluster_mask, It takes 1 bit to track a cluster. */
	max_number_of_clusters = ((max_used_cluster_mask * spdk_bs_get_page_size(bs))
				  - sizeof(struct spdk_bs_md_mask)) * 8;

	return max_number_of_clusters * bs->cluster_sz;
}

uint64_t
spdk_bs_get_io_unit_size(struct spdk_blob_store *bs)
{
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
	spdk_bs_get_io_unit_size;
	spdk_bs_free_cluster_count;
	spdk_bs_total_data_cluster_count;
	spdk_bs_get_max_growable_size;
	spdk_bs_grow;
	spdk_bs_grow_live;
	spdk_blob_get_id;
Loading