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

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