lvol: delete super blob in spdk_lvs_destroy

If we don't delete the super blob, this blob structure
will leak.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I56d0ca4884846aee0c7865f9c600d6c43811373c

Reviewed-on: https://review.gerrithub.io/383311
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
This commit is contained in:
Jim Harris 2017-10-20 15:22:11 -07:00 committed by Daniel Verkamp
parent 7d8fe2ca2c
commit 1efd9cfa2f
2 changed files with 26 additions and 5 deletions

View File

@ -62,6 +62,13 @@ struct spdk_lvs_with_handle_req {
struct spdk_bdev *base_bdev;
};
struct spdk_lvs_destroy_req {
spdk_lvs_op_complete cb_fn;
void *cb_arg;
struct spdk_lvol_store *lvs;
bool unmap_device;
};
struct spdk_lvol_with_handle_req {
spdk_lvol_op_with_handle_complete cb_fn;
void *cb_arg;

View File

@ -597,7 +597,7 @@ _spdk_lvs_destruct_cb(void *cb_arg, int lvserrno)
static void
_lvs_destroy_cb(void *cb_arg, int lvserrno)
{
struct spdk_lvs_req *lvs_req = cb_arg;
struct spdk_lvs_destroy_req *lvs_req = cb_arg;
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Lvol store destroyed\n");
assert(lvs_req->cb_fn != NULL);
@ -605,11 +605,24 @@ _lvs_destroy_cb(void *cb_arg, int lvserrno)
free(lvs_req);
}
static void
_lvs_destroy_super_cb(void *cb_arg, int bserrno)
{
struct spdk_lvs_destroy_req *lvs_req = cb_arg;
struct spdk_lvol_store *lvs = lvs_req->lvs;
assert(lvs != NULL);
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Destroying lvol store\n");
spdk_bs_destroy(lvs->blobstore, lvs_req->unmap_device, _lvs_destroy_cb, lvs_req);
_spdk_lvs_free(lvs);
}
int
spdk_lvs_destroy(struct spdk_lvol_store *lvs, bool unmap_device, spdk_lvs_op_complete cb_fn,
void *cb_arg)
{
struct spdk_lvs_req *lvs_req;
struct spdk_lvs_destroy_req *lvs_req;
struct spdk_lvol *iter_lvol, *tmp;
if (lvs == NULL) {
@ -637,10 +650,11 @@ spdk_lvs_destroy(struct spdk_lvol_store *lvs, bool unmap_device, spdk_lvs_op_com
lvs_req->cb_fn = cb_fn;
lvs_req->cb_arg = cb_arg;
lvs_req->lvs = lvs;
lvs_req->unmap_device = unmap_device;
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Destroying lvol store\n");
spdk_bs_destroy(lvs->blobstore, unmap_device, _lvs_destroy_cb, lvs_req);
_spdk_lvs_free(lvs);
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Deleting super blob\n");
spdk_bs_md_delete_blob(lvs->blobstore, lvs->super_blob_id, _lvs_destroy_super_cb, lvs_req);
return 0;
}