All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: <linux-nvdimm@lists.01.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Chunye Xu <chunye.xu@intel.com>
Subject: [ndctl PATCH 2/3] libdaxctl: add an API to check if a device is active
Date: Tue, 30 Mar 2021 21:12:28 -0600	[thread overview]
Message-ID: <20210331031229.384068-3-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20210331031229.384068-1-vishal.l.verma@intel.com>

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 <chunye.xu@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 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 -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  parent reply	other threads:[~2021-03-31  3:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31  3:12 [ndctl PATCH 0/3] daxctl-device fixes Vishal Verma
2021-03-31  3:12 ` [ndctl PATCH 1/3] daxctl: fail reconfigure-device based on kernel onlining policy Vishal Verma
2021-03-31  3:12 ` Vishal Verma [this message]
2021-03-31  3:12 ` [ndctl PATCH 3/3] libndctl: check for active system-ram before disabling daxctl devices Vishal Verma

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=20210331031229.384068-3-vishal.l.verma@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=chunye.xu@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.