lvol: add spdk_lvs_opts_init()
Some future patches will require specifying an lvol_store name when calling spdk_lvs_init(). This means that passing NULL for spdk_lvs_opts will no longer be an option. So add an spdk_lvs_opts_init() (similar to spdk_bs_opts_init) which will initialize a default value for the cluster size. While here, prepend an underscore to spdk_setup_lvs_opts, since this function is not part of the public SPDK API. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I155bcfd0c396017304bb3d58b7511ada71dade17 Reviewed-on: https://review.gerrithub.io/383030 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
f678097d50
commit
f97c8b3142
@ -49,6 +49,9 @@ struct spdk_lvs_opts {
|
||||
uint32_t cluster_sz;
|
||||
};
|
||||
|
||||
/* Initialize an spdk_lvs_opts structure to the default logical volume store option values. */
|
||||
void spdk_lvs_opts_init(struct spdk_lvs_opts *opts);
|
||||
|
||||
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);
|
||||
|
@ -105,8 +105,7 @@ vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
|
||||
{
|
||||
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;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc;
|
||||
|
||||
if (base_bdev == NULL) {
|
||||
@ -114,9 +113,9 @@ vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
spdk_lvs_opts_init(&opts);
|
||||
if (cluster_sz != 0) {
|
||||
temp.cluster_sz = cluster_sz;
|
||||
opts = &temp;
|
||||
opts.cluster_sz = cluster_sz;
|
||||
}
|
||||
|
||||
lvs_req = calloc(1, sizeof(*lvs_req));
|
||||
@ -137,7 +136,7 @@ vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
|
||||
lvs_req->cb_fn = cb_fn;
|
||||
lvs_req->cb_arg = cb_arg;
|
||||
|
||||
rc = spdk_lvs_init(bs_dev, opts, _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);
|
||||
|
@ -172,15 +172,18 @@ _spdk_lvs_init_cb(void *cb_arg, struct spdk_blob_store *bs, int lvserrno)
|
||||
spdk_bs_md_create_blob(lvs->blobstore, _spdk_super_blob_create_cb, lvs_req);
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_setup_lvs_opts(struct spdk_bs_opts *bs_opts, struct spdk_lvs_opts *o)
|
||||
void
|
||||
spdk_lvs_opts_init(struct spdk_lvs_opts *o)
|
||||
{
|
||||
o->cluster_sz = SPDK_LVS_OPTS_CLUSTER_SZ;
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_setup_lvs_opts(struct spdk_bs_opts *bs_opts, struct spdk_lvs_opts *o)
|
||||
{
|
||||
assert(o != NULL);
|
||||
spdk_bs_opts_init(bs_opts);
|
||||
if (o) {
|
||||
bs_opts->cluster_sz = o->cluster_sz;
|
||||
} else {
|
||||
bs_opts->cluster_sz = SPDK_LVS_OPTS_CLUSTER_SZ;
|
||||
}
|
||||
bs_opts->cluster_sz = o->cluster_sz;
|
||||
}
|
||||
|
||||
int
|
||||
@ -196,7 +199,12 @@ spdk_lvs_init(struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
spdk_setup_lvs_opts(&opts, o);
|
||||
if (o == NULL) {
|
||||
SPDK_ERRLOG("spdk_lvs_opts not specified\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
_spdk_setup_lvs_opts(&opts, o);
|
||||
|
||||
lvs = calloc(1, sizeof(*lvs));
|
||||
if (!lvs) {
|
||||
|
@ -106,6 +106,11 @@ spdk_bdev_create_bs_dev(struct spdk_bdev *bdev, spdk_bdev_remove_cb_t remove_cb,
|
||||
return bs_dev;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_lvs_opts_init(struct spdk_lvs_opts *opts)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -212,15 +212,17 @@ static void
|
||||
lvs_init_unload_success(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
g_lvserrno = -1;
|
||||
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -296,14 +298,17 @@ static void
|
||||
lvol_create_destroy_success(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
g_lvserrno = -1;
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -327,19 +332,22 @@ static void
|
||||
lvol_create_fail(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
g_lvol_store = NULL;
|
||||
g_lvserrno = 0;
|
||||
rc = spdk_lvs_init(NULL, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = spdk_lvs_init(NULL, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc != 0);
|
||||
CU_ASSERT(g_lvol_store == NULL);
|
||||
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
|
||||
@ -365,13 +373,16 @@ static void
|
||||
lvol_destroy_fail(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -396,13 +407,16 @@ static void
|
||||
lvol_close_fail(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -427,14 +441,17 @@ static void
|
||||
lvol_close_success(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
g_lvserrno = -1;
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -458,15 +475,18 @@ static void
|
||||
lvol_resize(void)
|
||||
{
|
||||
struct spdk_bs_dev bs_dev;
|
||||
struct spdk_lvs_opts opts;
|
||||
int rc = 0;
|
||||
|
||||
init_dev(&bs_dev);
|
||||
|
||||
spdk_allocate_thread(_lvol_send_msg, NULL, NULL);
|
||||
|
||||
spdk_lvs_opts_init(&opts);
|
||||
|
||||
g_resize_rc = 0;
|
||||
g_lvserrno = -1;
|
||||
rc = spdk_lvs_init(&bs_dev, NULL, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = spdk_lvs_init(&bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user