@@ -1123,6 +1123,33 @@ DAXCTL_EXPORT int daxctl_dev_set_align(struct daxctl_dev *dev, unsigned long ali
return 0;
}
+DAXCTL_EXPORT int daxctl_dev_set_mapping(struct daxctl_dev *dev,
+ unsigned long long start,
+ unsigned long long end)
+{
+ struct daxctl_ctx *ctx = daxctl_dev_get_ctx(dev);
+ unsigned long long size = end - start + 1;
+ char buf[SYSFS_ATTR_SIZE];
+ char *path = dev->dev_buf;
+ int len = dev->buf_len;
+
+ if (snprintf(path, len, "%s/mapping", dev->dev_path) >= len) {
+ err(ctx, "%s: buffer too small!\n",
+ daxctl_dev_get_devname(dev));
+ return -ENXIO;
+ }
+
+ sprintf(buf, "%#llx-%#llx\n", start, end);
+ if (sysfs_write_attr(ctx, path, buf) < 0) {
+ err(ctx, "%s: failed to set mapping\n",
+ daxctl_dev_get_devname(dev));
+ return -ENXIO;
+ }
+ dev->size += size;
+
+ return 0;
+}
+
DAXCTL_EXPORT int daxctl_dev_get_target_node(struct daxctl_dev *dev)
{
return dev->target_node;
@@ -89,4 +89,5 @@ global:
daxctl_mapping_get_end;
daxctl_mapping_get_offset;
daxctl_mapping_get_size;
+ daxctl_dev_set_mapping;
} LIBDAXCTL_7;
@@ -73,6 +73,8 @@ unsigned long long daxctl_dev_get_size(struct daxctl_dev *dev);
int daxctl_dev_set_size(struct daxctl_dev *dev, unsigned long long size);
unsigned long daxctl_dev_get_align(struct daxctl_dev *dev);
int daxctl_dev_set_align(struct daxctl_dev *dev, unsigned long align);
+int daxctl_dev_set_mapping(struct daxctl_dev *dev, unsigned long long start,
+ unsigned long long end);
struct daxctl_ctx *daxctl_dev_get_ctx(struct daxctl_dev *dev);
int daxctl_dev_is_enabled(struct daxctl_dev *dev);
int daxctl_dev_disable(struct daxctl_dev *dev);
This API adds the ability to manually pick a range within the region device. Such routine allows for a admin to restore the mappings of a device after kexec. This is specially useful for hmem dynamic devdax which do not persistent ranges allocation through say a e.g. namespace label storage area. It also allows an userspace application to pick it's own ranges, should it want to avoid relying on kernel's policy. Signed-off-by: Joao Martins <joao.m.martins@oracle.com> --- daxctl/lib/libdaxctl.c | 27 +++++++++++++++++++++++++++ daxctl/lib/libdaxctl.sym | 1 + daxctl/libdaxctl.h | 2 ++ 3 files changed, 30 insertions(+)