lvol: prevent unloading lvol store when lvols are open
Similar to blobstore unload, lib/lvol assumes that unloading lvol store is only possible after no lvols on it are open. Before spdk_lvs_unload() is possible, for each lvol on that lvol store spdk_lvol_close() or spdk_lvol_destroy() has to be called. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I86bae67ec322a61fdc0045d799854eecd1f36407 Reviewed-on: https://review.gerrithub.io/382252 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
5aecabfbd5
commit
df45eaecf7
@ -244,6 +244,11 @@ spdk_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!TAILQ_EMPTY(&lvs->lvols)) {
|
||||
SPDK_ERRLOG("Lvols still open on lvol store\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
lvs_req = calloc(1, sizeof(*lvs_req));
|
||||
if (!lvs_req) {
|
||||
SPDK_ERRLOG("Cannot alloc memory for lvol store request pointer\n");
|
||||
|
@ -129,8 +129,7 @@ spdk_lvs_init(struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o,
|
||||
}
|
||||
|
||||
int
|
||||
spdk_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn,
|
||||
void *cb_arg)
|
||||
spdk_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_lvol_store_req *req = cb_arg;
|
||||
|
||||
|
@ -225,6 +225,20 @@ lvs_init_unload_success(void)
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
|
||||
spdk_lvol_create(g_lvol_store, 10, lvol_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(g_lvserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
|
||||
|
||||
/* Lvol store has an open lvol, this unload should fail. */
|
||||
g_lvserrno = -1;
|
||||
rc = spdk_lvs_unload(g_lvol_store, NULL, NULL);
|
||||
CU_ASSERT(rc == -EBUSY);
|
||||
CU_ASSERT(g_lvserrno == -1);
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
|
||||
|
||||
/* Lvol has to be closed (or destroyed) before unloading lvol store. */
|
||||
spdk_lvol_close(g_lvol);
|
||||
|
||||
g_lvserrno = -1;
|
||||
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
Loading…
Reference in New Issue
Block a user