[PATCH 8/9] ndctl: fix ndctl_region_get_interleave_ways(), set minimum

2017-01-09 Thread Dan Williams
A pmem region that does not have any associated dimm mappings is still a
x1 interleave width by definition. Given that tooling does division by
interleave-ways, return 1 as a minimum so that users do not need to
check for the zero case.

If a user instead wants to know the number of mapping entries that is
provided by ndctl_region_get_mappings().

Signed-off-by: Dan Williams 
---
 ndctl/lib/libndctl.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 49e35bf0fd98..c4a9b3675d89 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1676,7 +1676,7 @@ NDCTL_EXPORT unsigned int ndctl_region_get_id(struct 
ndctl_region *region)
 
 NDCTL_EXPORT unsigned int ndctl_region_get_interleave_ways(struct ndctl_region 
*region)
 {
-   return ndctl_region_get_mappings(region);
+   return max(1, ndctl_region_get_mappings(region));
 }
 
 NDCTL_EXPORT unsigned int ndctl_region_get_mappings(struct ndctl_region 
*region)

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH 6/9] daxctl: add daxctl to rpm spec

2017-01-09 Thread Dan Williams
Signed-off-by: Dan Williams 
---
 ndctl.spec.in |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ndctl.spec.in b/ndctl.spec.in
index 6453edd1954c..b4817622e0b2 100644
--- a/ndctl.spec.in
+++ b/ndctl.spec.in
@@ -114,9 +114,15 @@ make check
 %defattr(-,root,root)
 %license util/COPYING licenses/BSD-MIT licenses/CC0
 %{_bindir}/ndctl
