anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame SOURCES/0026-ndctl-scrub-Reread-scrub-engine-status-at-start.patch

e0018b
From 4e646fa490ba4b782afa188dd8818b94c419924e Mon Sep 17 00:00:00 2001
e0018b
From: Dan Williams <dan.j.williams@intel.com>
e0018b
Date: Wed, 26 May 2021 16:33:10 -0700
e0018b
Subject: [PATCH 026/217] ndctl/scrub: Reread scrub-engine status at start
e0018b
e0018b
Given that the kernel has exponential backoff to cover the lack of
e0018b
interrupts for scrub completion status there is a reasonable likelihood
e0018b
that 'ndctl start-scrub' is issued while the hardware/platform scrub-state
e0018b
is idle, but the kernel engine poll timer has not fired.
e0018b
e0018b
Trigger at least one poll cycle for the kernel to re-read the scrub-state
e0018b
before reporting that ARS is busy.
e0018b
e0018b
Link: https://lore.kernel.org/r/162207199057.3715490.2469820075085914776.stgit@dwillia2-desk3.amr.corp.intel.com
e0018b
Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.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/lib/libndctl.c | 12 +++++++++++-
e0018b
 1 file changed, 11 insertions(+), 1 deletion(-)
e0018b
e0018b
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
e0018b
index e5641fe..536e142 100644
e0018b
--- a/ndctl/lib/libndctl.c
e0018b
+++ b/ndctl/lib/libndctl.c
e0018b
@@ -1354,8 +1354,18 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus *bus,
e0018b
 NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
e0018b
 {
e0018b
 	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
e0018b
+	int rc;
e0018b
+
e0018b
+	rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
e0018b
 
e0018b
-	return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
e0018b
+	/*
e0018b
+	 * Try at least 1 poll cycle before reporting busy in case this
e0018b
+	 * request hits the kernel's exponential backoff while the
e0018b
+	 * hardware/platform scrub state is idle.
e0018b
+	 */
e0018b
+	if (rc == -EBUSY && ndctl_bus_poll_scrub_completion(bus, 1, 1) == 0)
e0018b
+		return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
e0018b
+	return rc;
e0018b
 }
e0018b
 
e0018b
 NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)
e0018b
-- 
e0018b
2.27.0
e0018b