anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

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

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