Commit e87e8263 authored by Maciej Szwed's avatar Maciej Szwed Committed by Jim Harris
Browse files

lvol: Fix for lvol failed deletion flow



lvol should not only be freed but also removed
from lvols list when deletion fails.

Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: I3a047e1cc611e71b1544ca77c256a879dd2efdae
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446619


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarPiotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 06ec27a5
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -902,14 +902,12 @@ _spdk_lvol_delete_blob_cb(void *cb_arg, int lvolerrno)
	struct spdk_lvol *lvol = req->lvol;

	if (lvolerrno < 0) {
		SPDK_ERRLOG("Could not delete blob on lvol\n");
		goto end;
		SPDK_ERRLOG("Could not remove blob on lvol gracefully - forced removal\n");
	} else {
		SPDK_INFOLOG(SPDK_LOG_LVOL, "Lvol %s deleted\n", lvol->unique_id);
	}

	TAILQ_REMOVE(&lvol->lvol_store->lvols, lvol, link);
	SPDK_INFOLOG(SPDK_LOG_LVOL, "Lvol %s deleted\n", lvol->unique_id);

end:
	_spdk_lvol_free(lvol);
	req->cb_fn(req->cb_arg, lvolerrno);
	free(req);
+16 −1
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ int g_lvserrno;
int g_close_super_status;
int g_resize_rc;
int g_inflate_rc;
int g_remove_rc;
bool g_lvs_rename_blob_open_error = false;
struct spdk_lvol_store *g_lvol_store;
struct spdk_lvol *g_lvol;
@@ -326,7 +327,7 @@ spdk_bs_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
		}
	}

	cb_fn(cb_arg, 0);
	cb_fn(cb_arg, g_remove_rc);
}

spdk_blob_id
@@ -859,6 +860,20 @@ lvol_destroy_fail(void)
	spdk_lvol_destroy(g_lvol, destroy_cb, NULL);
	CU_ASSERT(g_lvserrno == 0);

	spdk_lvol_create(g_lvol_store, "lvol", 10, false, LVOL_CLEAR_WITH_DEFAULT,
			 lvol_op_with_handle_complete, NULL);
	CU_ASSERT(g_lvserrno == 0);
	SPDK_CU_ASSERT_FATAL(g_lvol != NULL);

	spdk_lvol_close(g_lvol, close_cb, NULL);
	CU_ASSERT(g_lvserrno == 0);

	g_remove_rc = -1;
	spdk_lvol_destroy(g_lvol, destroy_cb, NULL);
	CU_ASSERT(g_lvserrno != 0);
	CU_ASSERT(TAILQ_EMPTY(&g_lvol_store->lvols));
	g_remove_rc = 0;

	g_lvserrno = -1;
	rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL);
	CU_ASSERT(rc == 0);