[PATCH] mdadm: stop using 'idle' for sysfs api "sync_action" to wake up sync_thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yu Kuai <yukuai3@xxxxxxxxxx>

Echo 'idle' to "sync_action" is supposed to stop sync_thread while new
sync_thread can still start. However, currently this behaviour is not
correct, echo 'idle' will actually try to stop sync_thread and then
start a new sync_thread. And mdadm relies on this wrong behaviour in
some places.

In kernel, if resync is not done yet, then recovery/reshape/check/repair
can't not start in the first place, and if resync is done, echo 'resync'
behaves the same as echo 'idle' for now.

Hence replace echo 'idle' with echo 'resync/reshape' when trying to
continue frozed sync_thread. There should be no functional changes and
prevent regressions after fixing that echo 'idle' will start new
sync_thread in kernel.

Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
 Grow.c   | 2 +-
 Manage.c | 8 ++++----
 msg.c    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Grow.c b/Grow.c
index 8fa97875..05498c6f 100644
--- a/Grow.c
+++ b/Grow.c
@@ -843,7 +843,7 @@ static void unfreeze(struct supertype *st)
 		if (sra &&
 		    sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
 		    strcmp(buf, "frozen\n") == 0)
-			sysfs_set_str(sra, NULL, "sync_action", "idle");
+			sysfs_set_str(sra, NULL, "sync_action", "reshape");
 		sysfs_free(sra);
 	}
 }
diff --git a/Manage.c b/Manage.c
index 91532266..91483112 100644
--- a/Manage.c
+++ b/Manage.c
@@ -344,7 +344,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
 			backwards = 1;
 		if (sysfs_get_ll(mdi, NULL, "reshape_position", &position) != 0) {
 			/* reshape must have finished now */
-			sysfs_set_str(mdi, NULL, "sync_action", "idle");
+			sysfs_set_str(mdi, NULL, "sync_action", "resync");
 			goto done;
 		}
 		sysfs_get_two(mdi, NULL, "chunk_size", &chunk1, &chunk2);
@@ -386,7 +386,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
 		 * the reshape monitor */
 		if (sync_max < old_sync_max)
 			sysfs_set_num(mdi, NULL, "sync_max", sync_max);
-		sysfs_set_str(mdi, NULL, "sync_action", "idle");
+		sysfs_set_str(mdi, NULL, "sync_action", "resync");
 
 		/* That should have set things going again.  Now we
 		 * wait a little while (3 second max) for sync_completed
@@ -1717,7 +1717,7 @@ int Manage_subdevs(char *devname, int fd,
 	}
 	free(tst);
 	if (frozen > 0)
-		sysfs_set_str(&info, NULL, "sync_action","idle");
+		sysfs_set_str(&info, NULL, "sync_action", "resync");
 	if (test && count == 0)
 		return 2;
 	return 0;
@@ -1725,7 +1725,7 @@ int Manage_subdevs(char *devname, int fd,
 abort:
 	free(tst);
 	if (frozen > 0)
-		sysfs_set_str(&info, NULL, "sync_action","idle");
+		sysfs_set_str(&info, NULL, "sync_action", "resync");
 	return !test && busy ? 2 : 1;
 }
 
diff --git a/msg.c b/msg.c
index 45cd4504..d9f08ebf 100644
--- a/msg.c
+++ b/msg.c
@@ -252,7 +252,7 @@ int unblock_subarray(struct mdinfo *sra, const int unfreeze)
 	    sysfs_set_str(sra, NULL, "metadata_version", buf) ||
 	    (unfreeze &&
 	     sysfs_attribute_available(sra, NULL, "sync_action") &&
-	     sysfs_set_str(sra, NULL, "sync_action", "idle")))
+	     sysfs_set_str(sra, NULL, "sync_action", "resync")))
 		rc = -1;
 	return rc;
 }
-- 
2.39.2





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux