anitazha / rpms / ndctl

Forked from rpms/ndctl a year ago
Clone

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

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