From af1c4f7ffb20322377b412f10e78b774b3f59ca6 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 28 Jan 2022 16:04:16 +0000 Subject: [PATCH] lvol: finish initial iteration even if blob has no name If we find a blob during the initial iteration during load that doesn't have a name, we cannot just immediately unload the blobstore, since the 'bad' blob is still open. Instead finish the iteration, and unload the blobstore (with failure status) after the iteration is complete. This is somewhat related to issue #1831. By ensuring we can unload the blobstore, it closes the open descriptor on the underlying bdev, which allows the bdev subsystem to exit on application shutdown. Signed-off-by: Jim Harris Change-Id: I7ecd189842704bb809f25c60efa8f81dcf8ca79c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11352 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Tomasz Zawadzki --- lib/lvol/lvol.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/lvol/lvol.c b/lib/lvol/lvol.c index 65a9eb568..21214b107 100644 --- a/lib/lvol/lvol.c +++ b/lib/lvol/lvol.c @@ -173,8 +173,17 @@ load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno) if (lvolerrno == -ENOENT) { /* Finished iterating */ - req->cb_fn(req->cb_arg, lvs, 0); - free(req); + if (req->lvserrno == 0) { + req->cb_fn(req->cb_arg, lvs, req->lvserrno); + free(req); + } else { + TAILQ_FOREACH_SAFE(lvol, &lvs->lvols, link, tmp) { + TAILQ_REMOVE(&lvs->lvols, lvol, link); + free(lvol); + } + lvs_free(lvs); + spdk_bs_unload(bs, bs_unload_with_error_cb, req); + } return; } else if (lvolerrno < 0) { SPDK_ERRLOG("Failed to fetch blobs list\n"); @@ -235,18 +244,8 @@ load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno) SPDK_INFOLOG(lvol, "added lvol %s (%s)\n", lvol->unique_id, lvol->uuid_str); - spdk_bs_iter_next(bs, blob, load_next_lvol, req); - - return; - invalid: - TAILQ_FOREACH_SAFE(lvol, &lvs->lvols, link, tmp) { - TAILQ_REMOVE(&lvs->lvols, lvol, link); - free(lvol); - } - - lvs_free(lvs); - spdk_bs_unload(bs, bs_unload_with_error_cb, req); + spdk_bs_iter_next(bs, blob, load_next_lvol, req); } static void