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