Re: [PATCH 2/3] Create: Unnecessary prompt about device being busy

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

 



On Mon, 19 Sep 2011 18:52:38 +0200 Lukasz Orlowski
<lukasz.orlowski@xxxxxxxxx> wrote:

> Should the geometry validation fail, mdadm exits with error code 2 if the
> style of metadata is not explicitly set to imsm. Prior to that however it
> attempts to exclusively open a device block file. If it succeeds it says
> that the device is not suitable for any kind of array, otherwise it just
> says that the device is busy. The file opened is not closed afterwards.
> 
> Signed-off-by: Lukasz Orlowski <lukasz.orlowski@xxxxxxxxx>

I'm confused.  What exactly is the problem here?

If geometry validation fails, we need to exit because there is nothing useful
we can do.
We simply check if the problem is that the device is already in use, or if it
is an unusable device and report that.  Then exit.
Seeing we are about the exit there is point closing the file.

What is the scenario when you get incorrect behaviour?

NeilBrown


> ---
>  Create.c |   18 +++++++++---------
>  1 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/Create.c b/Create.c
> index 8d88aa1..47e5fc8 100644
> --- a/Create.c
> +++ b/Create.c
> @@ -346,15 +346,15 @@ int Create(struct supertype *st, char *mddev,
>  
>  			if (!st) {
>  				int dfd = open(dname, O_RDONLY|O_EXCL);
> -				if (dfd < 0) {
> -					fprintf(stderr, Name ": cannot open %s: %s\n",
> -						dname, strerror(errno));
> -					exit(2);
> +				if (dfd >= 0) {
> +					fprintf(stderr,
> +						Name ": device %s not suitable"
> +						" for any style of array\n",
> +						dname);
> +					close(dfd);
>  				}
> -				fprintf(stderr, Name ": device %s not suitable "
> -					"for any style of array\n",
> -					dname);
> -				exit(2);
> +				fail = 1;
> +				break;
>  			}
>  			if (st->ss != &super0 ||
>  			    st->minor_version != 90)
> @@ -443,7 +443,7 @@ int Create(struct supertype *st, char *mddev,
>  			close(fd);
>  		}
>  	}
> -	if (raiddisks + sparedisks > st->max_devs) {
> +	if (st && raiddisks + sparedisks > st->max_devs) {
>  		fprintf(stderr, Name ": Too many devices:"
>  			" %s metadata only supports %d\n",
>  			st->ss->name, st->max_devs);
> 
> ---------------------------------------------------------------------
> Intel Technology Poland sp. z o.o.
> z siedziba w Gdansku
> ul. Slowackiego 173
> 80-298 Gdansk
> 
> Sad Rejonowy Gdansk Polnoc w Gdansku, 
> VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, 
> numer KRS 101882
> 
> NIP 957-07-52-316
> Kapital zakladowy 200.000 zl
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.

Attachment: signature.asc
Description: PGP signature


[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