nvme/perf: The -r parameter can now contain "ns:X"
Transport addresses can now additional contain an "ns" key whose value is a specific nsid to connect to. If unspecified, all namespaces will be used, which is the previous behavior. Change-Id: Icbebe32d68a1f97acaa1197c7fec5f119f33ec4d Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/421267 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
This commit is contained in:
parent
3bec66015e
commit
af4d1bdc60
@ -186,6 +186,7 @@ static const char *g_core_mask;
|
||||
|
||||
struct trid_entry {
|
||||
struct spdk_nvme_transport_id trid;
|
||||
uint16_t nsid;
|
||||
TAILQ_ENTRY(trid_entry) tailq;
|
||||
};
|
||||
|
||||
@ -320,7 +321,7 @@ set_latency_tracking_feature(struct spdk_nvme_ctrlr *ctrlr, bool enable)
|
||||
}
|
||||
|
||||
static void
|
||||
register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
|
||||
register_ctrlr(struct spdk_nvme_ctrlr *ctrlr, struct trid_entry *trid_entry)
|
||||
{
|
||||
struct spdk_nvme_ns *ns;
|
||||
struct ctrlr_entry *entry = malloc(sizeof(struct ctrlr_entry));
|
||||
@ -350,12 +351,22 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
|
||||
set_latency_tracking_feature(ctrlr, true);
|
||||
}
|
||||
|
||||
for (nsid = spdk_nvme_ctrlr_get_first_active_ns(ctrlr);
|
||||
nsid != 0; nsid = spdk_nvme_ctrlr_get_next_active_ns(ctrlr, nsid)) {
|
||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, nsid);
|
||||
if (ns == NULL) {
|
||||
continue;
|
||||
if (trid_entry->nsid == 0) {
|
||||
for (nsid = spdk_nvme_ctrlr_get_first_active_ns(ctrlr);
|
||||
nsid != 0; nsid = spdk_nvme_ctrlr_get_next_active_ns(ctrlr, nsid)) {
|
||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, nsid);
|
||||
if (ns == NULL) {
|
||||
continue;
|
||||
}
|
||||
register_ns(ctrlr, ns);
|
||||
}
|
||||
} else {
|
||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, trid_entry->nsid);
|
||||
if (!ns) {
|
||||
perror("Namespace does not exist.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
register_ns(ctrlr, ns);
|
||||
}
|
||||
|
||||
@ -1174,6 +1185,7 @@ add_trid(const char *trid_str)
|
||||
{
|
||||
struct trid_entry *trid_entry;
|
||||
struct spdk_nvme_transport_id *trid;
|
||||
char *ns;
|
||||
|
||||
trid_entry = calloc(1, sizeof(*trid_entry));
|
||||
if (trid_entry == NULL) {
|
||||
@ -1191,6 +1203,34 @@ add_trid(const char *trid_str)
|
||||
return 1;
|
||||
}
|
||||
|
||||
ns = strcasestr(trid_str, "ns:");
|
||||
if (ns) {
|
||||
char nsid_str[6]; /* 5 digits maximum in an nsid */
|
||||
int len;
|
||||
int nsid;
|
||||
|
||||
ns += 3;
|
||||
|
||||
len = strcspn(ns, " \t\n");
|
||||
if (len > 5) {
|
||||
fprintf(stderr, "NVMe namespace IDs must be 5 digits or less\n");
|
||||
free(trid_entry);
|
||||
return 1;
|
||||
}
|
||||
|
||||
memcpy(nsid_str, ns, len);
|
||||
nsid_str[len] = '\0';
|
||||
|
||||
nsid = atoi(nsid_str);
|
||||
if (nsid <= 0 || nsid > 65535) {
|
||||
fprintf(stderr, "NVMe namespace IDs must be less than 65536 and greater than 0\n");
|
||||
free(trid_entry);
|
||||
return 1;
|
||||
}
|
||||
|
||||
trid_entry->nsid = (uint16_t)nsid;
|
||||
}
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_trid_list, trid_entry, tailq);
|
||||
return 0;
|
||||
}
|
||||
@ -1462,6 +1502,7 @@ static void
|
||||
attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||
{
|
||||
struct trid_entry *trid_entry = cb_ctx;
|
||||
struct spdk_pci_addr pci_addr;
|
||||
struct spdk_pci_device *pci_dev;
|
||||
struct spdk_pci_id pci_id;
|
||||
@ -1488,7 +1529,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
pci_id.vendor_id, pci_id.device_id);
|
||||
}
|
||||
|
||||
register_ctrlr(ctrlr);
|
||||
register_ctrlr(ctrlr, trid_entry);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1499,7 +1540,7 @@ register_controllers(void)
|
||||
printf("Initializing NVMe Controllers\n");
|
||||
|
||||
TAILQ_FOREACH(trid_entry, &g_trid_list, tailq) {
|
||||
if (spdk_nvme_probe(&trid_entry->trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
if (spdk_nvme_probe(&trid_entry->trid, trid_entry, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed for transport address '%s'\n",
|
||||
trid_entry->trid.traddr);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user