]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/Grow: Update reshape_progress to need_back after reshape finishes
authorXiao Ni <xni@redhat.com>
Wed, 11 Sep 2024 08:54:24 +0000 (16:54 +0800)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 23 Sep 2024 08:48:11 +0000 (10:48 +0200)
It tries to update data offset when kicking off reshape. If it can't
change data offset, it needs to use child_monitor to monitor reshape
progress and do back up job. And it needs to update reshape_progress
to need_back when reshape finishes. If not, it will be in a infinite
loop.

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Grow.c

diff --git a/Grow.c b/Grow.c
index 533f301468af08f6a10fb67ea1ae29a6ef0f5f57..3b9f994200aaffdc5eb402d9bcea008f2ff5c4d4 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -4148,8 +4148,8 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
                 * waiting forever on a dead array
                 */
                char action[SYSFS_MAX_BUF_SIZE];
-               if (sysfs_get_str(info, NULL, "sync_action", action, sizeof(action)) <= 0 ||
-                   strncmp(action, "reshape", 7) != 0)
+
+               if (sysfs_get_str(info, NULL, "sync_action", action, sizeof(action)) <= 0)
                        break;
                /* Some kernels reset 'sync_completed' to zero
                 * before setting 'sync_action' to 'idle'.
@@ -4157,12 +4157,18 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
                 */
                if (completed == 0 && advancing &&
                    strncmp(action, "idle", 4) == 0 &&
-                   info->reshape_progress > 0)
+                   info->reshape_progress > 0) {
+                       info->reshape_progress = need_backup;
                        break;
+               }
                if (completed == 0 && !advancing &&
                    strncmp(action, "idle", 4) == 0 &&
                    info->reshape_progress <
-                   (info->component_size * reshape->after.data_disks))
+                   (info->component_size * reshape->after.data_disks)) {
+                       info->reshape_progress = need_backup;
+                       break;
+               }
+               if (strncmp(action, "reshape", 7) != 0)
                        break;
                sysfs_wait(fd, NULL);
                if (sysfs_fd_get_ll(fd, &completed) < 0)