dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/mdadm-3.4-IMSM-retry-reading-sync_completed-during-reshape.patch

7bdf8f
From df2647fa5bbe84960dae11531e34bafef549b8ff Mon Sep 17 00:00:00 2001
7bdf8f
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
7bdf8f
Date: Tue, 17 May 2016 13:24:41 +0200
7bdf8f
Subject: [PATCH] IMSM: retry reading sync_completed during reshape
7bdf8f
7bdf8f
The sync_completed after restarting a reshape
7bdf8f
(for example - after reboot) is set to "delayed" until
7bdf8f
mdmon changes the state. Mdadm does not wait for that change with
7bdf8f
old kernels. If this condition occurs - it exits and reshape
7bdf8f
is not continuing. This patch adds retry of reading sync_complete
7bdf8f
with a delay. It gives time for mdmon to change the "delayed" state.
7bdf8f
7bdf8f
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
7bdf8f
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7bdf8f
---
7bdf8f
 super-intel.c | 17 ++++++++++++-----
7bdf8f
 1 file changed, 12 insertions(+), 5 deletions(-)
7bdf8f
7bdf8f
diff --git a/super-intel.c b/super-intel.c
7bdf8f
index ba3ee48..7e2860c 100644
7bdf8f
--- a/super-intel.c
7bdf8f
+++ b/super-intel.c
7bdf8f
@@ -10378,6 +10378,7 @@ exit_imsm_reshape_super:
7bdf8f
 int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
7bdf8f
 {
7bdf8f
 	int fd = sysfs_get_fd(sra, NULL, "sync_completed");
7bdf8f
+	int retry = 3;
7bdf8f
 	unsigned long long completed;
7bdf8f
 	/* to_complete : new sync_max position */
7bdf8f
 	unsigned long long to_complete = sra->reshape_progress;
7bdf8f
@@ -10388,11 +10389,17 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
7bdf8f
 		return 1;
7bdf8f
 	}
7bdf8f
 
7bdf8f
-	if (sysfs_fd_get_ll(fd, &completed) < 0) {
7bdf8f
-		dprintf("cannot read reshape_position (no reshape in progres)\n");
7bdf8f
-		close(fd);
7bdf8f
-		return 1;
7bdf8f
-	}
7bdf8f
+	do {
7bdf8f
+		if (sysfs_fd_get_ll(fd, &completed) < 0) {
7bdf8f
+			if (!retry) {
7bdf8f
+				dprintf("cannot read reshape_position (no reshape in progres)\n");
7bdf8f
+				close(fd);
7bdf8f
+				return 1;
7bdf8f
+			}
7bdf8f
+			usleep(30000);
7bdf8f
+		} else
7bdf8f
+			break;
7bdf8f
+	} while (retry--);
7bdf8f
 
7bdf8f
 	if (completed > position_to_set) {
7bdf8f
 		dprintf("wrong next position to set %llu (%llu)\n",
7bdf8f
-- 
7bdf8f
2.5.5
7bdf8f