lvol: add lvol inflate function
Change-Id: Ib999d3f082f5d632cb1aaf089504d0cd48e77539 Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com> Reviewed-on: https://review.gerrithub.io/408696 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
64ccd4b95b
commit
6ce7a73912
@ -251,6 +251,15 @@ void spdk_lvs_load(struct spdk_bs_dev *bs_dev, spdk_lvs_op_with_handle_complete
|
|||||||
*/
|
*/
|
||||||
void spdk_lvol_open(struct spdk_lvol *lvol, spdk_lvol_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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inflate lvol
|
||||||
|
*
|
||||||
|
* \param lvol Handle to lvol
|
||||||
|
* \param cb_fn Completion callback
|
||||||
|
* \param cb_arg Completion callback custom arguments
|
||||||
|
*/
|
||||||
|
void spdk_lvol_inflate(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,6 +54,7 @@ struct spdk_lvol_req {
|
|||||||
void *cb_arg;
|
void *cb_arg;
|
||||||
struct spdk_lvol *lvol;
|
struct spdk_lvol *lvol;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
|
struct spdk_io_channel *channel;
|
||||||
char name[SPDK_LVOL_NAME_MAX];
|
char name[SPDK_LVOL_NAME_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1423,3 +1423,54 @@ spdk_lvol_get_io_channel(struct spdk_lvol *lvol)
|
|||||||
{
|
{
|
||||||
return spdk_bs_alloc_io_channel(lvol->lvol_store->blobstore);
|
return spdk_bs_alloc_io_channel(lvol->lvol_store->blobstore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_spdk_lvol_inflate_cb(void *cb_arg, int lvolerrno)
|
||||||
|
{
|
||||||
|
struct spdk_lvol_req *req = cb_arg;
|
||||||
|
|
||||||
|
spdk_bs_free_io_channel(req->channel);
|
||||||
|
|
||||||
|
if (lvolerrno < 0) {
|
||||||
|
SPDK_ERRLOG("Could not inflate lvol\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
req->cb_fn(req->cb_arg, lvolerrno);
|
||||||
|
free(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_lvol_inflate(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
|
||||||
|
{
|
||||||
|
struct spdk_lvol_req *req;
|
||||||
|
struct spdk_blob *blob = lvol->blob;
|
||||||
|
spdk_blob_id blob_id = spdk_blob_get_id(blob);
|
||||||
|
|
||||||
|
assert(cb_fn != NULL);
|
||||||
|
|
||||||
|
if (lvol == NULL) {
|
||||||
|
SPDK_ERRLOG("Lvol does not exist\n");
|
||||||
|
cb_fn(cb_arg, -ENODEV);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
req = calloc(1, sizeof(*req));
|
||||||
|
if (!req) {
|
||||||
|
SPDK_ERRLOG("Cannot alloc memory for lvol request pointer\n");
|
||||||
|
cb_fn(cb_arg, -ENOMEM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
req->cb_fn = cb_fn;
|
||||||
|
req->cb_arg = cb_arg;
|
||||||
|
req->channel = spdk_bs_alloc_io_channel(lvol->lvol_store->blobstore);
|
||||||
|
if (req->channel == NULL) {
|
||||||
|
SPDK_ERRLOG("Cannot alloc io channel for lvol inflate request\n");
|
||||||
|
free(req);
|
||||||
|
cb_fn(cb_arg, -ENOMEM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_bs_inflate_blob(lvol->lvol_store->blobstore, req->channel, blob_id, _spdk_lvol_inflate_cb,
|
||||||
|
req);
|
||||||
|
}
|
||||||
|
@ -73,10 +73,12 @@ int g_lvolerrno;
|
|||||||
int g_lvserrno;
|
int g_lvserrno;
|
||||||
int g_close_super_status;
|
int g_close_super_status;
|
||||||
int g_resize_rc;
|
int g_resize_rc;
|
||||||
|
int g_inflate_rc;
|
||||||
bool g_lvs_rename_blob_open_error = false;
|
bool g_lvs_rename_blob_open_error = false;
|
||||||
struct spdk_lvol_store *g_lvol_store;
|
struct spdk_lvol_store *g_lvol_store;
|
||||||
struct spdk_lvol *g_lvol;
|
struct spdk_lvol *g_lvol;
|
||||||
spdk_blob_id g_blobid = 1;
|
spdk_blob_id g_blobid = 1;
|
||||||
|
struct spdk_io_channel *g_io_channel;
|
||||||
|
|
||||||
struct spdk_blob_store {
|
struct spdk_blob_store {
|
||||||
struct spdk_bs_opts bs_opts;
|
struct spdk_bs_opts bs_opts;
|
||||||
@ -92,6 +94,12 @@ struct lvol_ut_bs_dev {
|
|||||||
struct spdk_blob_store *bs;
|
struct spdk_blob_store *bs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void spdk_bs_inflate_blob(struct spdk_blob_store *bs, struct spdk_io_channel *channel,
|
||||||
|
spdk_blob_id blobid, spdk_blob_op_complete cb_fn, void *cb_arg)
|
||||||
|
{
|
||||||
|
cb_fn(cb_arg, g_inflate_rc);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_bs_iter_next(struct spdk_blob_store *bs, struct spdk_blob *b,
|
spdk_bs_iter_next(struct spdk_blob_store *bs, struct spdk_blob *b,
|
||||||
spdk_blob_op_with_handle_complete cb_fn, void *cb_arg)
|
spdk_blob_op_with_handle_complete cb_fn, void *cb_arg)
|
||||||
@ -166,7 +174,22 @@ spdk_bs_load(struct spdk_bs_dev *dev, struct spdk_bs_opts *opts,
|
|||||||
|
|
||||||
struct spdk_io_channel *spdk_bs_alloc_io_channel(struct spdk_blob_store *bs)
|
struct spdk_io_channel *spdk_bs_alloc_io_channel(struct spdk_blob_store *bs)
|
||||||
{
|
{
|
||||||
return NULL;
|
if (g_io_channel == NULL) {
|
||||||
|
g_io_channel = calloc(1, sizeof(struct spdk_io_channel));
|
||||||
|
SPDK_CU_ASSERT_FATAL(g_io_channel != NULL);
|
||||||
|
}
|
||||||
|
g_io_channel->ref++;
|
||||||
|
return g_io_channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spdk_bs_free_io_channel(struct spdk_io_channel *channel)
|
||||||
|
{
|
||||||
|
g_io_channel->ref--;
|
||||||
|
if (g_io_channel->ref == 0) {
|
||||||
|
free(g_io_channel);
|
||||||
|
g_io_channel = NULL;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1924,6 +1947,59 @@ lvol_create_thin_provisioned(void)
|
|||||||
spdk_free_thread();
|
spdk_free_thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lvol_inflate(void)
|
||||||
|
{
|
||||||
|
struct lvol_ut_bs_dev dev;
|
||||||
|
struct spdk_lvs_opts opts;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
init_dev(&dev);
|
||||||
|
|
||||||
|
spdk_allocate_thread(_lvol_send_msg, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
spdk_lvs_opts_init(&opts);
|
||||||
|
snprintf(opts.name, sizeof(opts.name), "lvs");
|
||||||
|
|
||||||
|
g_lvserrno = -1;
|
||||||
|
rc = spdk_lvs_init(&dev.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);
|
||||||
|
|
||||||
|
spdk_lvol_create(g_lvol_store, "lvol", 10, false, lvol_op_with_handle_complete, NULL);
|
||||||
|
CU_ASSERT(g_lvserrno == 0);
|
||||||
|
SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
|
||||||
|
|
||||||
|
g_inflate_rc = -1;
|
||||||
|
spdk_lvol_inflate(g_lvol, lvol_op_complete, NULL);
|
||||||
|
CU_ASSERT(g_lvolerrno != 0);
|
||||||
|
|
||||||
|
g_inflate_rc = 0;
|
||||||
|
spdk_lvol_inflate(g_lvol, lvol_op_complete, NULL);
|
||||||
|
CU_ASSERT(g_lvolerrno == 0);
|
||||||
|
|
||||||
|
spdk_lvol_close(g_lvol, close_cb, NULL);
|
||||||
|
CU_ASSERT(g_lvserrno == 0);
|
||||||
|
spdk_lvol_destroy(g_lvol, destroy_cb, NULL);
|
||||||
|
CU_ASSERT(g_lvserrno == 0);
|
||||||
|
|
||||||
|
g_lvserrno = -1;
|
||||||
|
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL);
|
||||||
|
CU_ASSERT(rc == 0);
|
||||||
|
CU_ASSERT(g_lvserrno == 0);
|
||||||
|
g_lvol_store = NULL;
|
||||||
|
|
||||||
|
free_dev(&dev);
|
||||||
|
|
||||||
|
/* Make sure that all references to the io_channel was closed after
|
||||||
|
* inflate call
|
||||||
|
*/
|
||||||
|
CU_ASSERT(g_io_channel == NULL);
|
||||||
|
|
||||||
|
spdk_free_thread();
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
CU_pSuite suite = NULL;
|
CU_pSuite suite = NULL;
|
||||||
@ -1965,7 +2041,8 @@ int main(int argc, char **argv)
|
|||||||
CU_add_test(suite, "lvol_names", lvol_names) == NULL ||
|
CU_add_test(suite, "lvol_names", lvol_names) == NULL ||
|
||||||
CU_add_test(suite, "lvol_create_thin_provisioned", lvol_create_thin_provisioned) == NULL ||
|
CU_add_test(suite, "lvol_create_thin_provisioned", lvol_create_thin_provisioned) == NULL ||
|
||||||
CU_add_test(suite, "lvol_rename", lvol_rename) == NULL ||
|
CU_add_test(suite, "lvol_rename", lvol_rename) == NULL ||
|
||||||
CU_add_test(suite, "lvs_rename", lvs_rename) == NULL
|
CU_add_test(suite, "lvs_rename", lvs_rename) == NULL ||
|
||||||
|
CU_add_test(suite, "lvol_inflate", lvol_inflate) == NULL
|
||||||
) {
|
) {
|
||||||
CU_cleanup_registry();
|
CU_cleanup_registry();
|
||||||
return CU_get_error();
|
return CU_get_error();
|
||||||
|
Loading…
Reference in New Issue
Block a user