Commit 91c0a9d2 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

module/blob_bdev: add possibility to change size of bs_dev



spdk bdevs can change their size in run time,
so far there was no way for bs_dev to change its size too
without re-creating it.

Blobstore size in general is determined from size written down
in super block. Size of bs_dev is used in following cases:
- initializing blobstore (therefore will become super->size)
- loading blobstore (to check if super->size is not larger)
- growing blobstore (combines two of the above)
- parsing/writing out super block when super->size is 0

Last one is for compatibility with old versions of blobstore.

This effectively means bs_dev size is not used in run-time,
changing it will not affect blobstore even after reloads.
Either way re-creating bs_dev already changed its size.

This patch proposes adding interface that will allow to change
the bs_dev size in run-time, and later in the series add
a way to grow blobstore without reloading it.

There is no need to add a way to revert the bs_dev size.
All error handling for changes in super->size is done in
blobstore.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I3d7872d91f3b24d40976b4a8c64df860ddf642ae
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19453


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent ed966159
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -63,6 +63,13 @@ int spdk_bdev_create_bs_dev(const char *bdev_name, bool write,
			    spdk_bdev_event_cb_t event_cb, void *event_ctx,
			    struct spdk_bs_dev **bs_dev);

/**
 * Updates number of blocks of a blobstore block device.
 *
 * \param bs_dev Blobstore block device.
 */
void spdk_bdev_update_bs_blockcnt(struct spdk_bs_dev *bs_dev);

/**
 * Claim the bdev module for the given blobstore.
 *
+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 := 10
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = blob_bdev.c
LIBNAME = blob_bdev
+9 −0
Original line number Diff line number Diff line
@@ -482,6 +482,15 @@ blob_bdev_init(struct blob_bdev *b, struct spdk_bdev_desc *desc)
	b->bs_dev.translate_lba = bdev_blob_translate_lba;
}

void
spdk_bdev_update_bs_blockcnt(struct spdk_bs_dev *bs_dev)
{
	struct blob_bdev *blob_bdev = (struct blob_bdev *)bs_dev;

	assert(bs_dev->blocklen == spdk_bdev_get_block_size(blob_bdev->bdev));
	bs_dev->blockcnt = spdk_bdev_get_num_blocks(blob_bdev->bdev);
}

int
spdk_bdev_create_bs_dev(const char *bdev_name, bool write,
			struct spdk_bdev_bs_dev_opts *opts, size_t opts_size,
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
	# public functions
	spdk_bdev_create_bs_dev;
	spdk_bdev_create_bs_dev_ext;
	spdk_bdev_update_bs_blockcnt;
	spdk_bs_bdev_claim;

	local: *;