* [ndctl PATCH] ndctl, create-namespace: fix minimum alignment detection
@ 2018-03-03 21:49 Dan Williams
2018-03-06 0:38 ` Verma, Vishal L
0 siblings, 1 reply; 2+ messages in thread
From: Dan Williams @ 2018-03-03 21:49 UTC (permalink / raw)
To: linux-nvdimm; +Cc: Maciej Ramotowski
Commit 0c31ce0a2875 "ndctl, create-namespace: fix --align= default..."
tried to make casual testing with nfit_test easier by auto-detecting the
alignment. However, this auto-detection always falls back to 4K
alignment on kernels that do not export the region 'resource' attribute.
Those kernels, like v4.9.4, may also be missing this fix: commit
cd755677d944 "libnvdimm, pfn: fix memmap reservation size versus 4K
alignment".
Given the chance to fail to initialize a namespace in the 4K case on
older kernels, be more conservative about falling back to 4K alignment.
Link: https://github.com/pmem/ndctl/issues/34
Reported-by: Maciej Ramotowski <maciej.ramotowski@intel.com>
Fixes: 0c31ce0a2875 ("ndctl, create-namespace: fix --align= default...")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
ndctl/namespace.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index ceb9e7a9b8af..aef356abbee1 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -462,7 +462,7 @@ static int validate_namespace_options(struct ndctl_region *region,
struct ndctl_namespace *ndns, struct parsed_parameters *p)
{
const char *region_name = ndctl_region_get_devname(region);
- unsigned long long size_align = SZ_4K, units = 1;
+ unsigned long long size_align = SZ_4K, units = 1, resource;
unsigned int ways;
int rc = 0;
@@ -563,8 +563,9 @@ static int validate_namespace_options(struct ndctl_region *region,
* the nfit_test use case where it is backed by vmalloc
* memory.
*/
- if (param.align_default && (ndctl_region_get_resource(region)
- & (SZ_2M - 1))) {
+ resource = ndctl_region_get_resource(region);
+ if (param.align_default && resource < ULLONG_MAX
+ && (resource & (SZ_2M - 1))) {
debug("%s: falling back to a 4K alignment\n",
region_name);
p->align = SZ_4K;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [ndctl PATCH] ndctl, create-namespace: fix minimum alignment detection
2018-03-03 21:49 [ndctl PATCH] ndctl, create-namespace: fix minimum alignment detection Dan Williams
@ 2018-03-06 0:38 ` Verma, Vishal L
0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2018-03-06 0:38 UTC (permalink / raw)
To: Williams, Dan J, linux-nvdimm; +Cc: Ramotowski, Maciej
On Sat, 2018-03-03 at 13:49 -0800, Dan Williams wrote:
> Commit 0c31ce0a2875 "ndctl, create-namespace: fix --align=
> default..."
> tried to make casual testing with nfit_test easier by auto-detecting
> the
> alignment. However, this auto-detection always falls back to 4K
> alignment on kernels that do not export the region 'resource'
> attribute.
> Those kernels, like v4.9.4, may also be missing this fix: commit
> cd755677d944 "libnvdimm, pfn: fix memmap reservation size versus 4K
> alignment".
>
> Given the chance to fail to initialize a namespace in the 4K case on
> older kernels, be more conservative about falling back to 4K
> alignment.
>
> Link: https://github.com/pmem/ndctl/issues/34
> Reported-by: Maciej Ramotowski <maciej.ramotowski@intel.com>
> Fixes: 0c31ce0a2875 ("ndctl, create-namespace: fix --align=
> default...")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> ndctl/namespace.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
Looks good, queued for v60.
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index ceb9e7a9b8af..aef356abbee1 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -462,7 +462,7 @@ static int validate_namespace_options(struct
> ndctl_region *region,
> struct ndctl_namespace *ndns, struct
> parsed_parameters *p)
> {
> const char *region_name = ndctl_region_get_devname(region);
> - unsigned long long size_align = SZ_4K, units = 1;
> + unsigned long long size_align = SZ_4K, units = 1, resource;
> unsigned int ways;
> int rc = 0;
>
> @@ -563,8 +563,9 @@ static int validate_namespace_options(struct
> ndctl_region *region,
> * the nfit_test use case where it is backed by
> vmalloc
> * memory.
> */
> - if (param.align_default &&
> (ndctl_region_get_resource(region)
> - & (SZ_2M - 1))) {
> + resource = ndctl_region_get_resource(region);
> + if (param.align_default && resource < ULLONG_MAX
> + && (resource & (SZ_2M - 1))) {
> debug("%s: falling back to a 4K
> alignment\n",
> region_name);
> p->align = SZ_4K;
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-06 0:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-03 21:49 [ndctl PATCH] ndctl, create-namespace: fix minimum alignment detection Dan Williams
2018-03-06 0:38 ` Verma, Vishal L
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.