nvme/perf: create helper function to build names
These are the names displayed in the output. Some upcoming patches will modify these names, so making this a common function now will reduce the work later. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I11cb8f607a66523becdcf621d8d6c911aec4427d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456077 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
f0dd2b789e
commit
96f0e3f889
@ -626,6 +626,15 @@ static const struct ns_fn_table nvme_fn_table = {
|
||||
.cleanup_ns_worker_ctx = nvme_cleanup_ns_worker_ctx,
|
||||
};
|
||||
|
||||
static void
|
||||
build_nvme_name(char *name, size_t length, struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
const struct spdk_nvme_ctrlr_data *cdata;
|
||||
|
||||
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
||||
snprintf(name, length, "%-20.20s (%-20.20s)", cdata->mn, cdata->sn);
|
||||
}
|
||||
|
||||
static void
|
||||
register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
|
||||
{
|
||||
@ -709,7 +718,7 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
|
||||
g_max_io_size_blocks = entry->io_size_blocks;
|
||||
}
|
||||
|
||||
snprintf(entry->name, 44, "%-20.20s (%-20.20s)", cdata->mn, cdata->sn);
|
||||
build_nvme_name(entry->name, sizeof(entry->name), ctrlr);
|
||||
|
||||
g_num_namespaces++;
|
||||
entry->next = g_namespaces;
|
||||
@ -767,7 +776,6 @@ 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));
|
||||
const struct spdk_nvme_ctrlr_data *cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
||||
uint32_t nsid;
|
||||
|
||||
if (entry == NULL) {
|
||||
@ -782,7 +790,7 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr, struct trid_entry *trid_entry)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn);
|
||||
build_nvme_name(entry->name, sizeof(entry->name), ctrlr);
|
||||
|
||||
entry->ctrlr = ctrlr;
|
||||
entry->trtype = trid_entry->trid.trtype;
|
||||
|
Loading…
Reference in New Issue
Block a user