-%{_mandir}/man1/*
+%{_mandir}/man1/ndctl*
 %{bashcompdir}/
 
+%files -n daxctl
+%defattr(-,root,root)
+%license util/COPYING licenses/BSD-MIT licenses/CC0
+%{_bindir}/daxctl
+%{_mandir}/man1/daxctl*
+
 %files -n LNAME
 %defattr(-,root,root)
 %doc README.md

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH 1/9] ndctl, create-namespace: skip idle regions when scanning for capacity

2017-01-09 Thread Dan Williams
Let validate_namespace_options() check that the region is enabled before
allowing namespace creation to proceed.

Signed-off-by: Dan Williams 
---
 ndctl/builtin-xaction-namespace.c |   17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/ndctl/builtin-xaction-namespace.c 
b/ndctl/builtin-xaction-namespace.c
index 2c4f85f5e4ac..66e61c531fa6 100644
--- a/ndctl/builtin-xaction-namespace.c
+++ b/ndctl/builtin-xaction-namespace.c
@@ -391,6 +391,12 @@ static int validate_namespace_options(struct ndctl_region 
*region,
 
memset(p, 0, sizeof(*p));
 
+   if (!ndctl_region_is_enabled(region)) {
+   debug("%s: disabled, skipping...\n",
+   ndctl_region_get_devname(region));
+   return -EAGAIN;
+   }
+
if (param.size)
p->size = parse_size64(param.size);
else if (ndns)
@@ -539,9 +545,11 @@ static int namespace_create(struct ndctl_region *region)
unsigned long long available;
struct ndctl_namespace *ndns;
struct parsed_parameters p;
+   int rc;
 
-   if (validate_namespace_options(region, NULL, ))
-   return -EINVAL;
+   rc = validate_namespace_options(region, NULL, );
+   if (rc)
+   return rc;
 
if (ndctl_region_get_ro(region)) {
debug("%s: read-only, inelligible for namespace creation\n",
@@ -685,8 +693,9 @@ static int namespace_reconfig(struct ndctl_region *region,
struct parsed_parameters p;
int rc;
 
-   if (validate_namespace_options(region, ndns, ))
-   return -EINVAL;
+   rc = validate_namespace_options(region, ndns, );
+   if (rc)
+   return rc;
 
rc = namespace_destroy(region, ndns);
if (rc)

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH 3/9] ndctl, create-namespace: improve failure message

2017-01-09 Thread Dan Williams
Distinguish failure to find suitable capacity with failures due to
missing capabilities in the kernel.

Signed-off-by: Dan Williams 
---
 ndctl/builtin-xaction-namespace.c |   20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/ndctl/builtin-xaction-namespace.c 
b/ndctl/builtin-xaction-namespace.c
index b0dd341db829..e260a87e9b1a 100644
--- a/ndctl/builtin-xaction-namespace.c
+++ b/ndctl/builtin-xaction-namespace.c
@@ -752,10 +752,8 @@ static int do_xaction_namespace(const char *namespace,
 
if (action == ACTION_CREATE && !namespace) {
rc = namespace_create(region);
-   if (rc == -EAGAIN) {
-   rc = 0;
+   if (rc == -EAGAIN)
continue;
-   }
if (rc == 0)
rc = 1;
return rc;
@@ -788,7 +786,8 @@ static int do_xaction_namespace(const char *namespace,
}
}
 
-   rc = success;
+   if (success)
+   return success;
return rc;
 }
 
@@ -853,8 +852,17 @@ int cmd_create_namespace(int argc, const char **argv, void 
*ctx)
}
 
if (created < 0 || (!namespace && created < 1)) {
-   fprintf(stderr, "failed to %s namespace\n", namespace
-   ? "reconfigure" : "create");
+   char *reason = "";
+
+   if (created == -EAGAIN)
+   reason = ": no suitable capacity found";
+   else if (created == -ENXIO)
+   reason = ": unsupported configuration";
+   else if (created == -EINVAL)
+   reason = ": invalid argument";
+
+   fprintf(stderr, "failed to %s namespace%s\n", namespace
+   ? "reconfigure" : "create", reason);
if (!namespace)
created = -ENODEV;
}

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH 5/9] daxctl, list: add man page

2017-01-09 Thread Dan Williams
Document the 'daxctl list' command which emits the details of the
Device-DAX regions and device instances in the system:

  # daxctl list -DRi
  {
"id":1,
"devices":[
  {
"chardev":"dax1.0",
"size":3233808384
  }
]
  }

Signed-off-by: Dan Williams 
---
 Documentation/Makefile.am |3 +-
 Documentation/daxctl-list.txt |   78 +
 2 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/daxctl-list.txt

diff --git a/Documentation/Makefile.am b/Documentation/Makefile.am
index adcc9e7dde8e..6daeb5621af0 100644
--- a/Documentation/Makefile.am
+++ b/Documentation/Makefile.am
@@ -12,7 +12,8 @@ man1_MANS = \
ndctl-disable-namespace.1 \
ndctl-create-namespace.1 \
ndctl-destroy-namespace.1 \
-   ndctl-list.1
+   ndctl-list.1 \
+   daxctl-list.1
 
 CLEANFILES = $(man1_MANS)
 
diff --git a/Documentation/daxctl-list.txt b/Documentation/daxctl-list.txt
new file mode 100644
index ..168d410d12d8
--- /dev/null
+++ b/Documentation/daxctl-list.txt
@@ -0,0 +1,78 @@
+daxctl-list(1)
+=
+
+NAME
+
+daxctl-list - dump the platform Device-DAX regions, devices, and
+attributes in json.
+
+SYNOPSIS
+
+[verse]
+'daxctl list' []
+
+Walk all the device-dax-regions in the system and list all device
+instances along with some of their major attributes.
+
+Options can be specified to limit the output to objects of a certain
+class.  Where the classes are regions or devices.  By default, 'daxctl
+list' with no options is equivalent to:
+[verse]
+daxctl list --devices
+
+EXAMPLE
+---
+[verse]
+# daxctl list --regions --devices
+
+["literal"]
+{
+  "id":1,
+  "devices":[
+{
+  "chardev":"dax1.0",
+  "size":3233808384
+}
+  ]
+}
+
+OPTIONS
+---
+-r::
+--region=::
+   A device-dax region is a contiguous range of memory that
+   hosts one or more /dev/daxX.Y devices, where X is the region id
+   and Y is the device instance id. The keyword 'all' can be
+   specified to carry out the operation on every region in the
+   system.
+
+-d::
+--dev=::
+   Specify a dax device name, .
+   tuple, or keyword 'all' to filter the listing. For
+   example to list the first device instance in region1:
+
+[verse]
+# daxctl list --dev=1.0
+
+["literal"]
+{
+  "chardev":"dax1.0",
+  "size":3233808384
+}
+
+-D::
+--devices::
+   Include device-dax instance info in the listing (default)
+
+-R::
+--regions::
+   Include region info in the listing
+
+-R::
+--regions::
+   Include region info in the listing
+
+-i::
+--idle::
+   Include idle (not enabled / zero-sized) devices in the listing

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH 2/9] ndctl, create-namespace: skip blk regions when scanning for memory or dax mode

2017-01-09 Thread Dan Williams
Treat blk regions as invalid capacity when the mode is a pmem-only mode
type.

Signed-off-by: Dan Williams 
---
 ndctl/builtin-xaction-namespace.c |   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/ndctl/builtin-xaction-namespace.c 
b/ndctl/builtin-xaction-namespace.c
index 66e61c531fa6..b0dd341db829 100644
--- a/ndctl/builtin-xaction-namespace.c
+++ b/ndctl/builtin-xaction-namespace.c
@@ -432,15 +432,14 @@ static int validate_namespace_options(struct ndctl_region 
*region,
else
p->mode = NDCTL_NS_MODE_RAW;
 
-   if (ndns && ndctl_namespace_get_type(ndns)
-   == ND_DEVICE_NAMESPACE_BLK
+   if (ndctl_region_get_type(region) != ND_DEVICE_REGION_PMEM
&& (p->mode == NDCTL_NS_MODE_MEMORY
|| p->mode == NDCTL_NS_MODE_DAX)) {
-   debug("%s: blk namespace do not support %s mode\n",
-   ndctl_namespace_get_devname(ndns),
+   debug("blk %s does not support %s mode\n",
+   ndctl_region_get_devname(region),
p->mode == NDCTL_NS_MODE_MEMORY
? "memory" : "dax");
-   return -EINVAL;
+   return -EAGAIN;
}
} else if (ndns)
p->mode = ndctl_namespace_get_mode(ndns);
@@ -518,10 +517,12 @@ static int validate_namespace_options(struct ndctl_region 
*region,
struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
 
if (!pfn && param.mode_default) {
-   debug("memory mode not available\n");
+   debug("%s memory mode not available\n",
+   ndctl_region_get_devname(region));
p->mode = NDCTL_NS_MODE_RAW;
} else if (!pfn) {
-   error("operation failed, memory mode not available\n");
+   error("operation failed, %s memory mode not 
available\n",
+   ndctl_region_get_devname(region));
return -EINVAL;
}
}
@@ -531,7 +532,8 @@ static int validate_namespace_options(struct ndctl_region 
*region,
struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
 
if (!dax) {
-   error("operation failed, dax mode not available\n");
+   error("operation failed, %s dax mode not available\n",
+   ndctl_region_get_devname(region));
return -EINVAL;
}
}

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates

2017-01-09 Thread Verma, Vishal L
On Mon, 2017-01-09 at 14:00 -0800, Dan Williams wrote:
> On Mon, Jan 9, 2017 at 1:56 PM, Vishal Verma  > wrote:
> > On 01/06, Dan Williams wrote:
> > > * The 'ndctl list' command awkwardly prints out all the
> > > corresponding
> > >   device-dax information when a namespace is in 'dax' mode.
> > > Conversely if
> > >   someone is only interested in listing device-dax information
> > > they need to
> > >   contend with libnvdimm data.
> > > 
> > >   Introduce a separate daxctl utility with its own 'list' command
> > > for this
> > >   purpose, and make the listing of device-dax data through 'ndctl
> > > list'
> > >   optional (new --device-dax option).
> > 
> > the 'rpmbuild' script was failing as the new daxctl utility wasn't
> > included in %files in the spec. The following patch fixes that.
> > 
> > 8<-
> > 
> > From d26a582b4ae9e69a22e52908a5d4bbae0a79717f Mon Sep 17 00:00:00
> > 2001
> > From: Vishal Verma 
> > Date: Mon, 9 Jan 2017 14:52:34 -0700
> > Subject: [PATCH] spec: add the new daxctl binary to the spec file
> > 
> > The missing binary was triggering the "installed but unpackaged file
> > found" check for rpmbuild. Add daxctl to the %files section as we do
> > want it to be packaged.
> 
> Yes, we do want it packaged, but in it's own rpm. I have patch to add
> that as well as a daxctl man page.

Ah ok - I thought it would just get installed as a part of the ndctl
rpm.
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates

2017-01-09 Thread Vishal Verma
On 01/06, Dan Williams wrote:
> * The 'ndctl list' command awkwardly prints out all the corresponding
>   device-dax information when a namespace is in 'dax' mode. Conversely if
>   someone is only interested in listing device-dax information they need to
>   contend with libnvdimm data.
> 
>   Introduce a separate daxctl utility with its own 'list' command for this
>   purpose, and make the listing of device-dax data through 'ndctl list'
>   optional (new --device-dax option).

the 'rpmbuild' script was failing as the new daxctl utility wasn't
included in %files in the spec. The following patch fixes that.

8<-

>From d26a582b4ae9e69a22e52908a5d4bbae0a79717f Mon Sep 17 00:00:00 2001
From: Vishal Verma 
Date: Mon, 9 Jan 2017 14:52:34 -0700
Subject: [PATCH] spec: add the new daxctl binary to the spec file

The missing binary was triggering the "installed but unpackaged file
found" check for rpmbuild. Add daxctl to the %files section as we do
want it to be packaged.

Signed-off-by: Vishal Verma 
---
 ndctl.spec.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ndctl.spec.in b/ndctl.spec.in
index 6453edd..4a22597 100644
--- a/ndctl.spec.in
+++ b/ndctl.spec.in
@@ -114,6 +114,7 @@ make check
 %defattr(-,root,root)
 %license util/COPYING licenses/BSD-MIT licenses/CC0
 %{_bindir}/ndctl
+%{_bindir}/daxctl
 %{_mandir}/man1/*
 %{bashcompdir}/
 
-- 
2.9.3


___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH 0/7] introduce 'daxctl list', and 'ndctl list' updates

2017-01-09 Thread Dan Williams
On Mon, Jan 9, 2017 at 1:56 PM, Vishal Verma  wrote:
> On 01/06, Dan Williams wrote:
>> * The 'ndctl list' command awkwardly prints out all the corresponding
>>   device-dax information when a namespace is in 'dax' mode. Conversely if
>>   someone is only interested in listing device-dax information they need to
>>   contend with libnvdimm data.
>>
>>   Introduce a separate daxctl utility with its own 'list' command for this
>>   purpose, and make the listing of device-dax data through 'ndctl list'
>>   optional (new --device-dax option).
>
> the 'rpmbuild' script was failing as the new daxctl utility wasn't
> included in %files in the spec. The following patch fixes that.
>
> 8<-
>
> From d26a582b4ae9e69a22e52908a5d4bbae0a79717f Mon Sep 17 00:00:00 2001
> From: Vishal Verma 
> Date: Mon, 9 Jan 2017 14:52:34 -0700
> Subject: [PATCH] spec: add the new daxctl binary to the spec file
>
> The missing binary was triggering the "installed but unpackaged file
> found" check for rpmbuild. Add daxctl to the %files section as we do
> want it to be packaged.

Yes, we do want it packaged, but in it's own rpm. I have patch to add
that as well as a daxctl man page.
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm