From: Joao Martins <joao.m.martins@oracle.com>
To: linux-nvdimm@lists.01.org
Cc: Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCH ndctl v1 7/8] libdaxctl: add daxctl_dev_set_mapping()
Date: Thu, 16 Jul 2020 19:47:06 +0100 [thread overview]
Message-ID: <20200716184707.23018-8-joao.m.martins@oracle.com> (raw)
In-Reply-To: <20200716184707.23018-1-joao.m.martins@oracle.com>
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(+)
diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 506cf4b93236..3992ae733b16 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1121,6 +1121,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;
diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym
index 08362b683678..a4e16848494b 100644
--- a/daxctl/lib/libdaxctl.sym
+++ b/daxctl/lib/libdaxctl.sym
@@ -89,4 +89,5 @@ global:
daxctl_mapping_get_end;
daxctl_mapping_get_offset;
daxctl_mapping_get_size;
+ daxctl_dev_set_mapping;
} LIBDAXCTL_7;
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
index f94a72fed85b..09439c16d6df 100644
--- a/daxctl/libdaxctl.h
+++ b/daxctl/libdaxctl.h
@@ -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);
--
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
next prev parent reply other threads:[~2020-07-16 18:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 18:46 [PATCH ndctl v1 0/8] daxctl: Add device align and range mapping allocation Joao Martins
2020-07-16 18:47 ` [PATCH ndctl v1 1/8] daxctl: add daxctl_dev_{get,set}_align() Joao Martins
2020-07-16 18:47 ` [PATCH ndctl v1 2/8] util/json: Print device align Joao Martins
2020-07-16 18:47 ` [PATCH ndctl v1 3/8] daxctl: add align support in reconfigure-device Joao Martins
2020-07-16 18:47 ` [PATCH ndctl v1 4/8] daxctl: add align support in create-device Joao Martins
2020-07-16 18:47 ` [PATCH ndctl v1 5/8] libdaxctl: add mapping iterator APIs Joao Martins
2020-07-16 18:47 ` [PATCH ndctl v1 6/8] daxctl: include mappings when listing Joao Martins
2020-07-16 18:47 ` Joao Martins [this message]
2020-07-16 18:47 ` [PATCH ndctl v1 8/8] daxctl: Allow restore devices from JSON metadata Joao Martins
2020-12-16 11:39 ` [PATCH ndctl v1 0/8] daxctl: Add device align and range mapping allocation Joao Martins
2020-12-16 18:42 ` Verma, Vishal L
2020-12-16 21:49 ` Joao Martins
2020-12-16 22:31 ` Dan Williams
2020-12-16 22:53 ` Joao Martins
2020-12-16 23:42 ` Dan Williams
2020-12-17 11:23 ` Joao Martins
2020-12-17 20:18 ` Verma, Vishal L
2020-12-16 19:13 ` Dan Williams
2020-12-16 21:35 ` Joao Martins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200716184707.23018-8-joao.m.martins@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).