bdev/nvme: Check if ns can be shared when configuring multipath

We had not checked the bit 0 of the Namespace Multipath I/O and
Namespace Sharing Capabilities (NMIC) field in the Identify Namespace
data structure.

If the bit 0 of the NMIC is zero, it is likely that namespaces are not
identical.

We should check if the value of the NMIC first, and do it in this patch.

Additionally, it is not usual if the bit 0 of the CMIC and the bit 0 of
the NMIC do not match. So in unit tests rename the parameter multi_ctrlr
by multipath for ut_attach_ctrlr() and use it for the value of the NMIC.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I6aa7cbcc99be2507dbf18930f7b585a9ea7d0f90
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10380
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Shuhei Matsumoto 2021-11-24 10:40:25 +09:00 committed by Tomasz Zawadzki
parent 819fd52907
commit 7cc66c0ab1
2 changed files with 10 additions and 2 deletions

View File

@ -2604,6 +2604,13 @@ static int
nvme_bdev_add_ns(struct nvme_bdev *bdev, struct nvme_ns *nvme_ns)
{
struct nvme_ns *tmp_ns;
const struct spdk_nvme_ns_data *nsdata;
nsdata = spdk_nvme_ns_get_data(nvme_ns->ns);
if (!nsdata->nmic.can_share) {
SPDK_ERRLOG("Namespace cannot be shared.\n");
return -EINVAL;
}
pthread_mutex_lock(&bdev->mutex);

View File

@ -371,7 +371,7 @@ spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1,
static struct spdk_nvme_ctrlr *
ut_attach_ctrlr(const struct spdk_nvme_transport_id *trid, uint32_t num_ns,
bool ana_reporting, bool multi_ctrlr)
bool ana_reporting, bool multipath)
{
struct spdk_nvme_ctrlr *ctrlr;
uint32_t i;
@ -413,6 +413,7 @@ ut_attach_ctrlr(const struct spdk_nvme_transport_id *trid, uint32_t num_ns,
ctrlr->ns[i].is_active = true;
ctrlr->ns[i].ana_state = SPDK_NVME_ANA_OPTIMIZED_STATE;
ctrlr->nsdata[i].nsze = 1024;
ctrlr->nsdata[i].nmic.can_share = multipath;
}
ctrlr->cdata.nn = num_ns;
@ -420,7 +421,7 @@ ut_attach_ctrlr(const struct spdk_nvme_transport_id *trid, uint32_t num_ns,
}
ctrlr->cdata.cntlid = ++g_ut_cntlid;
ctrlr->cdata.cmic.multi_ctrlr = multi_ctrlr;
ctrlr->cdata.cmic.multi_ctrlr = multipath;
ctrlr->cdata.cmic.ana_reporting = ana_reporting;
ctrlr->trid = *trid;
TAILQ_INIT(&ctrlr->active_io_qpairs);