blobstore: do not allow for spdk_bs_unload if blobs are still open
It is possible that a user will call spdk_bs_unload() with blobs list not-empty. Instead of just asserting that, now the call fails with appropriate error. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I83818453d6c90ff9b5bf657c90e12b2f9d5ca013 Reviewed-on: https://review.gerrithub.io/383220 Reviewed-by: Paul Luse <paul.e.luse@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
fb99e9e644
commit
79745b8c8b
@ -2320,6 +2320,12 @@ spdk_bs_unload(struct spdk_blob_store *bs, spdk_bs_op_complete cb_fn, void *cb_a
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_TRACE_BLOB, "Syncing blobstore\n");
|
||||
|
||||
if (!TAILQ_EMPTY(&bs->blobs)) {
|
||||
SPDK_ERRLOG("Blobstore still has open blobs\n");
|
||||
cb_fn(cb_arg, -EBUSY);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
cb_fn(cb_arg, -ENOMEM);
|
||||
@ -2347,8 +2353,6 @@ spdk_bs_unload(struct spdk_blob_store *bs, spdk_bs_op_complete cb_fn, void *cb_a
|
||||
return;
|
||||
}
|
||||
|
||||
assert(TAILQ_EMPTY(&bs->blobs));
|
||||
|
||||
/* Read super block */
|
||||
spdk_bs_sequence_read(seq, ctx->super, _spdk_bs_page_to_lba(bs, 0),
|
||||
_spdk_bs_byte_to_lba(bs, sizeof(*ctx->super)),
|
||||
|
@ -1112,12 +1112,41 @@ static void
|
||||
bs_unload(void)
|
||||
{
|
||||
struct spdk_bs_dev *dev;
|
||||
struct spdk_blob_store *bs;
|
||||
spdk_blob_id blobid;
|
||||
struct spdk_blob *blob;
|
||||
|
||||
dev = init_dev();
|
||||
|
||||
spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_bs != NULL);
|
||||
bs = g_bs;
|
||||
|
||||
/* Create a blob and open it. */
|
||||
g_bserrno = -1;
|
||||
spdk_bs_md_create_blob(bs, blob_op_with_id_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
CU_ASSERT(g_blobid > 0);
|
||||
blobid = g_blobid;
|
||||
|
||||
g_bserrno = -1;
|
||||
spdk_bs_md_open_blob(bs, blobid, blob_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
CU_ASSERT(g_blob != NULL);
|
||||
blob = g_blob;
|
||||
|
||||
/* Try to unload blobstore, should fail with open blob */
|
||||
g_bserrno = -1;
|
||||
spdk_bs_unload(bs, bs_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == -EBUSY);
|
||||
SPDK_CU_ASSERT_FATAL(g_bs != NULL);
|
||||
|
||||
/* Close the blob, then successfully unload blobstore */
|
||||
g_bserrno = -1;
|
||||
spdk_bs_md_close_blob(&blob, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
CU_ASSERT(blob == NULL);
|
||||
|
||||
g_bserrno = -1;
|
||||
spdk_bs_unload(g_bs, bs_op_complete, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user