Blame SOURCES/0015-libdaxctl-add-an-API-to-check-if-a-device-is-active.patch

2eb93d
From e563e6a7c55e65c554e07db6215f8bcb2d411d3b Mon Sep 17 00:00:00 2001
2eb93d
From: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
Date: Tue, 30 Mar 2021 20:50:37 -0600
2eb93d
Subject: [PATCH 015/217] libdaxctl: add an API to check if a device is active
2eb93d
2eb93d
Add an API to check whether a daxctl device is active in system-ram
2eb93d
mode. This would be used from libndctl during
2eb93d
ndctl_namespace_disable_safe(), so that we don't disable/destroy an
2eb93d
underlying namespace while the memory is active and online.
2eb93d
2eb93d
Reported-by: Chunye Xu <chunye.xu@intel.com>
2eb93d
Cc: Dan Williams <dan.j.williams@intel.com>
2eb93d
Cc: Dave Hansen <dave.hansen@linux.intel.com>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 daxctl/lib/libdaxctl.c   | 10 ++++++++++
2eb93d
 daxctl/lib/libdaxctl.sym |  1 +
2eb93d
 daxctl/libdaxctl.h       |  1 +
2eb93d
 3 files changed, 12 insertions(+)
2eb93d
2eb93d
diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
2eb93d
index 879f7e6..860bd9c 100644
2eb93d
--- a/daxctl/lib/libdaxctl.c
2eb93d
+++ b/daxctl/lib/libdaxctl.c
2eb93d
@@ -1665,3 +1665,13 @@ DAXCTL_EXPORT int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev)
2eb93d
 	/* match both "online" and "online_movable" */
2eb93d
 	return !strncmp(buf, "online", 6);
2eb93d
 }
2eb93d
+
2eb93d
+DAXCTL_EXPORT int daxctl_dev_has_online_memory(struct daxctl_dev *dev)
2eb93d
+{
2eb93d
+	struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
2eb93d
+
2eb93d
+	if (mem)
2eb93d
+		return daxctl_memory_is_online(mem);
2eb93d
+	else
2eb93d
+		return 0;
2eb93d
+}
2eb93d
diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym
2eb93d
index 892e393..a13e93d 100644
2eb93d
--- a/daxctl/lib/libdaxctl.sym
2eb93d
+++ b/daxctl/lib/libdaxctl.sym
2eb93d
@@ -95,4 +95,5 @@ global:
2eb93d
 LIBDAXCTL_9 {
2eb93d
 global:
2eb93d
 	daxctl_dev_will_auto_online_memory;
2eb93d
+	daxctl_dev_has_online_memory;
2eb93d
 } LIBDAXCTL_8;
2eb93d
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
2eb93d
index 30ab51a..683ae9c 100644
2eb93d
--- a/daxctl/libdaxctl.h
2eb93d
+++ b/daxctl/libdaxctl.h
2eb93d
@@ -72,6 +72,7 @@ int daxctl_dev_enable_devdax(struct daxctl_dev *dev);
2eb93d
 int daxctl_dev_enable_ram(struct daxctl_dev *dev);
2eb93d
 int daxctl_dev_get_target_node(struct daxctl_dev *dev);
2eb93d
 int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev);
2eb93d
+int daxctl_dev_has_online_memory(struct daxctl_dev *dev);
2eb93d
 
2eb93d
 struct daxctl_memory;
2eb93d
 struct daxctl_memory *daxctl_dev_get_memory(struct daxctl_dev *dev);
2eb93d
-- 
2eb93d
2.27.0
2eb93d