@@ -34,6 +34,7 @@ enum dev_mode {
};
static enum dev_mode reconfig_mode = DAXCTL_DEV_MODE_UNKNOWN;
+static long long size = -1;
static unsigned long flags;
enum memory_zone {
@@ -66,6 +67,7 @@ OPT_BOOLEAN('\0', "no-movable", ¶m.no_movable, \
static const struct option reconfig_options[] = {
BASE_OPTIONS(),
+ CREATE_OPTIONS(),
RECONFIG_OPTIONS(),
ZONE_OPTIONS(),
OPT_END(),
@@ -135,12 +137,14 @@ static const char *parse_device_options(int argc, const char **argv,
/* Handle action-specific options */
switch (action) {
case ACTION_RECONFIG:
- if (!param.mode) {
- fprintf(stderr, "error: a 'mode' option is required\n");
+ if (!param.size && !param.mode) {
+ fprintf(stderr, "error: a 'mode' or 'size' option is required\n");
usage_with_options(u, reconfig_options);
rc = -EINVAL;
}
- if (strcmp(param.mode, "system-ram") == 0) {
+ if (param.size) {
+ size = __parse_size64(param.size, &units);
+ } else if (strcmp(param.mode, "system-ram") == 0) {
reconfig_mode = DAXCTL_DEV_MODE_RAM;
if (param.no_movable)
mem_zone = MEM_ZONE_NORMAL;
@@ -309,6 +313,17 @@ static int dev_offline_memory(struct daxctl_dev *dev)
return 0;
}
+static int dev_resize(struct daxctl_dev *dev, unsigned long long val)
+{
+ int rc;
+
+ rc = daxctl_dev_set_size(dev, val);
+ if (rc < 0)
+ return rc;
+
+ return 0;
+}
+
static int disable_devdax_device(struct daxctl_dev *dev)
{
struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
@@ -418,6 +433,11 @@ static int do_reconfig(struct daxctl_dev *dev, enum dev_mode mode,
struct json_object *jdev;
int rc = 0;
+ if (size >= 0) {
+ rc = dev_resize(dev, size);
+ return rc;
+ }
+
switch (mode) {
case DAXCTL_DEV_MODE_RAM:
rc = reconfig_mode_system_ram(dev);