Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, maciej.patelczyk@intel.com,
	lukasz.dorau@intel.com
Subject: [PATCH] Manage.c: Try to get EXCL access more times while stopping the array
Date: Wed, 03 Apr 2013 14:47:15 +0200	[thread overview]
Message-ID: <20130403124715.23223.5137.stgit@localhost.localdomain> (raw)

If mdadm does not get EXCL access to the array, it should try again
after a while, because there still can be (for example)
a process of mdmon that is finishing aborting reshape.
If this fails couple of times, mdadm should stop
trying, print an error and abort stopping the array.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
---
 Manage.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Manage.c b/Manage.c
index 6267c0c..23e7c85 100644
--- a/Manage.c
+++ b/Manage.c
@@ -222,7 +222,14 @@ int Manage_runstop(char *devname, int fd, int runstop,
 		 * to stop is probably a bad idea.
 		 */
 		close(fd);
-		fd = open(devname, O_RDONLY|O_EXCL);
+		count = 5;
+		while (((fd = open(devname, O_RDONLY|O_EXCL)) < 0 ||
+				strcmp(fd2devnm(fd), devnm) != 0) && count) {
+			if (fd >= 0)
+				close(fd);
+			usleep(200000);
+			count--;
+		}
 		if (fd < 0 || strcmp(fd2devnm(fd), devnm) != 0) {
 			if (fd >= 0)
 				close(fd);


             reply	other threads:[~2013-04-03 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 12:47 Pawel Baldysiak [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-04-10 14:00 [PATCH] Manage.c: Try to get EXCL access more times while stopping the array Pawel Baldysiak

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=20130403124715.23223.5137.stgit@localhost.localdomain \
    --to=pawel.baldysiak@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=lukasz.dorau@intel.com \
    --cc=maciej.patelczyk@intel.com \
    --cc=neilb@suse.de \
    /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