|
|
2eb93d |
From 8186ec87dcd1b347ab0ee27ec5e87bda8c9a67e2 Mon Sep 17 00:00:00 2001
|
|
|
2eb93d |
From: Dan Williams <dan.j.williams@intel.com>
|
|
|
2eb93d |
Date: Thu, 28 Apr 2022 16:54:48 -0700
|
|
|
2eb93d |
Subject: [PATCH 170/217] ndctl/dimm: Flush invalidated labels after overwrite
|
|
|
2eb93d |
|
|
|
2eb93d |
Similar to "ndctl write-labels", after "ndctl sanitize-dimm --overwrite"
|
|
|
2eb93d |
the kernel may contain a cached copy of the label area that has been
|
|
|
2eb93d |
invalidated by the overwrite. Toggle the enabled state of the dimm-device
|
|
|
2eb93d |
to trigger the kernel to release the cached copy.
|
|
|
2eb93d |
|
|
|
2eb93d |
Link: https://lore.kernel.org/all/165118817010.1772793.5101398830527716084.stgit@dwillia2-desk3.amr.corp.intel.com/
|
|
|
2eb93d |
Link: https://lore.kernel.org/r/165119008839.1783158.3766085644383173318.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
|
2eb93d |
Cc: Jeff Moyer <jmoyer@redhat.com>
|
|
|
2eb93d |
Cc: Dave Jiang <dave.jiang@intel.com>
|
|
|
2eb93d |
Acked-by: Jeff Moyer <jmoyer@redhat.com>
|
|
|
2eb93d |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
2eb93d |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
2eb93d |
---
|
|
|
2eb93d |
ndctl/dimm.c | 34 ++++++++++++++++++++++------------
|
|
|
2eb93d |
1 file changed, 22 insertions(+), 12 deletions(-)
|
|
|
2eb93d |
|
|
|
2eb93d |
diff --git a/ndctl/dimm.c b/ndctl/dimm.c
|
|
|
2eb93d |
index d9718a3..ac7c527 100644
|
|
|
2eb93d |
--- a/ndctl/dimm.c
|
|
|
2eb93d |
+++ b/ndctl/dimm.c
|
|
|
2eb93d |
@@ -354,6 +354,23 @@ static int rw_bin(FILE *f, struct ndctl_cmd *cmd, ssize_t size,
|
|
|
2eb93d |
return 0;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static int revalidate_labels(struct ndctl_dimm *dimm)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ int rc;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ /*
|
|
|
2eb93d |
+ * If the dimm is already disabled the kernel is not holding a cached
|
|
|
2eb93d |
+ * copy of the label space.
|
|
|
2eb93d |
+ */
|
|
|
2eb93d |
+ if (!ndctl_dimm_is_enabled(dimm))
|
|
|
2eb93d |
+ return 0;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ rc = ndctl_dimm_disable(dimm);
|
|
|
2eb93d |
+ if (rc)
|
|
|
2eb93d |
+ return rc;
|
|
|
2eb93d |
+ return ndctl_dimm_enable(dimm);
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static int action_write(struct ndctl_dimm *dimm, struct action_context *actx)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
struct ndctl_cmd *cmd_read, *cmd_write;
|
|
|
2eb93d |
@@ -377,18 +394,10 @@ static int action_write(struct ndctl_dimm *dimm, struct action_context *actx)
|
|
|
2eb93d |
|
|
|
2eb93d |
size = ndctl_cmd_cfg_read_get_size(cmd_read);
|
|
|
2eb93d |
rc = rw_bin(actx->f_in, cmd_write, size, param.offset, WRITE);
|
|
|
2eb93d |
-
|
|
|
2eb93d |
- /*
|
|
|
2eb93d |
- * If the dimm is already disabled the kernel is not holding a cached
|
|
|
2eb93d |
- * copy of the label space.
|
|
|
2eb93d |
- */
|
|
|
2eb93d |
- if (!ndctl_dimm_is_enabled(dimm))
|
|
|
2eb93d |
- goto out;
|
|
|
2eb93d |
-
|
|
|
2eb93d |
- rc = ndctl_dimm_disable(dimm);
|
|
|
2eb93d |
if (rc)
|
|
|
2eb93d |
goto out;
|
|
|
2eb93d |
- rc = ndctl_dimm_enable(dimm);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ rc = revalidate_labels(dimm);
|
|
|
2eb93d |
|
|
|
2eb93d |
out:
|
|
|
2eb93d |
ndctl_cmd_unref(cmd_read);
|
|
|
2eb93d |
@@ -1043,7 +1052,7 @@ static int action_security_freeze(struct ndctl_dimm *dimm,
|
|
|
2eb93d |
static int action_sanitize_dimm(struct ndctl_dimm *dimm,
|
|
|
2eb93d |
struct action_context *actx)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
- int rc;
|
|
|
2eb93d |
+ int rc = 0;
|
|
|
2eb93d |
enum ndctl_key_type key_type;
|
|
|
2eb93d |
|
|
|
2eb93d |
if (ndctl_dimm_get_security(dimm) < 0) {
|
|
|
2eb93d |
@@ -1085,9 +1094,10 @@ static int action_sanitize_dimm(struct ndctl_dimm *dimm,
|
|
|
2eb93d |
rc = ndctl_dimm_overwrite_key(dimm);
|
|
|
2eb93d |
if (rc < 0)
|
|
|
2eb93d |
return rc;
|
|
|
2eb93d |
+ rc = revalidate_labels(dimm);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
- return 0;
|
|
|
2eb93d |
+ return rc;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
static int action_wait_overwrite(struct ndctl_dimm *dimm,
|
|
|
2eb93d |
--
|
|
|
2eb93d |
2.27.0
|
|
|
2eb93d |
|