Commit 88833020 authored by yupeng's avatar yupeng Committed by Ben Walker
Browse files

blobstore: reserve space for growing blobstore



Reserve space for used_cluster bitmap. The reserved space is calculated
according to the num_md_pages. The reserved space would be used when
the blobstore is extended in the future.
Add the num_md_pages_per_cluster_ratio parameter to the
bdev_lvol_create_lvstore API. Then calculate the num_md_pages
according to the num_md_pages_per_cluster_ratio and bdev total size, then
pass the num_md_pages to the blobstore.

Signed-off-by: default avatarPeng Yu <yupeng0921@gmail.com>
Change-Id: I61a28a3c931227e0fd3e1ef6b145fc18a3657751
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9517


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 72c4255e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -7,6 +7,16 @@
Added new `ssl` based socket implementation, the code is located in module/sock/posix.
For now we are using hard-coded PSK and only support TLS 1.3

### blobstore

Reserve space for used_cluster bitmap. The reserved space could be used for blobstore growing
in the future.

### lvol

Add num_md_pages_per_cluster_ratio parameter to the bdev_lvol_create_lvstore RPC.
Calculate num_md_pages from num_md_pages_per_cluster_ratio, and pass it to spdk_bs_opts.

## v22.05

### sock
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ struct spdk_lvs_opts {
	uint32_t		cluster_sz;
	enum lvs_clear_method	clear_method;
	char			name[SPDK_LVS_NAME_MAX];
	/** num_md_pages_per_cluster_ratio = 100 means 1 page per cluster */
	uint32_t		num_md_pages_per_cluster_ratio;
};

/**
+11 −1
Original line number Diff line number Diff line
@@ -4995,6 +4995,7 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
	uint64_t		num_md_lba;
	uint64_t		num_md_pages;
	uint64_t		num_md_clusters;
	uint64_t		max_used_cluster_mask_len;
	uint32_t		i;
	struct spdk_bs_opts	opts = {};
	int			rc;
@@ -5101,7 +5102,16 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
	ctx->super->used_cluster_mask_len = spdk_divide_round_up(sizeof(struct spdk_bs_md_mask) +
					    spdk_divide_round_up(bs->total_clusters, 8),
					    SPDK_BS_PAGE_SIZE);
	num_md_pages += ctx->super->used_cluster_mask_len;
	/* The blobstore might be extended, then the used_cluster bitmap will need more space.
	 * Here we calculate the max clusters we can support according to the
	 * num_md_pages (bs->md_len).
	 */
	max_used_cluster_mask_len = spdk_divide_round_up(sizeof(struct spdk_bs_md_mask) +
				    spdk_divide_round_up(bs->md_len, 8),
				    SPDK_BS_PAGE_SIZE);
	max_used_cluster_mask_len = spdk_max(max_used_cluster_mask_len,
					     ctx->super->used_cluster_mask_len);
	num_md_pages += max_used_cluster_mask_len;

	/* The used_blobids mask requires 1 bit per metadata page, rounded
	 * up to the nearest page, plus a header.
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 6
SO_VER := 7
SO_MINOR := 0

C_SRCS = lvol.c
+12 −2
Original line number Diff line number Diff line
@@ -526,16 +526,18 @@ spdk_lvs_opts_init(struct spdk_lvs_opts *o)
{
	o->cluster_sz = SPDK_LVS_OPTS_CLUSTER_SZ;
	o->clear_method = LVS_CLEAR_WITH_UNMAP;
	o->num_md_pages_per_cluster_ratio = 100;
	memset(o->name, 0, sizeof(o->name));
}

static void
setup_lvs_opts(struct spdk_bs_opts *bs_opts, struct spdk_lvs_opts *o)
setup_lvs_opts(struct spdk_bs_opts *bs_opts, struct spdk_lvs_opts *o, uint32_t total_clusters)
{
	assert(o != NULL);
	lvs_bs_opts_init(bs_opts);
	bs_opts->cluster_sz = o->cluster_sz;
	bs_opts->clear_method = (enum bs_clear_method)o->clear_method;
	bs_opts->num_md_pages = (o->num_md_pages_per_cluster_ratio * total_clusters) / 100;
}

int
@@ -545,6 +547,7 @@ spdk_lvs_init(struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o,
	struct spdk_lvol_store *lvs;
	struct spdk_lvs_with_handle_req *lvs_req;
	struct spdk_bs_opts opts = {};
	uint32_t total_clusters;
	int rc;

	if (bs_dev == NULL) {
@@ -557,7 +560,14 @@ spdk_lvs_init(struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o,
		return -EINVAL;
	}

	setup_lvs_opts(&opts, o);
	if (o->cluster_sz < bs_dev->blocklen) {
		SPDK_ERRLOG("Cluster size %" PRIu32 " is smaller than blocklen %" PRIu32 "\n",
			    opts.cluster_sz, bs_dev->blocklen);
		return -EINVAL;
	}
	total_clusters = bs_dev->blockcnt / (o->cluster_sz / bs_dev->blocklen);

	setup_lvs_opts(&opts, o, total_clusters);

	if (strnlen(o->name, SPDK_LVS_NAME_MAX) == SPDK_LVS_NAME_MAX) {
		SPDK_ERRLOG("Name has no null terminator.\n");
Loading