lvol: add lvs name in rpc calls
Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com> Change-Id: Ic6770371d9d62cbdd40ae0612eb4f7dceccd507f Reviewed-on: https://review.gerrithub.io/383771 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
e5b0dd6ead
commit
511adde02f
@ -139,12 +139,13 @@ int spdk_lvs_destroy(struct spdk_lvol_store *lvol_store, bool unmap_device,
|
||||
/**
|
||||
* \brief Create lvol on given lvolstore with specified size
|
||||
* \param lvs Handle to lvolstore
|
||||
* \param name Name of lvol
|
||||
* \param sz size of lvol in bytes
|
||||
* \param cb_fn Completion callback
|
||||
* \param cb_arg Completion callback custom arguments
|
||||
* \return error
|
||||
*/
|
||||
int spdk_lvol_create(struct spdk_lvol_store *lvs, char *name, uint64_t sz,
|
||||
int spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
|
||||
spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
@ -191,6 +192,12 @@ struct spdk_lvol *vbdev_get_lvol_by_name(const char *name);
|
||||
* \return Handle to spdk_lvol_store or NULL if not found.
|
||||
*/
|
||||
struct spdk_lvol_store *vbdev_get_lvol_store_by_uuid(uuid_t uuid);
|
||||
/**
|
||||
* \brief Search for handle to lvolstore
|
||||
* \param name name of lvolstore
|
||||
* \return Handle to spdk_lvol_store or NULL if not found.
|
||||
*/
|
||||
struct spdk_lvol_store *vbdev_get_lvol_store_by_name(const char *name);
|
||||
void spdk_lvs_load(struct spdk_bs_dev *bs_dev, spdk_lvs_op_with_handle_complete cb_fn,
|
||||
void *cb_arg);
|
||||
void spdk_lvol_open(struct spdk_lvol *lvol, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);
|
||||
|
@ -102,14 +102,14 @@ end:
|
||||
}
|
||||
|
||||
int
|
||||
vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
|
||||
vbdev_lvs_create(struct spdk_bdev *base_bdev, const char *name, 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;
|
||||
uuid_t uuid;
|
||||
int rc;
|
||||
int len;
|
||||
|
||||
if (base_bdev == NULL) {
|
||||
SPDK_ERRLOG("Bdev does not exist\n");
|
||||
@ -121,12 +121,18 @@ vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
|
||||
opts.cluster_sz = cluster_sz;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is temporary until the RPCs take a name parameter for creating
|
||||
* an lvolstore.
|
||||
*/
|
||||
uuid_generate(uuid);
|
||||
uuid_unparse(uuid, opts.name);
|
||||
if (name == NULL) {
|
||||
SPDK_ERRLOG("missing name param\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
len = strnlen(name, SPDK_LVS_NAME_MAX);
|
||||
|
||||
if (len == 0 || len == SPDK_LVS_NAME_MAX) {
|
||||
SPDK_ERRLOG("name must be between 1 and %d characters\n", SPDK_LVS_NAME_MAX - 1);
|
||||
return -EINVAL;
|
||||
}
|
||||
strncpy(opts.name, name, sizeof(opts.name));
|
||||
|
||||
lvs_req = calloc(1, sizeof(*lvs_req));
|
||||
if (!lvs_req) {
|
||||
@ -286,6 +292,22 @@ vbdev_get_lvol_store_by_uuid(uuid_t uuid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spdk_lvol_store *
|
||||
vbdev_get_lvol_store_by_name(const char *name)
|
||||
{
|
||||
struct spdk_lvol_store *lvs = NULL;
|
||||
struct lvol_store_bdev *lvs_bdev = vbdev_lvol_store_first();
|
||||
|
||||
while (lvs_bdev != NULL) {
|
||||
lvs = lvs_bdev->lvs;
|
||||
if (strncmp(lvs->name, name, sizeof(lvs->name)) == 0) {
|
||||
return lvs;
|
||||
}
|
||||
lvs_bdev = vbdev_lvol_store_next(lvs_bdev);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct lvol_store_bdev *
|
||||
vbdev_get_lvs_bdev_by_lvs(struct spdk_lvol_store *lvs_orig)
|
||||
{
|
||||
@ -356,6 +378,7 @@ _vbdev_lvol_destroy_cb(void *cb_arg, int lvserrno)
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Lvol destroyed\n");
|
||||
|
||||
spdk_bdev_unregister_done(bdev, lvserrno);
|
||||
free(bdev->name);
|
||||
free(bdev);
|
||||
}
|
||||
|
||||
@ -368,6 +391,7 @@ _vbdev_lvol_destroy_after_close_cb(void *cb_arg, int lvserrno)
|
||||
if (lvserrno != 0) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Could not close Lvol %s\n", lvol->old_name);
|
||||
spdk_bdev_unregister_done(bdev, lvserrno);
|
||||
free(bdev->name);
|
||||
free(bdev);
|
||||
return;
|
||||
}
|
||||
@ -384,6 +408,7 @@ vbdev_lvol_destruct(void *ctx)
|
||||
assert(lvol != NULL);
|
||||
|
||||
if (lvol->close_only) {
|
||||
free(lvol->bdev->name);
|
||||
free(lvol->bdev);
|
||||
spdk_lvol_close(lvol, _vbdev_lvol_close_cb, NULL);
|
||||
} else {
|
||||
@ -581,7 +606,12 @@ _create_lvol_disk(struct spdk_lvol *lvol)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bdev->name = lvol->old_name;
|
||||
bdev->name = spdk_sprintf_alloc("%s/%s", lvs_bdev->lvs->name, lvol->name);
|
||||
if (bdev->name == NULL) {
|
||||
SPDK_ERRLOG("Cannot alloc memory for bdev name\n");
|
||||
free(bdev);
|
||||
return NULL;
|
||||
}
|
||||
bdev->product_name = "Logical Volume";
|
||||
bdev->write_cache = 1;
|
||||
bdev->blocklen = spdk_bs_get_page_size(lvol->lvol_store->blobstore);
|
||||
@ -621,13 +651,11 @@ end:
|
||||
}
|
||||
|
||||
int
|
||||
vbdev_lvol_create(uuid_t uuid, size_t sz,
|
||||
vbdev_lvol_create(uuid_t uuid, const char *name, size_t sz,
|
||||
spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_lvol_with_handle_req *req;
|
||||
struct spdk_lvol_store *lvs;
|
||||
uuid_t lvol_uuid;
|
||||
char name[SPDK_LVOL_NAME_MAX];
|
||||
int rc;
|
||||
|
||||
lvs = vbdev_get_lvol_store_by_uuid(uuid);
|
||||
@ -642,13 +670,6 @@ vbdev_lvol_create(uuid_t uuid, size_t sz,
|
||||
req->cb_fn = cb_fn;
|
||||
req->cb_arg = cb_arg;
|
||||
|
||||
/*
|
||||
* This is temporary until the RPCs take a name parameter for creating
|
||||
* an lvol.
|
||||
*/
|
||||
uuid_generate(lvol_uuid);
|
||||
uuid_unparse(lvol_uuid, name);
|
||||
|
||||
rc = spdk_lvol_create(lvs, name, sz, _vbdev_lvol_create_cb, req);
|
||||
if (rc != 0) {
|
||||
free(req);
|
||||
|
@ -46,12 +46,14 @@ struct lvol_store_bdev {
|
||||
|
||||
TAILQ_ENTRY(lvol_store_bdev) lvol_stores;
|
||||
};
|
||||
int vbdev_lvs_create(struct spdk_bdev *base_bdev, uint32_t cluster_sz,
|
||||
|
||||
int vbdev_lvs_create(struct spdk_bdev *base_bdev, const char *name, 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);
|
||||
void vbdev_lvs_unload(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,
|
||||
int vbdev_lvol_create(uuid_t uuid, const char *name, size_t sz,
|
||||
spdk_lvol_op_with_handle_complete cb_fn,
|
||||
void *cb_arg);
|
||||
|
||||
int vbdev_lvol_resize(char *name, size_t sz, spdk_lvol_op_complete cb_fn, void *cb_arg);
|
||||
|
@ -41,19 +41,59 @@
|
||||
SPDK_LOG_REGISTER_TRACE_FLAG("lvolrpc", SPDK_TRACE_LVOL_RPC)
|
||||
|
||||
struct rpc_construct_lvol_store {
|
||||
char *base_name;
|
||||
char *lvs_name;
|
||||
char *bdev_name;
|
||||
uint32_t cluster_sz;
|
||||
};
|
||||
|
||||
static int
|
||||
vbdev_get_lvol_store_by_uuid_xor_name(const char *uuid, const char *lvs_name,
|
||||
struct spdk_lvol_store **lvs)
|
||||
{
|
||||
uuid_t lvol_store_uuid;
|
||||
|
||||
if ((uuid == NULL && lvs_name == NULL)) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "lvs UUID nor lvs name specified\n");
|
||||
return -EINVAL;
|
||||
} else if ((uuid && lvs_name)) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "both lvs UUID '%s' and lvs name '%s' specified\n", uuid,
|
||||
lvs_name);
|
||||
return -EINVAL;
|
||||
} else if (uuid) {
|
||||
if (uuid_parse(uuid, lvol_store_uuid)) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "incorrect UUID '%s'\n", uuid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*lvs = vbdev_get_lvol_store_by_uuid(lvol_store_uuid);
|
||||
|
||||
if (*lvs == NULL) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "blobstore with UUID '%p' not found\n", &lvol_store_uuid);
|
||||
return -ENODEV;
|
||||
}
|
||||
} else if (lvs_name) {
|
||||
|
||||
*lvs = vbdev_get_lvol_store_by_name(lvs_name);
|
||||
|
||||
if (*lvs == NULL) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "blobstore with name '%s' not found\n", lvs_name);
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
free_rpc_construct_lvol_store(struct rpc_construct_lvol_store *req)
|
||||
{
|
||||
free(req->base_name);
|
||||
free(req->bdev_name);
|
||||
free(req->lvs_name);
|
||||
}
|
||||
|
||||
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},
|
||||
{"bdev_name", offsetof(struct rpc_construct_lvol_store, bdev_name), spdk_json_decode_string},
|
||||
{"cluster_sz", offsetof(struct rpc_construct_lvol_store, cluster_sz), spdk_json_decode_uint32, true},
|
||||
{"lvs_name", offsetof(struct rpc_construct_lvol_store, lvs_name), spdk_json_decode_string},
|
||||
};
|
||||
|
||||
static void
|
||||
@ -103,20 +143,26 @@ spdk_rpc_construct_lvol_store(struct spdk_jsonrpc_request *request,
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (req.base_name == NULL) {
|
||||
SPDK_ERRLOG("missing name param\n");
|
||||
if (req.bdev_name == NULL) {
|
||||
SPDK_ERRLOG("missing bdev_name param\n");
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
bdev = spdk_bdev_get_by_name(req.base_name);
|
||||
if (req.lvs_name == NULL) {
|
||||
SPDK_ERRLOG("missing lvs_name param\n");
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
}
|
||||
bdev = spdk_bdev_get_by_name(req.bdev_name);
|
||||
if (bdev == NULL) {
|
||||
SPDK_ERRLOG("bdev '%s' does not exist\n", req.base_name);
|
||||
SPDK_ERRLOG("bdev '%s' does not exist\n", req.bdev_name);
|
||||
rc = -ENODEV;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
rc = vbdev_lvs_create(bdev, req.cluster_sz, _spdk_rpc_lvol_store_construct_cb, request);
|
||||
rc = vbdev_lvs_create(bdev, req.lvs_name, req.cluster_sz, _spdk_rpc_lvol_store_construct_cb,
|
||||
request);
|
||||
if (rc < 0) {
|
||||
goto invalid;
|
||||
}
|
||||
@ -132,17 +178,20 @@ invalid:
|
||||
SPDK_RPC_REGISTER("construct_lvol_store", spdk_rpc_construct_lvol_store)
|
||||
|
||||
struct rpc_destroy_lvol_store {
|
||||
char *lvol_store_uuid;
|
||||
char *uuid;
|
||||
char *lvs_name;
|
||||
};
|
||||
|
||||
static void
|
||||
free_rpc_destroy_lvol_store(struct rpc_destroy_lvol_store *req)
|
||||
{
|
||||
free(req->lvol_store_uuid);
|
||||
free(req->uuid);
|
||||
free(req->lvs_name);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_destroy_lvol_store_decoders[] = {
|
||||
{"lvol_store_uuid", offsetof(struct rpc_destroy_lvol_store, lvol_store_uuid), spdk_json_decode_string},
|
||||
{"uuid", offsetof(struct rpc_destroy_lvol_store, uuid), spdk_json_decode_string, true},
|
||||
{"lvs_name", offsetof(struct rpc_destroy_lvol_store, lvs_name), spdk_json_decode_string, true},
|
||||
};
|
||||
|
||||
static void
|
||||
@ -175,8 +224,7 @@ spdk_rpc_destroy_lvol_store(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_destroy_lvol_store req = {};
|
||||
struct spdk_lvol_store *lvs;
|
||||
uuid_t lvol_store_uuid;
|
||||
struct spdk_lvol_store *lvs = NULL;
|
||||
int rc;
|
||||
char buf[64];
|
||||
|
||||
@ -188,16 +236,8 @@ spdk_rpc_destroy_lvol_store(struct spdk_jsonrpc_request *request,
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (uuid_parse(req.lvol_store_uuid, lvol_store_uuid)) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL_RPC, "incorrect UUID '%s'\n", req.lvol_store_uuid);
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
lvs = vbdev_get_lvol_store_by_uuid(lvol_store_uuid);
|
||||
if (lvs == NULL) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL_RPC, "blobstore with UUID '%p' not found\n", &lvol_store_uuid);
|
||||
rc = -ENODEV;
|
||||
rc = vbdev_get_lvol_store_by_uuid_xor_name(req.uuid, req.lvs_name, &lvs);
|
||||
if (rc != 0) {
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
@ -215,18 +255,24 @@ invalid:
|
||||
SPDK_RPC_REGISTER("destroy_lvol_store", spdk_rpc_destroy_lvol_store)
|
||||
|
||||
struct rpc_construct_lvol_bdev {
|
||||
char *lvol_store_uuid;
|
||||
char *uuid;
|
||||
char *lvs_name;
|
||||
char *lvol_name;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
static void
|
||||
free_rpc_construct_lvol_bdev(struct rpc_construct_lvol_bdev *req)
|
||||
{
|
||||
free(req->lvol_store_uuid);
|
||||
free(req->uuid);
|
||||
free(req->lvs_name);
|
||||
free(req->lvol_name);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_construct_lvol_bdev_decoders[] = {
|
||||
{"lvol_store_uuid", offsetof(struct rpc_construct_lvol_bdev, lvol_store_uuid), spdk_json_decode_string},
|
||||
{"uuid", offsetof(struct rpc_construct_lvol_bdev, uuid), spdk_json_decode_string, true},
|
||||
{"lvs_name", offsetof(struct rpc_construct_lvol_bdev, lvs_name), spdk_json_decode_string, true},
|
||||
{"lvol_name", offsetof(struct rpc_construct_lvol_bdev, lvol_name), spdk_json_decode_string, true},
|
||||
{"size", offsetof(struct rpc_construct_lvol_bdev, size), spdk_json_decode_uint64},
|
||||
};
|
||||
|
||||
@ -247,7 +293,7 @@ _spdk_rpc_construct_lvol_bdev_cb(void *cb_arg, struct spdk_lvol *lvol, int lvole
|
||||
}
|
||||
|
||||
spdk_json_write_array_begin(w);
|
||||
spdk_json_write_string(w, lvol->old_name);
|
||||
spdk_json_write_string(w, lvol->bdev->name);
|
||||
spdk_json_write_array_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
return;
|
||||
@ -262,10 +308,10 @@ spdk_rpc_construct_lvol_bdev(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_construct_lvol_bdev req = {};
|
||||
uuid_t lvol_store_uuid;
|
||||
size_t sz;
|
||||
int rc;
|
||||
char buf[64];
|
||||
struct spdk_lvol_store *lvs = NULL;
|
||||
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL_RPC, "Creating blob\n");
|
||||
|
||||
@ -277,15 +323,20 @@ spdk_rpc_construct_lvol_bdev(struct spdk_jsonrpc_request *request,
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (uuid_parse(req.lvol_store_uuid, lvol_store_uuid)) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL_RPC, "incorrect UUID '%s'\n", req.lvol_store_uuid);
|
||||
rc = vbdev_get_lvol_store_by_uuid_xor_name(req.uuid, req.lvs_name, &lvs);
|
||||
if (rc != 0) {
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (req.lvol_name == NULL) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL_RPC, "no bdev name\n");
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
sz = (size_t)req.size;
|
||||
|
||||
rc = vbdev_lvol_create(lvol_store_uuid, sz, _spdk_rpc_construct_lvol_bdev_cb, request);
|
||||
rc = vbdev_lvol_create(lvs->uuid, req.lvol_name, sz, _spdk_rpc_construct_lvol_bdev_cb, request);
|
||||
if (rc < 0) {
|
||||
goto invalid;
|
||||
}
|
||||
@ -421,6 +472,9 @@ spdk_rpc_get_lvol_stores(struct spdk_jsonrpc_request *request,
|
||||
spdk_json_write_name(w, "uuid");
|
||||
spdk_json_write_string(w, uuid);
|
||||
|
||||
spdk_json_write_name(w, "name");
|
||||
spdk_json_write_string(w, lvs_bdev->lvs->name);
|
||||
|
||||
spdk_json_write_name(w, "base_bdev");
|
||||
spdk_json_write_string(w, spdk_bdev_get_name(lvs_bdev->bdev));
|
||||
|
||||
|
@ -909,7 +909,7 @@ _spdk_lvol_create_cb(void *cb_arg, spdk_blob_id blobid, int lvolerrno)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_lvol_create(struct spdk_lvol_store *lvs, char *name, uint64_t sz,
|
||||
spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
|
||||
spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_lvol_with_handle_req *req;
|
||||
|
@ -295,27 +295,34 @@ p.set_defaults(func=construct_error_bdev)
|
||||
|
||||
|
||||
def construct_lvol_store(args):
|
||||
params = {'base_name': args.base_name}
|
||||
params = {'bdev_name': args.bdev_name, 'lvs_name': args.lvs_name}
|
||||
|
||||
if args.cluster_sz:
|
||||
params['cluster_sz'] = args.cluster_sz
|
||||
|
||||
print_array(jsonrpc_call('construct_lvol_store', params))
|
||||
p = subparsers.add_parser('construct_lvol_store', help='Add logical volume store on base bdev')
|
||||
p.add_argument('base_name', help='base bdev name')
|
||||
p.add_argument('bdev_name', help='base bdev name')
|
||||
p.add_argument('lvs_name', help='name for lvol store')
|
||||
p.add_argument('-c', '--cluster-sz', help='size of cluster (in bytes)', type=int, required=False)
|
||||
p.set_defaults(func=construct_lvol_store)
|
||||
|
||||
|
||||
def construct_lvol_bdev(args):
|
||||
num_bytes = (args.size * 1024 * 1024)
|
||||
params = {
|
||||
'lvol_store_uuid': args.lvol_store_uuid,
|
||||
'size': num_bytes,
|
||||
}
|
||||
print_array(jsonrpc_call('construct_lvol_bdev', params))
|
||||
params = {'lvol_name': args.lvol_name, 'size': num_bytes}
|
||||
if (args.uuid and args.lvs_name) or (not args.uuid and not args.lvs_name):
|
||||
print("You need to specify either uuid or name of lvolstore")
|
||||
else:
|
||||
if args.uuid:
|
||||
params['uuid'] = args.uuid
|
||||
if args.lvs_name:
|
||||
params['lvs_name'] = args.lvs_name
|
||||
print_array(jsonrpc_call('construct_lvol_bdev', params))
|
||||
p = subparsers.add_parser('construct_lvol_bdev', help='Add a bdev with an logical volume backend')
|
||||
p.add_argument('lvol_store_uuid', help='lvol store UUID')
|
||||
p.add_argument('-u', '--uuid', help='lvol store UUID', required=False)
|
||||
p.add_argument('-l', '--lvs_name', help='lvol store name', required=False)
|
||||
p.add_argument('lvol_name', help='name for this lvol')
|
||||
p.add_argument('size', help='size in MiB for this bdev', type=int)
|
||||
p.set_defaults(func=construct_lvol_bdev)
|
||||
|
||||
@ -334,10 +341,18 @@ p.set_defaults(func=construct_lvol_bdev)
|
||||
|
||||
|
||||
def destroy_lvol_store(args):
|
||||
params = {'lvol_store_uuid': args.lvol_store_uuid}
|
||||
jsonrpc_call('destroy_lvol_store', params)
|
||||
params = {}
|
||||
if (args.uuid and args.lvs_name) or (not args.uuid and not args.lvs_name):
|
||||
print("You need to specify either uuid or name of lvolstore")
|
||||
else:
|
||||
if args.uuid:
|
||||
params['uuid'] = args.uuid
|
||||
if args.lvs_name:
|
||||
params['lvs_name'] = args.lvs_name
|
||||
jsonrpc_call('destroy_lvol_store', params)
|
||||
p = subparsers.add_parser('destroy_lvol_store', help='Destroy an logical volume store')
|
||||
p.add_argument('lvol_store_uuid', help='lvol store UUID')
|
||||
p.add_argument('-u', '--uuid', help='lvol store UUID', required=False)
|
||||
p.add_argument('-l', '--lvs_name', help='lvol store name', required=False)
|
||||
p.set_defaults(func=destroy_lvol_store)
|
||||
|
||||
|
||||
|
@ -41,11 +41,11 @@ for i in `seq 0 9`; do
|
||||
INITIATOR_TAG=$((i+2))
|
||||
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
|
||||
bdev=$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)
|
||||
ls_guid=$($rpc_py construct_lvol_store $bdev -c 1048576)
|
||||
ls_guid=$($rpc_py construct_lvol_store $bdev lvs_$i -c 1048576)
|
||||
LUNs=""
|
||||
for j in `seq 0 9`; do
|
||||
lb_guid=$($rpc_py construct_lvol_bdev $ls_guid 10)
|
||||
LUNs+="$lb_guid:$j "
|
||||
lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_$j 10)
|
||||
LUNs+="$lb_name:$j "
|
||||
done
|
||||
$rpc_py construct_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 1 0 0 0
|
||||
done
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
from uuid import UUID
|
||||
from subprocess import check_output, CalledProcessError
|
||||
|
||||
|
||||
@ -87,20 +88,32 @@ class Commands_Rpc(object):
|
||||
output = self.rpc.construct_malloc_bdev(total_size, block_size)[0]
|
||||
return output.rstrip('\n')
|
||||
|
||||
def construct_lvol_store(self, base_name, cluster_size):
|
||||
def construct_lvol_store(self, base_name, lvs_name, cluster_size):
|
||||
print("INFO: RPC COMMAND construct_lvol_store")
|
||||
output = self.rpc.construct_lvol_store(
|
||||
base_name, "-c {cluster_sz}".format(cluster_sz=cluster_size))[0]
|
||||
base_name,
|
||||
lvs_name,
|
||||
"-c {cluster_sz}".format(cluster_sz=cluster_size))[0]
|
||||
return output.rstrip('\n')
|
||||
|
||||
def construct_lvol_bdev(self, uuid, size):
|
||||
def construct_lvol_bdev(self, uuid, lbd_name, size):
|
||||
print("INFO: RPC COMMAND construct_lvol_bdev")
|
||||
output = self.rpc.construct_lvol_bdev(uuid, size)[0]
|
||||
try:
|
||||
uuid_obj = UUID(uuid)
|
||||
name_opt = "-u"
|
||||
except ValueError:
|
||||
name_opt = "-l"
|
||||
output = self.rpc.construct_lvol_bdev(name_opt, uuid, lbd_name, size)[0]
|
||||
return output.rstrip('\n')
|
||||
|
||||
def destroy_lvol_store(self, uuid):
|
||||
print("INFO: RPC COMMAND destroy_lvol_store")
|
||||
output, rc = self.rpc.destroy_lvol_store(uuid)
|
||||
try:
|
||||
uuid_obj = UUID(uuid)
|
||||
name_opt = "-u"
|
||||
except ValueError:
|
||||
name_opt = "-l"
|
||||
output, rc = self.rpc.destroy_lvol_store(name_opt, uuid)
|
||||
return rc
|
||||
|
||||
def delete_bdev(self, base_name):
|
||||
|
@ -59,6 +59,8 @@ class TestCases(object):
|
||||
self.block_size = block_size
|
||||
self.cluster_size = cluster_size
|
||||
self.path = base_dir_path
|
||||
self.lvs_name = "lvs_test"
|
||||
self.lbd_name = "lbd_test"
|
||||
|
||||
def _gen_lvs_uudi(self):
|
||||
return str(uuid4())
|
||||
@ -71,7 +73,9 @@ class TestCases(object):
|
||||
header(1)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
self.c.destroy_lvol_store(uuid_store)
|
||||
@ -84,10 +88,14 @@ class TestCases(object):
|
||||
header(2)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name,
|
||||
self.total_size - 1)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
|
||||
self.total_size - 1)
|
||||
self.c.delete_bdev(uuid_bdev)
|
||||
@ -100,14 +108,18 @@ class TestCases(object):
|
||||
header(3)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
size = ((self.total_size - 1) / 4)
|
||||
|
||||
uuid_bdevs = []
|
||||
for _ in range(4):
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, size)
|
||||
for i in range(4):
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name + str(i),
|
||||
size)
|
||||
uuid_bdevs.append(uuid_bdev)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)
|
||||
|
||||
@ -123,11 +135,15 @@ class TestCases(object):
|
||||
header(4)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
# size is equal to one quarter of size malloc bdev
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size / 4)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name,
|
||||
self.total_size / 4)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
|
||||
self.total_size / 4)
|
||||
# size is equal to half of size malloc bdev
|
||||
@ -152,7 +168,9 @@ class TestCases(object):
|
||||
header(5)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
self.c.destroy_lvol_store(uuid_store)
|
||||
@ -165,10 +183,14 @@ class TestCases(object):
|
||||
header(6)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name,
|
||||
self.total_size - 1)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
|
||||
self.total_size - 1)
|
||||
if self.c.destroy_lvol_store(uuid_store) != 0:
|
||||
@ -183,13 +205,17 @@ class TestCases(object):
|
||||
header(7)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
size = ((self.total_size - 1) / 4)
|
||||
|
||||
for _ in range(4):
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, size)
|
||||
for i in range(4):
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name + str(i),
|
||||
size)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)
|
||||
|
||||
self.c.destroy_lvol_store(uuid_store)
|
||||
@ -207,11 +233,15 @@ class TestCases(object):
|
||||
header(9)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
size = ((self.total_size - 1) / 4)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, size)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name,
|
||||
size)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
|
||||
size)
|
||||
|
||||
@ -234,7 +264,9 @@ class TestCases(object):
|
||||
header(10)
|
||||
fail_count = 0
|
||||
bad_bdev_id = random.randrange(999999999)
|
||||
if self.c.construct_lvol_store(bad_bdev_id, self.cluster_size) == 0:
|
||||
if self.c.construct_lvol_store(bad_bdev_id,
|
||||
self.lvs_name,
|
||||
self.cluster_size) == 0:
|
||||
fail_count += 1
|
||||
footer(10)
|
||||
return fail_count
|
||||
@ -243,10 +275,14 @@ class TestCases(object):
|
||||
header(11)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
if self.c.construct_lvol_store(base_name, self.cluster_size) == 0:
|
||||
if self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size) == 0:
|
||||
fail_count += 1
|
||||
self.c.destroy_lvol_store(uuid_store)
|
||||
self.c.delete_bdev(base_name)
|
||||
@ -256,7 +292,9 @@ class TestCases(object):
|
||||
def test_case12(self):
|
||||
header(12)
|
||||
fail_count = 0
|
||||
if self.c.construct_lvol_bdev(self._gen_lvs_uudi(), 32) == 0:
|
||||
if self.c.construct_lvol_bdev(self._gen_lvs_uudi(),
|
||||
self.lbd_name,
|
||||
32) == 0:
|
||||
fail_count += 1
|
||||
footer(12)
|
||||
return fail_count
|
||||
@ -265,13 +303,19 @@ class TestCases(object):
|
||||
header(13)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name,
|
||||
self.total_size - 1)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
|
||||
self.total_size - 1)
|
||||
if self.c.construct_lvol_bdev(uuid_store, self.total_size - 1) == 0:
|
||||
if self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name + "_1",
|
||||
self.total_size - 1) == 0:
|
||||
fail_count += 1
|
||||
|
||||
self.c.delete_bdev(uuid_bdev)
|
||||
@ -292,10 +336,14 @@ class TestCases(object):
|
||||
header(15)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
|
||||
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
|
||||
self.lbd_name,
|
||||
self.total_size - 1)
|
||||
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
|
||||
self.total_size - 1)
|
||||
if self.c.resize_lvol_bdev(uuid_bdev, self.total_size + 1) == 0:
|
||||
@ -319,7 +367,9 @@ class TestCases(object):
|
||||
header(17)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
|
||||
@ -346,7 +396,9 @@ class TestCases(object):
|
||||
header(20)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
self.c.delete_bdev(base_name)
|
||||
@ -360,6 +412,7 @@ class TestCases(object):
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
if self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
(self.total_size * 1024 * 1024) + 1) == 0:
|
||||
fail_count += 1
|
||||
footer(21)
|
||||
@ -370,7 +423,8 @@ class TestCases(object):
|
||||
fail_count = 0
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
if self.c.construct_lvol_store(base_name, 0) == 0:
|
||||
if self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name, 0) == 0:
|
||||
fail_count += 1
|
||||
footer(22)
|
||||
return fail_count
|
||||
@ -379,7 +433,9 @@ class TestCases(object):
|
||||
header(23)
|
||||
base_name = self.c.construct_malloc_bdev(self.total_size,
|
||||
self.block_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
|
||||
uuid_store = self.c.construct_lvol_store(base_name,
|
||||
self.lvs_name,
|
||||
self.cluster_size)
|
||||
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
|
||||
self.cluster_size)
|
||||
pid_path = path.join(self.path, 'vhost.pid')
|
||||
|
@ -47,7 +47,7 @@ lvol_bdevs=()
|
||||
# Create malloc backends and creat lvol store on each
|
||||
for i in `seq 1 $SUBSYS_NR`; do
|
||||
bdev="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
|
||||
ls_guid="$($rpc_py construct_lvol_store $bdev -c 1048576)"
|
||||
ls_guid="$($rpc_py construct_lvol_store $bdev lvs_$i -c 1048576)"
|
||||
lvol_stores+=("$ls_guid")
|
||||
|
||||
# 1 NVMe-OF subsystem per malloc bdev / lvol store / 10 lvol bdevs
|
||||
@ -55,9 +55,9 @@ for i in `seq 1 $SUBSYS_NR`; do
|
||||
|
||||
# Create lvol bdevs on each lvol store
|
||||
for j in `seq 1 10`; do
|
||||
lb_guid="$($rpc_py construct_lvol_bdev $ls_guid $LVOL_BDEV_SIZE)"
|
||||
lvol_bdevs+=("$lb_guid")
|
||||
ns_bdevs+="$lb_guid "
|
||||
lb_name="$($rpc_py construct_lvol_bdev -u $ls_guid lbd_$j $LVOL_BDEV_SIZE)"
|
||||
lvol_bdevs+=("$lb_name")
|
||||
ns_bdevs+="$lb_name "
|
||||
done
|
||||
$rpc_py construct_nvmf_subsystem nqn.2016-06.io.spdk:cnode$i "trtype:RDMA traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" '' -a -s SPDK$i -n "$ns_bdevs"
|
||||
done
|
||||
|
@ -431,7 +431,7 @@ _lvol_create(struct spdk_lvol_store *lvs)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_lvol_create(struct spdk_lvol_store *lvs, char *name, size_t sz,
|
||||
spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, size_t sz,
|
||||
spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_lvol *lvol;
|
||||
@ -478,7 +478,7 @@ ut_lvs_destroy(void)
|
||||
struct spdk_lvol_store *lvs;
|
||||
|
||||
/* Lvol store is succesfully created */
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -491,7 +491,7 @@ ut_lvs_destroy(void)
|
||||
|
||||
/* Suuccessfully create lvol, which should be unloaded with lvs later */
|
||||
g_lvolerrno = -1;
|
||||
rc = vbdev_lvol_create(lvs->uuid, sz, vbdev_lvol_create_complete, NULL);
|
||||
rc = vbdev_lvol_create(lvs->uuid, "lvol", sz, vbdev_lvol_create_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvolerrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
|
||||
@ -525,14 +525,14 @@ ut_lvol_init(void)
|
||||
|
||||
/* Incorrect uuid set */
|
||||
g_lvolerrno = 0;
|
||||
rc = vbdev_lvol_create(wrong_uuid, sz, vbdev_lvol_create_complete, NULL);
|
||||
rc = vbdev_lvol_create(wrong_uuid, "lvol", sz, vbdev_lvol_create_complete, NULL);
|
||||
CU_ASSERT(rc == -ENODEV);
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_spdk_lvol_pairs, g_lvs_bdev, lvol_stores);
|
||||
|
||||
/* Successful lvol create */
|
||||
g_lvolerrno = -1;
|
||||
rc = vbdev_lvol_create(g_lvs->uuid, sz, vbdev_lvol_create_complete, NULL);
|
||||
rc = vbdev_lvol_create(g_lvs->uuid, "lvol", sz, vbdev_lvol_create_complete, NULL);
|
||||
SPDK_CU_ASSERT_FATAL(rc == 0);
|
||||
CU_ASSERT(g_lvol != NULL);
|
||||
CU_ASSERT(g_lvolerrno == 0);
|
||||
@ -561,7 +561,7 @@ ut_lvol_hotremove(void)
|
||||
g_bs_dev = NULL;
|
||||
|
||||
/* Lvol store is succesfully created */
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
CU_ASSERT(g_lvol_store != NULL);
|
||||
@ -651,6 +651,7 @@ ut_lvol_examine(void)
|
||||
TAILQ_FIRST(&g_lvol_store->lvols)->ref_count--;
|
||||
bdev = TAILQ_FIRST(&g_lvol_store->lvols)->bdev;
|
||||
vbdev_lvs_destruct(g_lvol_store, lvol_store_op_complete, NULL);
|
||||
free(bdev->name);
|
||||
free(bdev);
|
||||
free(g_bs_dev);
|
||||
free(g_lvol_store);
|
||||
@ -681,7 +682,7 @@ ut_lvol_resize(void)
|
||||
|
||||
/* Successful lvol create */
|
||||
g_lvolerrno = -1;
|
||||
rc = vbdev_lvol_create(g_lvs->uuid, sz, vbdev_lvol_create_complete, NULL);
|
||||
rc = vbdev_lvol_create(g_lvs->uuid, "lvol", sz, vbdev_lvol_create_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvolerrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
|
||||
@ -726,7 +727,7 @@ ut_lvs_unload(void)
|
||||
struct spdk_lvol_store *lvs;
|
||||
|
||||
/* Lvol store is succesfully created */
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
@ -739,7 +740,7 @@ ut_lvs_unload(void)
|
||||
|
||||
/* Suuccessfully create lvol, which should be destroyed with lvs later */
|
||||
g_lvolerrno = -1;
|
||||
rc = vbdev_lvol_create(lvs->uuid, sz, vbdev_lvol_create_complete, NULL);
|
||||
rc = vbdev_lvol_create(lvs->uuid, "lvol", sz, vbdev_lvol_create_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvolerrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
|
||||
@ -761,7 +762,7 @@ ut_lvs_init(void)
|
||||
/* spdk_lvs_init() fails */
|
||||
lvol_store_initialize_fail = true;
|
||||
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc != 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
CU_ASSERT(g_lvol_store == NULL);
|
||||
@ -772,7 +773,7 @@ ut_lvs_init(void)
|
||||
/* spdk_lvs_init_cb() fails */
|
||||
lvol_store_initialize_cb_fail = true;
|
||||
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno != 0);
|
||||
CU_ASSERT(g_lvol_store == NULL);
|
||||
@ -781,7 +782,7 @@ ut_lvs_init(void)
|
||||
lvol_store_initialize_cb_fail = false;
|
||||
|
||||
/* Lvol store is succesfully created */
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
CU_ASSERT(g_lvol_store != NULL);
|
||||
@ -793,7 +794,7 @@ ut_lvs_init(void)
|
||||
g_bs_dev = NULL;
|
||||
|
||||
/* Bdev with lvol store already claimed */
|
||||
rc = vbdev_lvs_create(&g_bdev, 0, lvol_store_op_with_handle_complete, NULL);
|
||||
rc = vbdev_lvs_create(&g_bdev, "lvs", 0, lvol_store_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(rc != 0);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
CU_ASSERT(g_lvol_store == NULL);
|
||||
|
@ -120,7 +120,7 @@ used_vms=""
|
||||
# On each NVMe create one lvol store
|
||||
for (( i=0; i<$max_disks; i++ ));do
|
||||
echo "INFO: Creating lvol store on device Nvme${i}n1"
|
||||
ls_guid=$($rpc_py construct_lvol_store Nvme${i}n1)
|
||||
ls_guid=$($rpc_py construct_lvol_store Nvme${i}n1 lvs_$i)
|
||||
lvol_stores+=("$ls_guid")
|
||||
done
|
||||
|
||||
@ -129,11 +129,11 @@ if $nested_lvol; then
|
||||
for lvol_store in "${lvol_stores[@]}"; do
|
||||
|
||||
echo "INFO: Creating lvol bdev on lvol store $lvol_store"
|
||||
lb_guid=$($rpc_py construct_lvol_bdev $lvol_store 16000)
|
||||
lvol_bdevs+=("$lb_guid")
|
||||
lb_name=$($rpc_py construct_lvol_bdev -u $lvol_store lbd_nest 16000)
|
||||
lvol_bdevs+=("$lb_name")
|
||||
|
||||
echo "INFO: Creating nested lvol store on lvol bdev: $lb_guid"
|
||||
ls_guid=$($rpc_py construct_lvol_store $lb_guid)
|
||||
ls_guid=$($rpc_py construct_lvol_store $lb_guid lvs_n_$i)
|
||||
nest_lvol_stores+=("$ls_guid")
|
||||
done
|
||||
fi
|
||||
@ -143,15 +143,15 @@ for (( i=0; i<$vm_count; i++)); do
|
||||
bdevs=()
|
||||
echo "INFO: Creating lvol bdevs for VM $i"
|
||||
for lvol_store in "${lvol_stores[@]}"; do
|
||||
lb_guid=$($rpc_py construct_lvol_bdev $lvol_store 10000)
|
||||
lvol_bdevs+=("$lb_guid")
|
||||
bdevs+=("$lb_guid")
|
||||
lb_name=$($rpc_py construct_lvol_bdev -u $lvol_store lbd_$i 10000)
|
||||
lvol_bdevs+=("$lb_name")
|
||||
bdevs+=("$lb_name")
|
||||
done
|
||||
|
||||
if $nested_lvol; then
|
||||
echo "INFO: Creating nested lvol bdevs for VM $i"
|
||||
for lvol_store in "${nest_lvol_stores[@]}"; do
|
||||
lb_guid=$($rpc_py construct_lvol_bdev $lvol_store 2000)
|
||||
lb_guid=$($rpc_py construct_lvol_bdev -u $lvol_store lbd_nest_$i 2000)
|
||||
nest_lvol_bdevs+=("$lb_guid")
|
||||
bdevs+=("$lb_guid")
|
||||
done
|
||||
@ -266,7 +266,7 @@ done
|
||||
|
||||
echo "INFO: Removing nested lvol stores"
|
||||
for lvol_store in "${nest_lvol_stores[@]}"; do
|
||||
$rpc_py destroy_lvol_store $lvol_store
|
||||
$rpc_py destroy_lvol_store -u $lvol_store
|
||||
echo -e "\tINFO: nested lvol store $lvol_store removed"
|
||||
done
|
||||
|
||||
@ -278,7 +278,7 @@ done
|
||||
|
||||
echo "INFO: Removing lvol stores"
|
||||
for lvol_store in "${lvol_stores[@]}"; do
|
||||
$rpc_py destroy_lvol_store $lvol_store
|
||||
$rpc_py destroy_lvol_store -u $lvol_store
|
||||
echo -e "\tINFO: lvol store $lvol_store removed"
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user