From: Oliver O'Halloran <oohall@gmail.com>
To: linux-nvdimm@lists.01.org
Subject: [PATCH 4/4] ndctl/namespace: Validate alignment from the {pfn|dax} seed
Date: Mon, 19 Nov 2018 19:00:56 +1100 [thread overview]
Message-ID: <20181119080056.13386-4-oohall@gmail.com> (raw)
In-Reply-To: <20181119080056.13386-1-oohall@gmail.com>
This patch adds support to the ndctl tool for validating that the
namespace alignment is valid.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
ndctl/namespace.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 1e04f32c0e95..6f8dca288527 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -537,8 +537,18 @@ static int validate_namespace_options(struct ndctl_region *region,
}
if (param.align) {
- if (p->mode != NDCTL_NS_MODE_MEMORY &&
- p->mode != NDCTL_NS_MODE_DAX) {
+ int i, alignments;
+
+ switch (p->mode) {
+ case NDCTL_NS_MODE_MEMORY:
+ alignments = ndctl_pfn_get_num_alignments(pfn);
+ break;
+
+ case NDCTL_NS_MODE_DAX:
+ alignments = ndctl_dax_get_num_alignments(dax);
+ break;
+
+ default:
error("%s mode does not support setting an alignment\n",
p->mode == NDCTL_NS_MODE_SAFE
? "sector" : "raw");
@@ -546,13 +556,19 @@ static int validate_namespace_options(struct ndctl_region *region,
}
p->align = parse_size64(param.align);
+ for (i = 0; i < alignments; i++) {
+ uint64_t a;
- switch (p->align) {
- case SZ_4K:
- case SZ_2M:
- case SZ_1G:
- break;
- default:
+ if (p->mode == NDCTL_NS_MODE_MEMORY)
+ a = ndctl_pfn_get_supported_alignment(pfn, i);
+ else
+ a = ndctl_dax_get_supported_alignment(dax, i);
+
+ if (p->align == a)
+ break;
+ }
+
+ if (i >= alignments) {
error("unsupported align: %s\n", param.align);
return -ENXIO;
}
--
2.17.2
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-11-19 8:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 8:00 [PATCH 1/4] libndctl: Use the supported_alignment attribute Oliver O'Halloran
2018-11-19 8:00 ` [PATCH 2/4] ndctl/namespace: Check for seed namespaces earlier Oliver O'Halloran
2018-11-25 20:12 ` Dan Williams
2018-11-27 13:27 ` Oliver
2019-01-08 2:59 ` Dan Williams
2019-01-08 11:00 ` Oliver
2018-11-19 8:00 ` [PATCH 3/4] ndctl/namespace: Use seed alignment as the default Oliver O'Halloran
2018-11-25 20:14 ` Dan Williams
2018-11-19 8:00 ` Oliver O'Halloran [this message]
2018-11-25 20:18 ` [PATCH 4/4] ndctl/namespace: Validate alignment from the {pfn|dax} seed Dan Williams
2018-11-25 20:06 ` [PATCH 1/4] libndctl: Use the supported_alignment attribute 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=20181119080056.13386-4-oohall@gmail.com \
--to=oohall@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.