* [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix @ 2016-04-22 19:47 Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust Dan Williams ` (7 more replies) 0 siblings, 8 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm; +Cc: Marcin Ślusarz A collection of fixes for create-namespace operations mainly around properly generating default parameters. The destroy-namespace implementation was sent out previously, however the zero_info_block() enhancement deserved to be its own patch ("ndctl, create-namespace: make zero_info_block() more robust"). --- Dan Williams (7): ndctl, create-namespace: make zero_info_block() more robust ndctl: new 'destroy-namespace' utility ndctl, create-namespace: report failures due to namespace being mounted ndctl, xaction-namespace: make 'verbose' option available in all sub-commands ndctl, create-namespace: fix memmap location reconfiguration ndctl, create-namespace: fix sector mode default for pmem namespaces ndctl, create-namespace: check for ZONE_DEVICE=n kernels Marcin Ślusarz (1): ndctl: fix build on systems where /bin/sh is not a link to bash Documentation/Makefile.am | 1 Documentation/ndctl-destroy-namespace.txt | 32 ++++++++ Documentation/xable-namespace-options.txt | 4 + builtin-xaction-namespace.c | 121 +++++++++++++++++++++++------ builtin.h | 1 git-version | 2 ndctl.c | 3 - 7 files changed, 137 insertions(+), 27 deletions(-) create mode 100644 Documentation/ndctl-destroy-namespace.txt _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 2/8] ndctl: new 'destroy-namespace' utility Dan Williams ` (6 subsequent siblings) 7 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm Arrange for zero_info_block() to continue in the case when the namespace cannot be enabled. This allows a partially configured namespace to be reset. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- builtin-xaction-namespace.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index d83ad91a7258..3e13a1c0c3a1 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -463,12 +463,17 @@ static int zero_info_block(struct ndctl_namespace *ndns) char path[50]; void *buf; + ndctl_namespace_set_raw_mode(ndns, 1); + rc = ndctl_namespace_enable(ndns); + if (rc < 0) { + debug("%s failed to enable for zeroing, continuing\n", devname); + rc = 0; + goto out; + } + if (posix_memalign(&buf, 4096, 4096) != 0) return -ENXIO; - ndctl_namespace_set_raw_mode(ndns, 1); - ndctl_namespace_enable(ndns); - sprintf(path, "/dev/%s", ndctl_namespace_get_block_device(ndns)); fd = open(path, O_RDWR|O_DIRECT|O_EXCL); if (fd < 0) { _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [ndctl PATCH 2/8] ndctl: new 'destroy-namespace' utility 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 3/8] ndctl: fix build on systems where /bin/sh is not a link to bash Dan Williams ` (5 subsequent siblings) 7 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm Undo a create-namespace operation. Zero any info blocks, revoke all claims, and unallocate the region capacity. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- Documentation/Makefile.am | 1 Documentation/ndctl-destroy-namespace.txt | 27 ++++++++++ builtin-xaction-namespace.c | 79 ++++++++++++++++++++++------- builtin.h | 1 ndctl.c | 3 + 5 files changed, 92 insertions(+), 19 deletions(-) create mode 100644 Documentation/ndctl-destroy-namespace.txt diff --git a/Documentation/Makefile.am b/Documentation/Makefile.am index 7fb49b8e4538..470f5d003f6c 100644 --- a/Documentation/Makefile.am +++ b/Documentation/Makefile.am @@ -7,6 +7,7 @@ man1_MANS = \ ndctl-enable-namespace.1 \ ndctl-disable-namespace.1 \ ndctl-create-namespace.1 \ + ndctl-destroy-namespace.1 \ ndctl-list.1 CLEANFILES = $(man1_MANS) diff --git a/Documentation/ndctl-destroy-namespace.txt b/Documentation/ndctl-destroy-namespace.txt new file mode 100644 index 000000000000..623820533cec --- /dev/null +++ b/Documentation/ndctl-destroy-namespace.txt @@ -0,0 +1,27 @@ +ndctl-destroy-namespace(1) +========================= + +NAME +---- +ndctl-destroy-namespace - destroy the given namespace(s) + +SYNOPSIS +-------- +[verse] +'ndctl destroy-namespace' <namespace> [<options>] + +include::namespace-description.txt[] + +OPTIONS +------- +include::xable-namespace-options.txt[] +-f:: +--force:: + Unless this option is specified the 'destroy namespace' + operation will fail if the namespace is presently active. + Specifying --force causes the namespace to be disabled before + the operation is attempted. + +SEE ALSO +-------- +linkndctl:ndctl-create-namespace[1] diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index 3e13a1c0c3a1..53ff82bc2c8d 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -61,11 +61,11 @@ struct parsed_parameters { }; #define debug(fmt, ...) \ - if (verbose) { \ + ({if (verbose) { \ fprintf(stderr, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__); \ } else { \ do { } while (0); \ - } + }}) #define BASE_OPTIONS() \ OPT_STRING('b', "bus", ¶m.bus, "bus-id", \ @@ -98,6 +98,13 @@ static const struct option base_options[] = { OPT_END(), }; +static const struct option destroy_options[] = { + BASE_OPTIONS(), + OPT_BOOLEAN('f', "force", &force, + "destroy namespace even if currently active"), + OPT_END(), +}; + static const struct option create_options[] = { BASE_OPTIONS(), CREATE_OPTIONS(), @@ -108,9 +115,10 @@ enum namespace_action { ACTION_ENABLE, ACTION_DISABLE, ACTION_CREATE, + ACTION_DESTROY, }; -static int set_defaults(void) +static int set_defaults(enum namespace_action mode) { int rc = 0; @@ -124,7 +132,7 @@ static int set_defaults(void) param.type); rc = -EINVAL; } - } else if (!param.reconfig) + } else if (!param.reconfig && mode == ACTION_CREATE) param.type = "pmem"; if (param.mode) { @@ -140,7 +148,7 @@ static int set_defaults(void) error("invalid mode '%s'\n", param.mode); rc = -EINVAL; } - } else if (!param.reconfig) { + } else if (!param.reconfig && param.type) { if (strcmp(param.type, "pmem") == 0) param.mode = "memory"; else @@ -220,7 +228,7 @@ static const char *parse_namespace_options(int argc, const char **argv, param.do_scan = argc == 1; argc = parse_options(argc, argv, options, u, 0); - rc = set_defaults(); + rc = set_defaults(mode); if (argc == 0 && mode != ACTION_CREATE) { error("specify a namespace to %s, or \"all\"\n", @@ -498,20 +506,16 @@ static int zero_info_block(struct ndctl_namespace *ndns) return rc; } -static int namespace_reconfig(struct ndctl_region *region, +static int namespace_destroy(struct ndctl_region *region, struct ndctl_namespace *ndns) { const char *devname = ndctl_namespace_get_devname(ndns); struct ndctl_pfn *pfn = ndctl_namespace_get_pfn(ndns); struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns); - struct parsed_parameters p; const char *bdev = NULL; char path[50]; int fd, rc; - if (validate_namespace_options(ndns, &p)) - return -EINVAL; - if (ndctl_region_get_ro(region)) { error("%s: read-only, re-configuration disabled\n", devname); @@ -557,14 +561,29 @@ static int namespace_reconfig(struct ndctl_region *region, } rc = ndctl_namespace_delete(ndns); - if (rc) { - error("%s: failed to reclaim\n", devname); + if (rc) + debug("%s: failed to reclaim\n", devname); + + return 0; +} + +static int namespace_reconfig(struct ndctl_region *region, + struct ndctl_namespace *ndns) +{ + struct parsed_parameters p; + int rc; + + if (validate_namespace_options(ndns, &p)) + return -EINVAL; + + rc = namespace_destroy(region, ndns); + if (rc) return rc; - } ndns = ndctl_region_get_namespace_seed(region); if (is_namespace_active(ndns)) { - debug("%s: no %s namespace seed\n", devname, + debug("%s: no %s namespace seed\n", + ndctl_region_get_devname(region), ndns ? "idle" : "available"); return -ENODEV; } @@ -575,8 +594,8 @@ static int namespace_reconfig(struct ndctl_region *region, static int do_xaction_namespace(const char *namespace, enum namespace_action action) { + struct ndctl_namespace *ndns, *_n; int rc = -ENXIO, success = 0; - struct ndctl_namespace *ndns; struct ndctl_region *region; const char *ndns_name; struct ndctl_ctx *ctx; @@ -623,7 +642,7 @@ static int do_xaction_namespace(const char *namespace, rc = 1; goto done; } - ndctl_namespace_foreach(region, ndns) { + ndctl_namespace_foreach_safe(region, ndns, _n) { ndns_name = ndctl_namespace_get_devname(ndns); if (strcmp(namespace, "all") != 0 @@ -636,6 +655,9 @@ static int do_xaction_namespace(const char *namespace, case ACTION_ENABLE: rc = ndctl_namespace_enable(ndns); break; + case ACTION_DESTROY: + rc = namespace_destroy(region, ndns); + break; case ACTION_CREATE: rc = namespace_reconfig(region, ndns); if (rc < 0) @@ -711,7 +733,7 @@ int cmd_create_namespace(int argc, const char **argv) */ memset(¶m, 0, sizeof(param)); param.type = "blk"; - set_defaults(); + set_defaults(ACTION_CREATE); created = do_xaction_namespace(NULL, ACTION_CREATE); } @@ -726,3 +748,24 @@ int cmd_create_namespace(int argc, const char **argv) return created; return 0; } + +int cmd_destroy_namespace(int argc , const char **argv) +{ + char *xable_usage = "ndctl destroy-namespace <namespace> [<options>]"; + const char *namespace = parse_namespace_options(argc, argv, + ACTION_DESTROY, destroy_options, xable_usage); + int destroyed = do_xaction_namespace(namespace, ACTION_DESTROY); + + if (destroyed < 0) { + fprintf(stderr, "error destroying namespaces: %s\n", + strerror(-destroyed)); + return destroyed; + } else if (destroyed == 0) { + fprintf(stderr, "destroyed 0 namespaces\n"); + return 0; + } else { + fprintf(stderr, "destroyed %d namespace%s\n", destroyed, + destroyed > 1 ? "s" : ""); + return 0; + } +} diff --git a/builtin.h b/builtin.h index 9c207552b254..53ec25b8a76a 100644 --- a/builtin.h +++ b/builtin.h @@ -11,6 +11,7 @@ struct cmd_struct { int cmd_create_nfit(int argc, const char **argv); int cmd_enable_namespace(int argc, const char **argv); int cmd_create_namespace(int argc, const char **argv); +int cmd_destroy_namespace(int argc, const char **argv); int cmd_disable_namespace(int argc, const char **argv); int cmd_enable_region(int argc, const char **argv); int cmd_disable_region(int argc, const char **argv); diff --git a/ndctl.c b/ndctl.c index bed194979cc0..6db1b2ffa0c0 100644 --- a/ndctl.c +++ b/ndctl.c @@ -26,8 +26,9 @@ static struct cmd_struct commands[] = { { "version", cmd_version }, { "create-nfit", cmd_create_nfit }, { "enable-namespace", cmd_enable_namespace }, - { "create-namespace", cmd_create_namespace }, { "disable-namespace", cmd_disable_namespace }, + { "create-namespace", cmd_create_namespace }, + { "destroy-namespace", cmd_destroy_namespace }, { "enable-region", cmd_enable_region }, { "disable-region", cmd_disable_region }, { "zero-labels", cmd_zero_labels }, _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [ndctl PATCH 3/8] ndctl: fix build on systems where /bin/sh is not a link to bash 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 2/8] ndctl: new 'destroy-namespace' utility Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted Dan Williams ` (4 subsequent siblings) 7 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm; +Cc: Marcin Ślusarz From: Marcin Ślusarz <marcin.slusarz@intel.com> On Debian and Ubuntu autogen.sh fails because: ./git-version: 37: ./git-version: Bad substitution Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- git-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-version b/git-version index c78aff46023f..629f6d4a213d 100755 --- a/git-version +++ b/git-version @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash dirty() { git update-index -q --refresh _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams ` (2 preceding siblings ...) 2016-04-22 19:47 ` [ndctl PATCH 3/8] ndctl: fix build on systems where /bin/sh is not a link to bash Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 23:00 ` Linda Knippers 2016-04-22 19:47 ` [ndctl PATCH 5/8] ndctl, xaction-namespace: make 'verbose' option available in all sub-commands Dan Williams ` (3 subsequent siblings) 7 siblings, 1 reply; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm In the case when a filesystem is mounted on a namespace targeted for reconfiguration or destruction, emit a message so the user knows to unmount the filesystem. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- builtin-xaction-namespace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index 53ff82bc2c8d..e2e6d518c64d 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -550,6 +550,8 @@ static int namespace_destroy(struct ndctl_region *region, * stopping the !bdev case from racing to mount an fs or * re-enabling the namepace. */ + error("%s: %s is mounted, failing operation\n", + devname, bdev); return -EBUSY; } } _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted 2016-04-22 19:47 ` [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted Dan Williams @ 2016-04-22 23:00 ` Linda Knippers 2016-04-22 23:10 ` Dan Williams 0 siblings, 1 reply; 12+ messages in thread From: Linda Knippers @ 2016-04-22 23:00 UTC (permalink / raw) To: Dan Williams, linux-nvdimm On 4/22/2016 3:47 PM, Dan Williams wrote: > In the case when a filesystem is mounted on a namespace targeted for > reconfiguration or destruction, emit a message so the user knows to > unmount the filesystem. > > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > builtin-xaction-namespace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c > index 53ff82bc2c8d..e2e6d518c64d 100644 > --- a/builtin-xaction-namespace.c > +++ b/builtin-xaction-namespace.c > @@ -550,6 +550,8 @@ static int namespace_destroy(struct ndctl_region *region, > * stopping the !bdev case from racing to mount an fs or > * re-enabling the namepace. > */ > + error("%s: %s is mounted, failing operation\n", > + devname, bdev); I'm seeing this error message in cases where the device is not mounted, such as when I forget to run ndctl as root/sudo. That's a more likely reason that the open() may fail. Perhaps you could check the errno from the open() failure and display an error based on that? You might simply do a perror(). -- ljk > return -EBUSY; > } > } > > _______________________________________________ > 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] 12+ messages in thread
* Re: [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted 2016-04-22 23:00 ` Linda Knippers @ 2016-04-22 23:10 ` Dan Williams 0 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 23:10 UTC (permalink / raw) To: Linda Knippers; +Cc: linux-nvdimm On Fri, Apr 22, 2016 at 4:00 PM, Linda Knippers <linda.knippers@hpe.com> wrote: > On 4/22/2016 3:47 PM, Dan Williams wrote: >> In the case when a filesystem is mounted on a namespace targeted for >> reconfiguration or destruction, emit a message so the user knows to >> unmount the filesystem. >> >> Signed-off-by: Dan Williams <dan.j.williams@intel.com> >> --- >> builtin-xaction-namespace.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c >> index 53ff82bc2c8d..e2e6d518c64d 100644 >> --- a/builtin-xaction-namespace.c >> +++ b/builtin-xaction-namespace.c >> @@ -550,6 +550,8 @@ static int namespace_destroy(struct ndctl_region *region, >> * stopping the !bdev case from racing to mount an fs or >> * re-enabling the namepace. >> */ >> + error("%s: %s is mounted, failing operation\n", >> + devname, bdev); > > I'm seeing this error message in cases where the device is not mounted, > such as when I forget to run ndctl as root/sudo. That's a more > likely reason that the open() may fail. Perhaps you could check the > errno from the open() failure and display an error based on that? > You might simply do a perror(). > Ah, thanks Linda! Yes, checking for EACESS vs EBUSY should do the trick here. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ndctl PATCH 5/8] ndctl, xaction-namespace: make 'verbose' option available in all sub-commands 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams ` (3 preceding siblings ...) 2016-04-22 19:47 ` [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 6/8] ndctl, create-namespace: fix memmap location reconfiguration Dan Williams ` (2 subsequent siblings) 7 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm Rather than limiting the -v option to create-namespace, enable it for all xaction-namespace commands i.e. {enable, disable, create, destroy}-namespace. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- Documentation/ndctl-destroy-namespace.txt | 5 +++++ Documentation/xable-namespace-options.txt | 4 ++++ builtin-xaction-namespace.c | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/ndctl-destroy-namespace.txt b/Documentation/ndctl-destroy-namespace.txt index 623820533cec..ea6d2856107a 100644 --- a/Documentation/ndctl-destroy-namespace.txt +++ b/Documentation/ndctl-destroy-namespace.txt @@ -22,6 +22,11 @@ include::xable-namespace-options.txt[] Specifying --force causes the namespace to be disabled before the operation is attempted. +-v:: +--verbose:: + Emit debug messages for the namespace destruction operation + + SEE ALSO -------- linkndctl:ndctl-create-namespace[1] diff --git a/Documentation/xable-namespace-options.txt b/Documentation/xable-namespace-options.txt index a5c876180c91..cb24c2d61328 100644 --- a/Documentation/xable-namespace-options.txt +++ b/Documentation/xable-namespace-options.txt @@ -6,3 +6,7 @@ the operation on every namespace in the system, optionally filtered by region -r:: --region=:: include::xable-region-options.txt[] + +-v:: +--verbose:: + Emit debug messages for the namespace operation diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index e2e6d518c64d..23b38ad0b73b 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -71,7 +71,8 @@ struct parsed_parameters { OPT_STRING('b', "bus", ¶m.bus, "bus-id", \ "limit namespace to a bus with an id or provider of <bus-id>"), \ OPT_STRING('r', "region", ¶m.region, "region-id", \ - "limit namespace to a region with an id or name of <region-id>") + "limit namespace to a region with an id or name of <region-id>"), \ +OPT_BOOLEAN('v', "verbose", &verbose, "emit extra debug messages to stderr") #define CREATE_OPTIONS() \ OPT_STRING('e', "reconfig", ¶m.reconfig, "reconfig namespace", \ @@ -90,8 +91,7 @@ OPT_STRING('l', "sector-size", ¶m.sector_size, "lba-size", \ "specify the logical sector size in bytes"), \ OPT_STRING('t', "type", ¶m.type, "type", \ "specify the type of namespace to create 'pmem' or 'blk'"), \ -OPT_BOOLEAN('f', "force", &force, "reconfigure namespace even if currently active"), \ -OPT_BOOLEAN('v', "verbose", &verbose, "emit extra debug messages to stderr") +OPT_BOOLEAN('f', "force", &force, "reconfigure namespace even if currently active") static const struct option base_options[] = { BASE_OPTIONS(), _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [ndctl PATCH 6/8] ndctl, create-namespace: fix memmap location reconfiguration 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams ` (4 preceding siblings ...) 2016-04-22 19:47 ` [ndctl PATCH 5/8] ndctl, xaction-namespace: make 'verbose' option available in all sub-commands Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 8/8] ndctl, create-namespace: check for ZONE_DEVICE=n kernels Dan Williams 7 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm Fix segfault resulting from: ndctl create-namespace -M map -e namespace0.0 -f ...when 'memory' mode is implied by the source namespace. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- builtin-xaction-namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index 23b38ad0b73b..7d555a7d14a1 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -165,7 +165,8 @@ static int set_defaults(enum namespace_action mode) rc = -EINVAL; } - if (!param.reconfig && strcmp(param.mode, "memory") != 0) { + if (!param.reconfig && param.mode + && strcmp(param.mode, "memory") != 0) { error("--map only valid for a memory mode pmem namespace\n"); rc = -EINVAL; } _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams ` (5 preceding siblings ...) 2016-04-22 19:47 ` [ndctl PATCH 6/8] ndctl, create-namespace: fix memmap location reconfiguration Dan Williams @ 2016-04-22 19:47 ` Dan Williams 2016-04-22 23:07 ` Linda Knippers 2016-04-22 19:47 ` [ndctl PATCH 8/8] ndctl, create-namespace: check for ZONE_DEVICE=n kernels Dan Williams 7 siblings, 1 reply; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm The man page uses the following example for establishing a sector mode namespace: ndctl create-namespace -e namespace0.0 -f -m sector ...however this only works for blk-type namespaces to inherit a default sector size. Default to 4K in the pmem-type namespaces. Reported-by: Linda Knippers <linda.knippers@hpe.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- builtin-xaction-namespace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index 7d555a7d14a1..6ae8d7aee849 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -410,6 +410,8 @@ static int validate_namespace_options(struct ndctl_namespace *ndns, else if (ndctl_namespace_get_type(ndns) == ND_DEVICE_NAMESPACE_BLK) p->sector_size = ndctl_namespace_get_sector_size(ndns); + else if (p->mode == NDCTL_NS_MODE_SAFE) + p->sector_size = 4096; } if (param.map) { _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces 2016-04-22 19:47 ` [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces Dan Williams @ 2016-04-22 23:07 ` Linda Knippers 0 siblings, 0 replies; 12+ messages in thread From: Linda Knippers @ 2016-04-22 23:07 UTC (permalink / raw) To: Dan Williams, linux-nvdimm On 4/22/2016 3:47 PM, Dan Williams wrote: > The man page uses the following example for establishing a sector mode > namespace: > > ndctl create-namespace -e namespace0.0 -f -m sector > > ...however this only works for blk-type namespaces to inherit a default > sector size. Default to 4K in the pmem-type namespaces. > > Reported-by: Linda Knippers <linda.knippers@hpe.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> Thanks Dan. Tested-by: Linda Knippers <linda.knippers@hpe.com> > --- > builtin-xaction-namespace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c > index 7d555a7d14a1..6ae8d7aee849 100644 > --- a/builtin-xaction-namespace.c > +++ b/builtin-xaction-namespace.c > @@ -410,6 +410,8 @@ static int validate_namespace_options(struct ndctl_namespace *ndns, > else if (ndctl_namespace_get_type(ndns) > == ND_DEVICE_NAMESPACE_BLK) > p->sector_size = ndctl_namespace_get_sector_size(ndns); > + else if (p->mode == NDCTL_NS_MODE_SAFE) > + p->sector_size = 4096; > } > > if (param.map) { > _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ndctl PATCH 8/8] ndctl, create-namespace: check for ZONE_DEVICE=n kernels 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams ` (6 preceding siblings ...) 2016-04-22 19:47 ` [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces Dan Williams @ 2016-04-22 19:47 ` Dan Williams 7 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2016-04-22 19:47 UTC (permalink / raw) To: linux-nvdimm When a kernel does not support ZONE_DEVICE it is unable to support pfn-device configurations. Use the absence of a pfn-seed as the indicator of this configuration to fail the operation with an error rather than crashing. Reported-by: Linda Knippers <linda.knippers@hpe.com> Reported-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- builtin-xaction-namespace.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index 6ae8d7aee849..6ff969cd696e 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -38,6 +38,7 @@ static bool verbose; static bool force; static struct parameters { bool do_scan; + bool mode_default; const char *bus; const char *map; const char *type; @@ -153,6 +154,7 @@ static int set_defaults(enum namespace_action mode) param.mode = "memory"; else param.mode = "safe"; + param.mode_default = true; } if (param.map) { @@ -428,6 +430,22 @@ static int validate_namespace_options(struct ndctl_namespace *ndns, } else if (p->mode == NDCTL_NS_MODE_MEMORY) p->loc = NDCTL_PFN_LOC_PMEM; + /* check if we need, and whether the kernel supports, pfn devices */ + if (do_setup_pfn(ndns, p)) { + struct ndctl_region *region; + struct ndctl_pfn *pfn; + + region = ndctl_namespace_get_region(ndns); + pfn = ndctl_region_get_pfn_seed(region); + if (!pfn && param.mode_default) { + debug("memory mode not available\n"); + p->mode = NDCTL_NS_MODE_RAW; + } else if (!pfn) { + error("operation failed, memory mode not available\n"); + return -EINVAL; + } + } + return 0; } _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-04-22 23:10 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 2/8] ndctl: new 'destroy-namespace' utility Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 3/8] ndctl: fix build on systems where /bin/sh is not a link to bash Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted Dan Williams 2016-04-22 23:00 ` Linda Knippers 2016-04-22 23:10 ` Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 5/8] ndctl, xaction-namespace: make 'verbose' option available in all sub-commands Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 6/8] ndctl, create-namespace: fix memmap location reconfiguration Dan Williams 2016-04-22 19:47 ` [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces Dan Williams 2016-04-22 23:07 ` Linda Knippers 2016-04-22 19:47 ` [ndctl PATCH 8/8] ndctl, create-namespace: check for ZONE_DEVICE=n kernels Dan Williams
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.