[ndctl PATCH 2/3] libdaxctl: add an API to check if a device is active
Vishal Verma <[email protected]>
| Newsgroups | org.01.lists.linux-nvdimm,dev.linux.lists.nvdimm |
|---|---|
| Message-ID | <[email protected]> |
Add an API to check whether a daxctl device is active in system-ram mode. This would be used from libndctl during ndctl_namespace_disable_safe(), so that we don't disable/destroy an underlying namespace while the memory is active and online. Reported-by: Chunye Xu <[email protected]> Cc: Dan Williams <[email protected]> Cc: Dave Hansen <[email protected]> Signed-off-by: Vishal Verma <[email protected]> --- daxctl/lib/libdaxctl.c | 10 ++++++++++ daxctl/libdaxctl.h | 1 + daxctl/lib/libdaxctl.sym | 1 + 3 files changed, 12 insertions(+) diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c index 879f7e6..860bd9c 100644 --- a/daxctl/lib/libdaxctl.c +++ b/daxctl/lib/libdaxctl.c @@ -1665,3 +1665,13 @@ DAXCTL_EXPORT int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev) /* match both "online" and "online_movable" */ return !strncmp(buf, "online", 6); } + +DAXCTL_EXPORT int daxctl_dev_has_online_memory(struct daxctl_dev *dev) +{ + struct daxctl_memory *mem = daxctl_dev_get_memory(dev); + + if (mem) + return daxctl_memory_is_online(mem); + else + return 0; +} diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h index 30ab51a..683ae9c 100644 --- a/daxctl/libdaxctl.h +++ b/daxctl/libdaxctl.h @@ -72,6 +72,7 @@ int daxctl_dev_enable_devdax(struct daxctl_dev *dev); int daxctl_dev_enable_ram(struct daxctl_dev *dev); int daxctl_dev_get_target_node(struct daxctl_dev *dev); int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev); +int daxctl_dev_has_online_memory(struct daxctl_dev *dev); struct daxctl_memory; struct daxctl_memory *daxctl_dev_get_memory(struct daxctl_dev *dev); diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym index 892e393..a13e93d 100644 --- a/daxctl/lib/libdaxctl.sym +++ b/daxctl/lib/libdaxctl.sym @@ -95,4 +95,5 @@ global: LIBDAXCTL_9 { global: daxctl_dev_will_auto_online_memory; + daxctl_dev_has_online_memory; } LIBDAXCTL_8; -- 2.30.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]