From: Dexuan Cui <dexuan.cui@gmail.com>
To: vishal.l.verma@intel.com, dan.j.williams@intel.com,
dave.jiang@intel.com, linux-nvdimm@lists.01.org,
mikelley@microsoft.com
Cc: qi.fuli@fujitsu.com
Subject: [ndctl PATCH v3 5/5] libndctl: Implement the "cmd_is_supported" dimm-op for Hyper-V
Date: Sat, 23 Mar 2019 04:26:37 +0000 [thread overview]
Message-ID: <20190323042637.4544-1-decui@microsoft.com> (raw)
Currently "ndctl monitor" fails for Hyper-V virtual NVDIMM due to
"no smart support".
According to http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"),
Hyper-V doesn't really support ND_CMD_SMART, but it supports
"Get Health Information (Function Index 1)" and
"Get Unsafe Shutdown Count (Function Index 2)", which is basically
a "weak" variant of ND_CMD_SMART.
Implement the dimm-ops to allow "ndctl monitor" to work with Hyper-V
NVDIMM. Now when an error happens, "ndctl monitor" can show such a
line:
{"timestamp":"1550547497.431731497","pid":1571,"event":
{"dimm-health-state":true},"dimm":{"dev":"nmem1",
"id":"04d5-01-1701-01000000","handle":1,"phys_id":0,
"health":{"health_state":"fatal","shutdown_count":8}}}
Here the meaningful info is:
"health":{"health_state":"fatal","shutdown_count":8}
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
ndctl/lib/hyperv.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/ndctl/lib/hyperv.c b/ndctl/lib/hyperv.c
index efd8b03..9b4fe12 100644
--- a/ndctl/lib/hyperv.c
+++ b/ndctl/lib/hyperv.c
@@ -9,6 +9,19 @@
#include "private.h"
#include "hyperv.h"
+static bool hyperv_cmd_is_supported(struct ndctl_dimm *dimm, int cmd)
+{
+ /*
+ * "ndctl monitor" requires ND_CMD_SMART, which is not really supported
+ * by Hyper-V virtual NVDIMM. Nevertheless, ND_CMD_SMART can be emulated
+ * by ND_HYPERV_CMD_GET_HEALTH_INFO and ND_HYPERV_CMD_GET_SHUTDOWN_INFO.
+ */
+ if (cmd == ND_CMD_SMART )
+ return true;
+
+ return !!(dimm->cmd_mask & (1ULL << cmd));
+}
+
static struct ndctl_cmd *alloc_hyperv_cmd(struct ndctl_dimm *dimm,
unsigned int command)
{
@@ -161,6 +174,7 @@ static int hyperv_cmd_xlat_firmware_status(struct ndctl_cmd *cmd)
}
struct ndctl_dimm_ops * const hyperv_dimm_ops = &(struct ndctl_dimm_ops) {
+ .cmd_is_supported = hyperv_cmd_is_supported,
.new_smart = hyperv_dimm_cmd_new_smart,
.smart_get_flags = hyperv_cmd_get_flags,
.smart_get_health = hyperv_cmd_get_health,
--
2.19.1
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
reply other threads:[~2019-03-23 4:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190323042637.4544-1-decui@microsoft.com \
--to=dexuan.cui@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-nvdimm@lists.01.org \
--cc=mikelley@microsoft.com \
--cc=qi.fuli@fujitsu.com \
--cc=vishal.l.verma@intel.com \
/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.