]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/Manage: record errno
authorXiao Ni <xni@redhat.com>
Wed, 11 Sep 2024 08:54:32 +0000 (16:54 +0800)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 23 Sep 2024 08:49:17 +0000 (10:49 +0200)
Sometimes it reports:
mdadm: failed to stop array /dev/md0: Success
It's the reason the errno is reset. So record errno during the loop.

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

index 241de05520d62ab929f506fe5ffbdf5672a485f8..aba97df8e122588fa631192696570997c4e93ec5 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -238,13 +238,14 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
                                            "array_state",
                                            "inactive")) < 0 &&
                       errno == EBUSY) {
+                       err = errno;
                        sleep_for(0, MSEC_TO_NSEC(200), true);
                        count--;
                }
                if (err) {
                        if (verbose >= 0)
                                pr_err("failed to stop array %s: %s\n",
-                                      devname, strerror(errno));
+                                      devname, strerror(err));
                        rv = 1;
                        goto out;
                }
@@ -438,14 +439,15 @@ done:
        count = 25; err = 0;
        while (count && fd >= 0 &&
               (err = ioctl(fd, STOP_ARRAY, NULL)) < 0 && errno == EBUSY) {
+               err = errno;
                sleep_for(0, MSEC_TO_NSEC(200), true);
                count --;
        }
        if (fd >= 0 && err) {
                if (verbose >= 0) {
                        pr_err("failed to stop array %s: %s\n",
-                              devname, strerror(errno));
-                       if (errno == EBUSY)
+                              devname, strerror(err));
+                       if (err == EBUSY)
                                cont_err("Perhaps a running process, mounted filesystem or active volume group?\n");
                }
                rv = 1;