bdev/nvme: Restore the removed async callbacks for populating namespaces
For multipath, when an new nvme_ns is added to an existing nvme_bdev, we need to add the corresponding qpair to all existing nvme_bdev_channels dynamically. The RPC bdev_nvme_attach_controller has to return after that. Hence populating namespace needs to be asynchronous. On the other hand, when an nvme_ns is removed from an existing nvme_bdev, we need to remove the corresponding qpair from all existing nvme_bdev_channels dynamically. Hence depopulating namespace needs to be asynchronous. By the recent refactoring, two callbacks, nvme_ctrlr_populate_namespace_done() and nvme_ctrlr_depopulate_namespace_done() were removed accidentally. We need to restore these. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I37ea2420588cef3a18648dec053f8bd2b884e86b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9392 Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
edc95ba117
commit
fbbc8c4f81
@ -1928,6 +1928,29 @@ timeout_cb(void *cb_arg, struct spdk_nvme_ctrlr *ctrlr,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_ctrlr_populate_namespace_done(struct nvme_async_probe_ctx *ctx,
|
||||
struct nvme_ns *nvme_ns, int rc)
|
||||
{
|
||||
struct nvme_ctrlr *nvme_ctrlr = nvme_ns->ctrlr;
|
||||
|
||||
if (rc == 0) {
|
||||
pthread_mutex_lock(&nvme_ctrlr->mutex);
|
||||
nvme_ctrlr->ref++;
|
||||
pthread_mutex_unlock(&nvme_ctrlr->mutex);
|
||||
} else {
|
||||
nvme_ctrlr->namespaces[nvme_ns->id - 1] = NULL;
|
||||
free(nvme_ns);
|
||||
}
|
||||
|
||||
if (ctx) {
|
||||
ctx->populates_in_progress--;
|
||||
if (ctx->populates_in_progress == 0) {
|
||||
nvme_ctrlr_populate_namespaces_done(nvme_ctrlr, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_ctrlr_populate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *nvme_ns,
|
||||
struct nvme_async_probe_ctx *ctx)
|
||||
@ -1953,32 +1976,15 @@ nvme_ctrlr_populate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *nvm
|
||||
rc = nvme_bdev_create(nvme_ctrlr, nvme_ns);
|
||||
|
||||
done:
|
||||
if (rc == 0) {
|
||||
pthread_mutex_lock(&nvme_ctrlr->mutex);
|
||||
nvme_ctrlr->ref++;
|
||||
pthread_mutex_unlock(&nvme_ctrlr->mutex);
|
||||
} else {
|
||||
nvme_ctrlr->namespaces[nvme_ns->id - 1] = NULL;
|
||||
free(nvme_ns);
|
||||
}
|
||||
|
||||
if (ctx) {
|
||||
ctx->populates_in_progress--;
|
||||
if (ctx->populates_in_progress == 0) {
|
||||
nvme_ctrlr_populate_namespaces_done(nvme_ctrlr, ctx);
|
||||
}
|
||||
}
|
||||
nvme_ctrlr_populate_namespace_done(ctx, nvme_ns, rc);
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_ctrlr_depopulate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *nvme_ns)
|
||||
nvme_ctrlr_depopulate_namespace_done(struct nvme_ns *nvme_ns)
|
||||
{
|
||||
struct nvme_bdev *bdev;
|
||||
struct nvme_ctrlr *nvme_ctrlr = nvme_ns->ctrlr;
|
||||
|
||||
bdev = nvme_ns->bdev;
|
||||
if (bdev != NULL) {
|
||||
spdk_bdev_unregister(&bdev->disk, NULL, NULL);
|
||||
}
|
||||
assert(nvme_ctrlr != NULL);
|
||||
|
||||
pthread_mutex_lock(&nvme_ctrlr->mutex);
|
||||
|
||||
@ -1995,6 +2001,19 @@ nvme_ctrlr_depopulate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *n
|
||||
nvme_ctrlr_release(nvme_ctrlr);
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_ctrlr_depopulate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *nvme_ns)
|
||||
{
|
||||
struct nvme_bdev *bdev;
|
||||
|
||||
bdev = nvme_ns->bdev;
|
||||
if (bdev != NULL) {
|
||||
spdk_bdev_unregister(&bdev->disk, NULL, NULL);
|
||||
}
|
||||
|
||||
nvme_ctrlr_depopulate_namespace_done(nvme_ns);
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_ctrlr_populate_namespaces(struct nvme_ctrlr *nvme_ctrlr,
|
||||
struct nvme_async_probe_ctx *ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user