linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Ni <xni@redhat.com>
To: mariusz.tkaczyk@linux.intel.com
Cc: ncroxon@redhat.com, linux-raid@vger.kernel.org
Subject: [PATCH 10/10] mdadm/Manage: record errno
Date: Wed, 28 Aug 2024 10:11:50 +0800	[thread overview]
Message-ID: <20240828021150.63240-11-xni@redhat.com> (raw)
In-Reply-To: <20240828021150.63240-1-xni@redhat.com>

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>
---
 Manage.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Manage.c b/Manage.c
index 241de05520d6..aba97df8e122 100644
--- 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;
-- 
2.32.0 (Apple Git-132)


  parent reply	other threads:[~2024-08-28  2:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28  2:11 [PATCH 00/10] mdadm tests fix Xiao Ni
2024-08-28  2:11 ` [PATCH 01/10] mdadm/Grow: Update new level when starting reshape Xiao Ni
2024-09-02  9:50   ` Mariusz Tkaczyk
2024-09-02 10:10     ` Mariusz Tkaczyk
2024-09-03  0:34       ` Xiao Ni
2024-09-03  7:34         ` Mariusz Tkaczyk
2024-09-03 10:11           ` Xiao Ni
2024-09-03  0:32     ` Xiao Ni
2024-08-28  2:11 ` [PATCH 02/10] mdadm/Grow: Update reshape_progress to need_back after reshape finishes Xiao Ni
2024-09-02  9:55   ` Mariusz Tkaczyk
2024-08-28  2:11 ` [PATCH 03/10] mdadm/Grow: Can't open raid when running --grow --continue Xiao Ni
2024-09-02 10:00   ` Mariusz Tkaczyk
2024-08-28  2:11 ` [PATCH 04/10] mdadm/Grow: sleep a while after removing disk in impose_level Xiao Ni
     [not found]   ` <20240902121359.00007a84@linux.intel.com>
2024-09-03  0:53     ` Xiao Ni
2024-09-03  7:22       ` Mariusz Tkaczyk
2024-09-11  8:42         ` Xiao Ni
2024-08-28  2:11 ` [PATCH 05/10] mdadm/tests: wait until level changes Xiao Ni
2024-08-28  2:11 ` [PATCH 06/10] mdadm/tests: 07changelevels fix Xiao Ni
2024-08-28  2:11 ` [PATCH 07/10] mdadm/tests: Remove 07reshape5intr.broken Xiao Ni
2024-08-28  2:11 ` [PATCH 08/10] mdadm/tests: 07testreshape5 fix Xiao Ni
2024-08-28  2:11 ` [PATCH 09/10] mdadm/tests: remove 09imsm-assemble.broken Xiao Ni
2024-08-28  2:11 ` Xiao Ni [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-11  8:54 [PATCH 00/10] mdadm tests fix Xiao Ni
2024-09-11  8:54 ` [PATCH 10/10] mdadm/Manage: record errno Xiao Ni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240828021150.63240-11-xni@redhat.com \
    --to=xni@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mariusz.tkaczyk@linux.intel.com \
    --cc=ncroxon@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).