Commit 9f6f73d4 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

lvol: allow to configure cluster size of lvol store



New optional parameter -c or --cluster_sz in construct_lvol_store() RPC,
as well as in vbdev_lvol and lvol lib API.

This parameter allows to configure cluster size of blobstore that lvol store
is build upon.

When this parameter is not specified, default of 1GiB is used.

spdk_lvs_opts struct was created to facilitate any future options when
creating lvol store.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ibfe8765ede3e78ff19c36f46043e4cec2e5c9f97
Reviewed-on: https://review.gerrithub.io/379356


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPiotr Pelpliński <piotr.pelplinski@intel.com>
parent 4790c403
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@
struct spdk_lvol_store;
struct spdk_lvol;

struct spdk_lvs_opts {
	uint32_t cluster_sz;
};

typedef void (*spdk_lvs_op_with_handle_complete)(void *cb_arg, struct spdk_lvol_store *lvol_store,
		int lvserrno);
typedef void (*spdk_lvs_op_complete)(void *cb_arg, int lvserrno);
@@ -52,7 +56,8 @@ typedef void (*spdk_lvol_op_complete)(void *cb_arg, int lvolerrno);
typedef void (*spdk_lvol_op_with_handle_complete)(void *cb_arg, struct spdk_lvol *lvol,
		int lvolerrno);

int spdk_lvs_init(struct spdk_bs_dev *bs_dev, spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg);
int spdk_lvs_init(struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o,
		  spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg);
int spdk_lvs_unload(struct spdk_lvol_store *lvol_store, spdk_lvs_op_complete cb_fn, void *cb_arg);
int spdk_lvol_create(struct spdk_lvol_store *lvs, uint64_t sz,
		     spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
#include "spdk/lvol.h"
#include "spdk_internal/bdev.h"

/* Default size of blobstore cluster */
#define SPDK_LVS_OPTS_CLUSTER_SZ (1024 * 1024 * 1024)

/* Length of string returned from uuid_unparse() */
#define UUID_STRING_LEN 37

+15 −4
Original line number Diff line number Diff line
@@ -92,14 +92,25 @@ end:
}

int
vbdev_lvs_create(struct spdk_bdev *base_bdev,
		 spdk_lvs_op_with_handle_complete cb_fn,
		 void *cb_arg)
vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
		 spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg)
{
	struct spdk_bs_dev *bs_dev;
	struct spdk_lvs_with_handle_req *lvs_req;
	struct spdk_lvs_opts *opts = NULL;
	struct spdk_lvs_opts temp;
	int rc;

	if (base_bdev == NULL) {
		SPDK_ERRLOG("Bdev does not exist\n");
		return -ENODEV;
	}

	if (cluster_sz != 0) {
		temp.cluster_sz = cluster_sz;
		opts = &temp;
	}

	lvs_req = calloc(1, sizeof(*lvs_req));
	if (!lvs_req) {
		SPDK_ERRLOG("Cannot alloc memory for vbdev lvol store request pointer\n");
@@ -118,7 +129,7 @@ vbdev_lvs_create(struct spdk_bdev *base_bdev,
	lvs_req->cb_fn = cb_fn;
	lvs_req->cb_arg = cb_arg;

	rc = spdk_lvs_init(bs_dev, _vbdev_lvs_create_cb, lvs_req);
	rc = spdk_lvs_init(bs_dev, opts, _vbdev_lvs_create_cb, lvs_req);
	if (rc < 0) {
		free(lvs_req);
		bs_dev->destroy(bs_dev);
+2 −2
Original line number Diff line number Diff line
@@ -45,8 +45,8 @@ struct lvol_store_bdev {

	TAILQ_ENTRY(lvol_store_bdev)	lvol_stores;
};
int vbdev_lvs_create(struct spdk_bdev *base_bdev, spdk_lvs_op_with_handle_complete cb_fn,
		     void *cb_arg);
int vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
		     spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg);
void vbdev_lvs_destruct(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg);

int vbdev_lvol_create(uuid_t uuid, size_t sz, spdk_lvol_op_with_handle_complete cb_fn,
+3 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ SPDK_LOG_REGISTER_TRACE_FLAG("lvolrpc", SPDK_TRACE_LVOL_RPC)

struct rpc_construct_lvol_store {
	char *base_name;
	uint32_t cluster_sz;
};

static void
@@ -52,6 +53,7 @@ free_rpc_construct_lvol_store(struct rpc_construct_lvol_store *req)

static const struct spdk_json_object_decoder rpc_construct_lvol_store_decoders[] = {
	{"base_name", offsetof(struct rpc_construct_lvol_store, base_name), spdk_json_decode_string},
	{"cluster_sz", offsetof(struct rpc_construct_lvol_store, cluster_sz), spdk_json_decode_uint32, true},
};

static void
@@ -114,7 +116,7 @@ spdk_rpc_construct_lvol_store(struct spdk_jsonrpc_request *request,
		goto invalid;
	}

	rc = vbdev_lvs_create(bdev, _spdk_rpc_lvol_store_construct_cb, request);
	rc = vbdev_lvs_create(bdev, req.cluster_sz, _spdk_rpc_lvol_store_construct_cb, request);
	if (rc < 0) {
		goto invalid;
	}
Loading