linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Retry writing 'inactive' state during stopping array
@ 2011-03-17 16:34 Krzysztof Wojcik
  2011-03-18  1:43 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Wojcik @ 2011-03-17 16:34 UTC (permalink / raw)
  To: neilb
  Cc: linux-raid, wojciech.neubauer, adam.kwolek, dan.j.williams,
	ed.ciechanowski

Issue observed:
Sporadicaly stopping arrays using "mdadm -Ss" command does not succeded.
Cause:
Writting "inactive" to the array state not succeded- array is busy
(accessed by udev, blkid etc.)
Resolution:
If writing 'inactive' fails, wait and retry again (because it is possibly
a transient failure)

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
---
 Manage.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Manage.c b/Manage.c
index ed3112e..a6531f3 100644
--- a/Manage.c
+++ b/Manage.c
@@ -224,7 +224,9 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
 				close(fd);
 			fprintf(stderr,
 				Name ": Cannot get exclusive access to %s:"
-				" possibly it is still in use.\n",
+				"Perhaps a running "
+				"process, mounted filesystem "
+				"or active volume group?\n",
 				devname);
 			return 1;
 		}
@@ -234,12 +236,18 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
 		    is_subarray(mdi->text_version)) {
 			/* This is mdmon managed. */
 			close(fd);
-			if (sysfs_set_str(mdi, NULL,
-					  "array_state", "inactive") < 0) {
-				if (quiet == 0)
-					fprintf(stderr, Name
-						": failed to stop array %s: %s\n",
-						devname, strerror(errno));
+
+			count = 25;
+			while (count && sysfs_set_str(mdi, NULL,
+				  "array_state", "inactive") < 0
+				  && errno == EBUSY) {
+				usleep(200000);
+				count--;
+			}
+			if (!count && !quiet) {
+				fprintf(stderr, Name
+					": failed to stop array %s: %s\n",
+					devname, strerror(errno));
 				return 1;
 			}
 
@@ -297,6 +305,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
 			usleep(200000);
 			count --;
 		}
+
 		if (fd >= 0 && err) {
 			if (quiet == 0) {
 				fprintf(stderr, Name


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Retry writing 'inactive' state during stopping array
  2011-03-17 16:34 [PATCH] Retry writing 'inactive' state during stopping array Krzysztof Wojcik
@ 2011-03-18  1:43 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2011-03-18  1:43 UTC (permalink / raw)
  To: Krzysztof Wojcik
  Cc: linux-raid, wojciech.neubauer, adam.kwolek, dan.j.williams,
	ed.ciechanowski

On Thu, 17 Mar 2011 17:34:57 +0100 Krzysztof Wojcik
<krzysztof.wojcik@intel.com> wrote:

> Issue observed:
> Sporadicaly stopping arrays using "mdadm -Ss" command does not succeded.
> Cause:
> Writting "inactive" to the array state not succeded- array is busy
> (accessed by udev, blkid etc.)
> Resolution:
> If writing 'inactive' fails, wait and retry again (because it is possibly
> a transient failure)
> 
> Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>

Thanks.  Applied,
though with a small change so that it will print an error message even if the
error isn't EBUSY.

Thanks,
NeilBrown


> ---
>  Manage.c |   23 ++++++++++++++++-------
>  1 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/Manage.c b/Manage.c
> index ed3112e..a6531f3 100644
> --- a/Manage.c
> +++ b/Manage.c
> @@ -224,7 +224,9 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
>  				close(fd);
>  			fprintf(stderr,
>  				Name ": Cannot get exclusive access to %s:"
> -				" possibly it is still in use.\n",
> +				"Perhaps a running "
> +				"process, mounted filesystem "
> +				"or active volume group?\n",
>  				devname);
>  			return 1;
>  		}
> @@ -234,12 +236,18 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
>  		    is_subarray(mdi->text_version)) {
>  			/* This is mdmon managed. */
>  			close(fd);
> -			if (sysfs_set_str(mdi, NULL,
> -					  "array_state", "inactive") < 0) {
> -				if (quiet == 0)
> -					fprintf(stderr, Name
> -						": failed to stop array %s: %s\n",
> -						devname, strerror(errno));
> +
> +			count = 25;
> +			while (count && sysfs_set_str(mdi, NULL,
> +				  "array_state", "inactive") < 0
> +				  && errno == EBUSY) {
> +				usleep(200000);
> +				count--;
> +			}
> +			if (!count && !quiet) {
> +				fprintf(stderr, Name
> +					": failed to stop array %s: %s\n",
> +					devname, strerror(errno));
>  				return 1;
>  			}
>  
> @@ -297,6 +305,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
>  			usleep(200000);
>  			count --;
>  		}
> +
>  		if (fd >= 0 && err) {
>  			if (quiet == 0) {
>  				fprintf(stderr, Name


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-18  1:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 16:34 [PATCH] Retry writing 'inactive' state during stopping array Krzysztof Wojcik
2011-03-18  1:43 ` NeilBrown

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).