Add an alignment option to reconfigure-device and use the newly added libdaxctl API to set the alignment of the device prior to setting size.
Signed-off-by: Joao Martins <[email protected]> --- daxctl/device.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/daxctl/device.c b/daxctl/device.c index 05293d6c38ee..9d82ea12aca2 100644 --- a/daxctl/device.c +++ b/daxctl/device.c @@ -22,6 +22,7 @@ static struct { const char *mode; const char *region; const char *size; + const char *align; bool no_online; bool no_movable; bool force; @@ -36,6 +37,7 @@ enum dev_mode { }; static enum dev_mode reconfig_mode = DAXCTL_DEV_MODE_UNKNOWN; +static long long align = -1; static long long size = -1; static unsigned long flags; @@ -68,7 +70,8 @@ OPT_BOOLEAN('f', "force", ¶m.force, \ "attempt to offline memory sections before reconfiguration") #define CREATE_OPTIONS() \ -OPT_STRING('s', "size", ¶m.size, "size", "size to switch the device to") +OPT_STRING('s', "size", ¶m.size, "size", "size to switch the device to"), \ +OPT_STRING('a', "align", ¶m.align, "align", "alignment to switch the device to") #define DESTROY_OPTIONS() \ OPT_BOOLEAN('f', "force", ¶m.force, \ @@ -185,8 +188,10 @@ static const char *parse_device_options(int argc, const char **argv, /* Handle action-specific options */ switch (action) { case ACTION_RECONFIG: - if (!param.size && !param.mode) { - fprintf(stderr, "error: a 'mode' or 'size' option is required\n"); + if (!param.size && + !param.align && + !param.mode) { + fprintf(stderr, "error: a 'align', 'mode' or 'size' option is required\n"); usage_with_options(u, reconfig_options); rc = -EINVAL; } @@ -204,6 +209,8 @@ static const char *parse_device_options(int argc, const char **argv, rc = -EINVAL; } } + if (param.align) + align = __parse_size64(param.align, &units); break; case ACTION_CREATE: if (param.size) @@ -558,6 +565,12 @@ static int do_reconfig(struct daxctl_dev *dev, enum dev_mode mode, struct json_object *jdev; int rc = 0; + if (align > 0) { + rc = daxctl_dev_set_align(dev, align); + if (rc < 0) + return rc; + } + if (size >= 0) { rc = dev_resize(dev, size); return rc; -- 1.8.3.1 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
