From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH v3 3/8] ndctl/dimm: Minimize data-transfer for init-labels
Date: Fri, 02 Aug 2019 16:54:39 -0700 [thread overview]
Message-ID: <156479007957.707590.14784171945389605864.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <156479006271.707590.298793474092813749.stgit@dwillia2-desk3.amr.corp.intel.com>
Currently init-labels implementation reads the entire namespace-label
capacity, initializes just the namespace index, and then writes the
entire label capacity. It turns out that DIMM label-area access methods
can be exceedingly slow.
For example, the time to read the entire label area on a single dimm:
2s, but the time to just read the index block space: 45ms.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/dimm.c | 2 +-
ndctl/lib/dimm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++---
ndctl/lib/libndctl.sym | 1 +
ndctl/libndctl.h | 1 +
4 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index db91f42421e4..d78e0dbc3ec6 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -982,7 +982,7 @@ static int __action_init(struct ndctl_dimm *dimm,
struct ndctl_cmd *cmd_read;
int rc;
- cmd_read = ndctl_dimm_read_labels(dimm);
+ cmd_read = ndctl_dimm_read_label_index(dimm);
if (!cmd_read)
return -ENXIO;
diff --git a/ndctl/lib/dimm.c b/ndctl/lib/dimm.c
index 22cf4e10b56c..9c5a34e542c3 100644
--- a/ndctl/lib/dimm.c
+++ b/ndctl/lib/dimm.c
@@ -370,14 +370,15 @@ static struct namespace_label *label_base(struct nvdimm_data *ndd)
return (struct namespace_label *) base;
}
-static void init_ndd(struct nvdimm_data *ndd, struct ndctl_cmd *cmd_read)
+static void init_ndd(struct nvdimm_data *ndd, struct ndctl_cmd *cmd_read,
+ struct ndctl_cmd *cmd_size)
{
ndctl_cmd_unref(ndd->cmd_read);
memset(ndd, 0, sizeof(*ndd));
ndd->cmd_read = cmd_read;
ndctl_cmd_ref(cmd_read);
ndd->data = cmd_read->iter.total_buf;
- ndd->config_size = cmd_read->iter.total_xfer;
+ ndd->config_size = cmd_size->get_size->config_size;
ndd->ns_current = -1;
ndd->ns_next = -1;
}
@@ -490,6 +491,52 @@ NDCTL_EXPORT int ndctl_dimm_validate_labels(struct ndctl_dimm *dimm)
return label_validate(&dimm->ndd);
}
+NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_read_label_index(struct ndctl_dimm *dimm)
+{
+ struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm);
+ struct ndctl_cmd *cmd_size, *cmd_read;
+ struct nvdimm_data *ndd = &dimm->ndd;
+ int rc;
+
+ rc = ndctl_bus_wait_probe(bus);
+ if (rc < 0)
+ return NULL;
+
+ cmd_size = ndctl_dimm_cmd_new_cfg_size(dimm);
+ if (!cmd_size)
+ return NULL;
+ rc = ndctl_cmd_submit_xlat(cmd_size);
+ if (rc < 0)
+ goto out_size;
+
+ cmd_read = ndctl_dimm_cmd_new_cfg_read(cmd_size);
+ if (!cmd_read)
+ goto out_size;
+ /*
+ * To calc the namespace index size use the minimum label
+ * size which corresponds to the maximum namespace index size.
+ */
+ init_ndd(ndd, cmd_read, cmd_size);
+ ndd->nslabel_size = 128;
+ rc = ndctl_cmd_cfg_read_set_extent(cmd_read,
+ sizeof_namespace_index(ndd) * 2, 0);
+ if (rc < 0)
+ goto out_size;
+
+ rc = ndctl_cmd_submit_xlat(cmd_read);
+ if (rc < 0)
+ goto out_read;
+ ndctl_cmd_unref(cmd_size);
+
+ return cmd_read;
+
+ out_read:
+ ndctl_cmd_unref(cmd_read);
+ out_size:
+ ndctl_cmd_unref(cmd_size);
+ return NULL;
+}
+
NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_read_labels(struct ndctl_dimm *dimm)
{
struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm);
@@ -515,7 +562,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_read_labels(struct ndctl_dimm *dimm)
goto out_read;
ndctl_cmd_unref(cmd_size);
- init_ndd(&dimm->ndd, cmd_read);
+ init_ndd(&dimm->ndd, cmd_read, cmd_size);
return cmd_read;
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 84359b97b793..648f83bced1b 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -415,4 +415,5 @@ global:
LIBNDCTL_21 {
ndctl_cmd_cfg_read_set_extent;
ndctl_cmd_cfg_write_set_extent;
+ ndctl_dimm_read_label_index;
} LIBNDCTL_20;
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
index 310814fe924c..8aa4b8bbe6c2 100644
--- a/ndctl/libndctl.h
+++ b/ndctl/libndctl.h
@@ -308,6 +308,7 @@ struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_read(struct ndctl_cmd *cfg_size);
struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_write(struct ndctl_cmd *cfg_read);
int ndctl_dimm_zero_labels(struct ndctl_dimm *dimm);
struct ndctl_cmd *ndctl_dimm_read_labels(struct ndctl_dimm *dimm);
+struct ndctl_cmd *ndctl_dimm_read_label_index(struct ndctl_dimm *dimm);
int ndctl_dimm_validate_labels(struct ndctl_dimm *dimm);
enum ndctl_namespace_version {
NDCTL_NS_VERSION_1_1,
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2019-08-03 0:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-02 23:54 [ndctl PATCH v3 0/8] Improvements for namespace creation/interrogation Dan Williams
2019-08-02 23:54 ` [ndctl PATCH v3 1/8] ndctl/build: Suppress -Waddress-of-packed-member Dan Williams
2019-08-05 16:54 ` Jeff Moyer
2019-08-05 17:34 ` Dan Williams
2019-08-05 17:45 ` Jeff Moyer
2019-08-05 19:50 ` Dan Williams
2019-08-02 23:54 ` [ndctl PATCH v3 2/8] ndctl/dimm: Support small label reads/writes Dan Williams
2019-08-02 23:54 ` Dan Williams [this message]
2019-08-02 23:54 ` [ndctl PATCH v3 4/8] ndctl/dimm: Add offset and size options to {read, write, zero}-labels Dan Williams
2019-08-02 23:54 ` [ndctl PATCH v3 5/8] ndctl/dimm: Limit read-labels with --index option Dan Williams
2019-08-02 23:54 ` [ndctl PATCH v3 6/8] ndctl/namespace: Minimize label data transfer for autolabel Dan Williams
2019-08-02 23:55 ` [ndctl PATCH v3 7/8] ndctl/namespace: Continue region search on 'missing seed' event Dan Williams
2019-08-02 23:55 ` [ndctl PATCH v3 8/8] ndctl/namespace: Report ENOSPC when regions are full Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=156479007957.707590.14784171945389605864.stgit@dwillia2-desk3.amr.corp.intel.com \
--to=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).