Re: [PATCH] Retry writing 'inactive' state during stopping array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 17 Mar 2011 17:34:57 +0100 Krzysztof Wojcik
<krzysztof.wojcik@xxxxxxxxx> 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@xxxxxxxxx>

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

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux