On Fri, 2019-07-26 at 19:52 -0600, Vishal Verma wrote:
> Add a new command 'daxctl-reconfigure-device'. This is used to switch
> the mode of a dax device between regular 'device_dax' and
> 'system-memory'. The command also uses the memory hotplug sysfs
> interfaces to online the newly available memory when converting to
> 'system-ram', and to attempt to offline the memory when converting back
> to a DAX device.
>
> Cc: Pavel Tatashin <[email protected]>
> Cc: Dave Hansen <[email protected]>
> Cc: Dan Williams <[email protected]>
> Signed-off-by: Vishal Verma <[email protected]>
> ---
> daxctl/Makefile.am | 2 +
> daxctl/builtin.h | 1 +
> daxctl/daxctl.c | 1 +
> daxctl/device.c | 503 +++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 507 insertions(+)
> create mode 100644 daxctl/device.c
>
> +static int verify_dax_bus_model(struct daxctl_dev *dev)
> +{
> + const char *devname = daxctl_dev_get_devname(dev);
> + char *dev_path, *subsys_path, *resolved;
> + struct stat sb;
> + int rc;
> +
> + if (asprintf(&dev_path, "/dev/%s", devname) < 0)
> + return -ENOMEM;
> +
> + rc = lstat(dev_path, &sb);
> + if (rc < 0) {
> + rc = -errno;
> + fprintf(stderr, "%s: stat for %s failed: %s\n",
> + devname, dev_path, strerror(-rc));
> + goto out_dev;;
> + }
> +
> + if (asprintf(&subsys_path, "/sys/dev/char/%d:%d/subsystem",
> + major(sb.st_rdev), minor(sb.st_rdev)) < 0) {
> + rc = -ENOMEM;
> + goto out_dev;
> + }
> +
> + resolved = realpath(subsys_path, NULL);
> + if (!resolved) {
> + rc = -errno;
> + fprintf(stderr, "%s: unable to determine subsys: %s\n",
> + devname, strerror(errno));
> + goto out_subsys;
> + }
> +
> + if (strcmp(resolved, "/sys/bus/dax") == 0)
> + rc = 0;
> + else
> + rc = -ENXIO;
> +
> + free(resolved);
> +out_subsys:
> + free(subsys_path);
> +out_dev:
> + free(dev_path);
> + return rc;
> +}
I suspect this check is screaming to be moved into the library, and be
invoked internally by the 'enable' and 'is_enabled' routines.
When in the dax-class model, a listing of the dax device will currently
show:
{
"chardev":"dax1.0",
"size":799063146496,
"target_node":3,
"mode":"devdax",
"state":"disabled"
}
Where the state: disabled is misleading.
I'll send a new version with this moved.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm