nvme/fio_plugin: allow for not supplying a namespace.

This will open up the way for probing and connecting to
all of the namespaces on a pci controller.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I8fa3dde9f249ce826659882e66f630b8c25e2701
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2779
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Seth Howell 2020-06-04 10:20:35 -07:00 committed by Jim Harris
parent efc0fb1706
commit 8cad1a9d15

View File

@ -236,7 +236,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
long int tmp;
p = strstr(f->file_name, "ns=");
assert(p != NULL);
if (p != NULL) {
tmp = spdk_strtol(p + 3, 10);
if (tmp <= 0) {
SPDK_ERRLOG("namespace id should be >=1, but was invalid: %ld\n", tmp);
@ -244,6 +244,13 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
return;
}
ns_id = (uint32_t)tmp;
} else {
ns_id = spdk_nvme_ctrlr_get_first_active_ns(ctrlr);
if (ns_id == 0) {
/* The ctrlr has no active namespaces and we didn't specify any so nothing to do. */
return;
}
}
pthread_mutex_lock(&g_mutex);
fio_ctrlr = get_fio_ctrlr(trid);
@ -453,12 +460,12 @@ static int spdk_fio_setup(struct thread_data *td)
trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
p = strstr(f->file_name, " ns=");
if (p == NULL) {
SPDK_ERRLOG("Failed to find namespace 'ns=X'\n");
continue;
if (p != NULL) {
trid_info = strndup(f->file_name, p - f->file_name);
} else {
trid_info = strndup(f->file_name, strlen(f->file_name));
}
trid_info = strndup(f->file_name, p - f->file_name);
if (!trid_info) {
SPDK_ERRLOG("Failed to allocate space for trid_info\n");
continue;