Remove re_add flag in favour of new disposition.

Instead of
   disposition == 'a'  re_add == 1
use
   disposition == 'A'

to record that a re-add was requested.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2012-07-09 17:14:16 +10:00
parent e7b84f9d50
commit c8e1a230b7
4 changed files with 9 additions and 16 deletions

View File

@ -950,7 +950,6 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
char devname[20];
devlist.next = NULL;
devlist.used = 0;
devlist.re_add = 0;
devlist.writemostly = 0;
devlist.devname = devname;
sprintf(devname, "%d:%d", major(stb.st_rdev),

View File

@ -524,7 +524,7 @@ int Manage_subdevs(char *devname, int fd,
if (next != dv)
continue;
} else if (strcmp(dv->devname, "missing") == 0) {
if (dv->disposition != 'a' || dv->re_add == 0) {
if (dv->disposition != 'A') {
pr_err("'missing' only meaningful "
"with --re-add\n");
goto abort;
@ -610,6 +610,7 @@ int Manage_subdevs(char *devname, int fd,
dv->devname, dv->disposition);
goto abort;
case 'a':
case 'A':
/* add the device */
if (subarray) {
pr_err("Cannot add disks to a"
@ -724,8 +725,7 @@ int Manage_subdevs(char *devname, int fd,
break;
}
/* FIXME this is a bad test to be using */
if (!tst->sb &&
dv->re_add) {
if (!tst->sb && dv->disposition == 'A') {
/* we are re-adding a device to a
* completely dead array - have to depend
* on kernel to check
@ -857,7 +857,7 @@ int Manage_subdevs(char *devname, int fd,
}
continue;
}
if (dv->re_add) {
if (dv->disposition == 'A') {
if (tfd >= 0)
close(tfd);
pr_err("--re-add for %s to %s is not possible\n",
@ -943,7 +943,7 @@ int Manage_subdevs(char *devname, int fd,
close(dfd);
goto abort;
}
} else if (dv->re_add) {
} else if (dv->disposition == 'A') {
/* this had better be raid1.
* As we are "--re-add"ing we must find a spare slot
* to fill.
@ -1269,7 +1269,6 @@ int move_spare(char *from_devname, char *to_devname, dev_t devid)
devlist.next = NULL;
devlist.used = 0;
devlist.re_add = 0;
devlist.writemostly = 0;
devlist.devname = devname;
sprintf(devname, "%d:%d", major(devid), minor(devid));

View File

@ -117,7 +117,6 @@ int main(int argc, char *argv[])
int spare_sharing = 1;
struct supertype *ss = NULL;
int writemostly = 0;
int re_add = 0;
char *shortopt = short_options;
int dosyslog = 0;
int rebuild_map = 0;
@ -326,7 +325,6 @@ int main(int argc, char *argv[])
dv->devname = optarg;
dv->disposition = devmode;
dv->writemostly = writemostly;
dv->re_add = re_add;
dv->used = 0;
dv->next = NULL;
*devlistend = dv;
@ -382,7 +380,6 @@ int main(int argc, char *argv[])
dv->devname = optarg;
dv->disposition = devmode;
dv->writemostly = writemostly;
dv->re_add = re_add;
dv->used = 0;
dv->next = NULL;
*devlistend = dv;
@ -785,7 +782,7 @@ int main(int argc, char *argv[])
case O(MANAGE,'U'):
/* update=devicesize is allowed with --re-add */
if (devmode != 'a' || re_add != 1) {
if (devmode != 'A') {
pr_err("--update in Manage mode only"
" allowed with --re-add.\n");
exit(1);
@ -912,11 +909,9 @@ int main(int argc, char *argv[])
case O(MANAGE,'a'):
case O(MANAGE,Add): /* add a drive */
devmode = 'a';
re_add = 0;
continue;
case O(MANAGE,ReAdd):
devmode = 'a';
re_add = 1;
devmode = 'A';
continue;
case O(MANAGE,'r'): /* remove a drive */
case O(MANAGE,Remove):

View File

@ -377,11 +377,11 @@ struct mddev_ident {
/* List of device names - wildcards expanded */
struct mddev_dev {
char *devname;
int disposition; /* 'a' for add, 'r' for remove, 'f' for fail.
int disposition; /* 'a' for add, 'r' for remove, 'f' for fail,
* 'A' for re_add.
* Not set for names read from .config
*/
char writemostly; /* 1 for 'set writemostly', 2 for 'clear writemostly' */
char re_add;
char used; /* set when used */
struct mddev_dev *next;
};