bdev/nvme: Inline nvme_bdev_ns_detach()

The nvme_ns->ref was added to nvme_bdev_ns to support both multipath
and OCSSD range. OCSSD range was to split a namespace into multiple
partitions.

However, OCSSD range was not used and removed to simplify multipath.

When namespace is not split, nvme_ns->ref is 2 at the maximum. First is
for populating namespace and second is for nvme_bdev. nvme_ns->populated
is for populating namespace and nvme_ns->bdev is for nvme_bdev.
Hence we can use nvme_ns->populated and nvme_ns->bdev directly instead of
nvme_ns->ref.

A few patches from this remove nvme_ns->ref and use nvme_ns->populated
and nvme_ns->bdev instead.

dThis patch inlines nvme_bdev_ns_detach() into the callers and remove it.

The following patches will adjust the locations to update nvme_ns->populated
and nvme_ns->bdev and then remove nvme_ns->ref.

Removing nvme_ns->ref will be helpful to associate multiple namespaces
into a single nvme_bdev for multipath.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I87581d39769681adc5e1fdf0b33680e31d958e47
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7095
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Shuhei Matsumoto 2021-03-29 23:46:57 +09:00 committed by Jim Harris
parent 2b8661d6ac
commit 8cc81fa07a
4 changed files with 24 additions and 11 deletions

View File

@ -318,7 +318,17 @@ bdev_nvme_destruct(void *ctx)
nvme_ns->bdev = NULL;
nvme_bdev_ns_detach(nvme_ns);
pthread_mutex_lock(&nvme_ns->ctrlr->mutex);
assert(nvme_ns->ref > 0);
nvme_ns->ref--;
if (nvme_ns->ref == 0) {
pthread_mutex_unlock(&nvme_ns->ctrlr->mutex);
nvme_bdev_ctrlr_destruct(nvme_ns->ctrlr);
} else {
pthread_mutex_unlock(&nvme_ns->ctrlr->mutex);
}
free(nvme_disk->disk.name);
free(nvme_disk);

View File

@ -216,7 +216,17 @@ bdev_ocssd_destruct(void *ctx)
nvme_ns->bdev = NULL;
nvme_bdev_ns_detach(nvme_ns);
pthread_mutex_lock(&nvme_ns->ctrlr->mutex);
assert(nvme_ns->ref > 0);
nvme_ns->ref--;
if (nvme_ns->ref == 0) {
pthread_mutex_unlock(&nvme_ns->ctrlr->mutex);
nvme_bdev_ctrlr_destruct(nvme_ns->ctrlr);
} else {
pthread_mutex_unlock(&nvme_ns->ctrlr->mutex);
}
bdev_ocssd_free_bdev(ocssd_bdev);

View File

@ -187,7 +187,7 @@ nvme_bdev_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
}
void
nvme_bdev_ns_detach(struct nvme_bdev_ns *nvme_ns)
nvme_ctrlr_depopulate_namespace_done(struct nvme_bdev_ns *nvme_ns)
{
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = nvme_ns->ctrlr;
@ -202,11 +202,5 @@ nvme_bdev_ns_detach(struct nvme_bdev_ns *nvme_ns)
}
pthread_mutex_unlock(&nvme_bdev_ctrlr->mutex);
nvme_bdev_ctrlr_destruct(nvme_ns->ctrlr);
}
void
nvme_ctrlr_depopulate_namespace_done(struct nvme_bdev_ns *nvme_ns)
{
nvme_bdev_ns_detach(nvme_ns);
nvme_bdev_ctrlr_destruct(nvme_bdev_ctrlr);
}

View File

@ -177,7 +177,6 @@ void nvme_bdev_dump_trid_json(const struct spdk_nvme_transport_id *trid,
void nvme_bdev_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr);
void nvme_bdev_ctrlr_do_destruct(void *ctx);
void nvme_bdev_ns_detach(struct nvme_bdev_ns *nvme_ns);
static inline bool
bdev_nvme_find_io_path(struct nvme_bdev *nbdev, struct nvme_io_channel *nvme_ch,