nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH 0/2] ndctl/scrub: Fix start-scrub vs exponential backoff
@ 2021-05-26 23:32 Dan Williams
  2021-05-26 23:33 ` [ndctl PATCH 1/2] ndctl/scrub: Stop translating return values Dan Williams
  2021-05-26 23:33 ` [ndctl PATCH 2/2] ndctl/scrub: Reread scrub-engine status at start Dan Williams
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Williams @ 2021-05-26 23:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: Krzysztof Rusocki, nvdimm

The initial scrub that Linux performs at boot may complete before the
next firing of the poll timer. Use the start-scrub event as a manual
polling event.

---

Dan Williams (2):
      ndctl/scrub: Stop translating return values
      ndctl/scrub: Reread scrub-engine status at start


 ndctl/lib/libndctl.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ndctl PATCH 1/2] ndctl/scrub: Stop translating return values
  2021-05-26 23:32 [ndctl PATCH 0/2] ndctl/scrub: Fix start-scrub vs exponential backoff Dan Williams
@ 2021-05-26 23:33 ` Dan Williams
  2021-05-26 23:33 ` [ndctl PATCH 2/2] ndctl/scrub: Reread scrub-engine status at start Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2021-05-26 23:33 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm

In preparation for triggering a poll loop within ndctl_bus_start_scrub(),
stop translating return values into -EOPNOTSUPP.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/libndctl.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index aa36a3c87c57..e5641feec23d 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1354,14 +1354,8 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus *bus,
 NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
 {
 	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
-	int rc;
 
-	rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
-	if (rc == -EBUSY)
-		return rc;
-	else if (rc < 0)
-		return -EOPNOTSUPP;
-	return 0;
+	return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
 }
 
 NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ndctl PATCH 2/2] ndctl/scrub: Reread scrub-engine status at start
  2021-05-26 23:32 [ndctl PATCH 0/2] ndctl/scrub: Fix start-scrub vs exponential backoff Dan Williams
  2021-05-26 23:33 ` [ndctl PATCH 1/2] ndctl/scrub: Stop translating return values Dan Williams
@ 2021-05-26 23:33 ` Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2021-05-26 23:33 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: Krzysztof Rusocki, nvdimm

Given that the kernel has exponential backoff to cover the lack of
interrupts for scrub completion status there is a reasonable likelihood
that 'ndctl start-scrub' is issued while the hardware/platform scrub-state
is idle, but the kernel engine poll timer has not fired.

Trigger at least one poll cycle for the kernel to re-read the scrub-state
before reporting that ARS is busy.

Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/libndctl.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index e5641feec23d..536e142cf6af 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1354,8 +1354,18 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus *bus,
 NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
 {
 	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
+	int rc;
+
+	rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
 
-	return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
+	/*
+	 * Try at least 1 poll cycle before reporting busy in case this
+	 * request hits the kernel's exponential backoff while the
+	 * hardware/platform scrub state is idle.
+	 */
+	if (rc == -EBUSY && ndctl_bus_poll_scrub_completion(bus, 1, 1) == 0)
+		return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
+	return rc;
 }
 
 NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26 23:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 23:32 [ndctl PATCH 0/2] ndctl/scrub: Fix start-scrub vs exponential backoff Dan Williams
2021-05-26 23:33 ` [ndctl PATCH 1/2] ndctl/scrub: Stop translating return values Dan Williams
2021-05-26 23:33 ` [ndctl PATCH 2/2] ndctl/scrub: Reread scrub-engine status at start Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).