Skip to content

Commit

Permalink
blobstore: importing logical volumes asynchronously
Browse files Browse the repository at this point in the history
When importing an LVS, logical volumes are iterated and opened in a loop.
This can cause I/O requests to accumulate, and lead out-of-resource condition.
This fix iterates and open LVOLs asynchronously.

Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Feb 20, 2024
1 parent 8fddd8f commit 3bb3414
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions module/bdev/lvol/vbdev_lvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,12 +1735,35 @@ vbdev_lvs_examine_config(struct spdk_bdev *bdev)
spdk_bdev_module_examine_done(&g_lvol_if);
}

static void _vbdev_lvs_open_next_lvol(struct spdk_lvol *lvol, void *cb_arg);

static void
_vbdev_lvs_open_next_lvol_cb(void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
{
struct spdk_lvol *next_lvol = TAILQ_NEXT(lvol, link);

if (lvolerrno != 0) {
SPDK_ERRLOG("Failed to open lvol %s (blob 0x%" PRIx64 ")\n", lvol->name, lvol->blob_id);
}

_vbdev_lvs_examine_finish(cb_arg, lvol, lvolerrno);

if (next_lvol) {
_vbdev_lvs_open_next_lvol(next_lvol, cb_arg);
}
}

static void
_vbdev_lvs_open_next_lvol(struct spdk_lvol *lvol, void *cb_arg)
{
spdk_lvol_open(lvol, _vbdev_lvs_open_next_lvol_cb, cb_arg);
}

static void
_vbdev_lvs_examine_cb(void *arg, struct spdk_lvol_store *lvol_store, int lvserrno)
{
struct lvol_store_bdev *lvs_bdev;
struct spdk_lvs_with_handle_req *req = (struct spdk_lvs_with_handle_req *)arg;
struct spdk_lvol *lvol, *tmp;
struct spdk_lvs_req *ori_req = req->cb_arg;

if (lvserrno == -EEXIST) {
Expand Down Expand Up @@ -1790,9 +1813,7 @@ _vbdev_lvs_examine_cb(void *arg, struct spdk_lvol_store *lvol_store, int lvserrn
_vbdev_lvs_examine_done(ori_req, 0);
} else {
/* Open all lvols */
TAILQ_FOREACH_SAFE(lvol, &lvol_store->lvols, link, tmp) {
spdk_lvol_open(lvol, _vbdev_lvs_examine_finish, ori_req);
}
_vbdev_lvs_open_next_lvol(TAILQ_FIRST(&lvol_store->lvols), ori_req);
}

end:
Expand Down

0 comments on commit 3bb3414

Please sign in to comment.