Manage: split Manage_runstop into Manage_run and Manage_stop
The two branches have virtually nothing in common, so it is simpler if they are separate. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
8cde842b18
commit
fe7e0e64b0
|
@ -1677,8 +1677,7 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
|
|||
*/
|
||||
int devid = devnm2devid(ent->devnm);
|
||||
run_udisks("--unmount", map_dev(major(devid),minor(devid), 0));
|
||||
rv = Manage_runstop(ent->dev, mdfd, -1,
|
||||
verbose, 1);
|
||||
rv = Manage_stop(ent->dev, mdfd, verbose, 1);
|
||||
if (rv)
|
||||
/* At least we can try to trigger a 'remove' */
|
||||
sysfs_uevent(&mdi, "remove");
|
||||
|
|
47
Manage.c
47
Manage.c
|
@ -170,35 +170,19 @@ static void remove_devices(char *devnm, char *path)
|
|||
free(path2);
|
||||
}
|
||||
|
||||
int Manage_runstop(char *devname, int fd, int runstop,
|
||||
int verbose, int will_retry)
|
||||
int Manage_run(char *devname, int fd, int verbose)
|
||||
{
|
||||
/* Run or stop the array. Array must already be configured
|
||||
* 'Run' requires >= 0.90.0
|
||||
* 'will_retry' is only relevant for 'stop', and means
|
||||
* that error messages are not wanted.
|
||||
/* Run the array. Array must already be configured
|
||||
* Requires >= 0.90.0
|
||||
*/
|
||||
mdu_param_t param; /* unused */
|
||||
int rv = 0;
|
||||
|
||||
if (will_retry && verbose == 0)
|
||||
verbose = -1;
|
||||
|
||||
if (runstop == -1 && md_get_version(fd) < 9000) {
|
||||
if (ioctl(fd, STOP_MD, 0) == 0)
|
||||
return 0;
|
||||
pr_err("stopping device %s "
|
||||
"failed: %s\n",
|
||||
devname, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (md_get_version(fd) < 9000) {
|
||||
pr_err("need md driver version 0.90.0 or later\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (runstop > 0) {
|
||||
if (ioctl(fd, RUN_ARRAY, ¶m)) {
|
||||
if (verbose >= 0)
|
||||
pr_err("failed to run array %s: %s\n",
|
||||
|
@ -207,13 +191,34 @@ int Manage_runstop(char *devname, int fd, int runstop,
|
|||
}
|
||||
if (verbose >= 0)
|
||||
pr_err("started %s\n", devname);
|
||||
} else if (runstop < 0){
|
||||
return rv;
|
||||
}
|
||||
|
||||
int Manage_stop(char *devname, int fd, int verbose, int will_retry)
|
||||
{
|
||||
/* Stop the array. Array must already be configured
|
||||
* 'will_retry' means that error messages are not wanted.
|
||||
*/
|
||||
int rv = 0;
|
||||
struct map_ent *map = NULL;
|
||||
struct mdinfo *mdi;
|
||||
char devnm[32];
|
||||
char container[32];
|
||||
int err;
|
||||
int count;
|
||||
|
||||
if (will_retry && verbose == 0)
|
||||
verbose = -1;
|
||||
|
||||
if (md_get_version(fd) < 9000) {
|
||||
if (ioctl(fd, STOP_MD, 0) == 0)
|
||||
return 0;
|
||||
pr_err("stopping device %s "
|
||||
"failed: %s\n",
|
||||
devname, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If this is an mdmon managed array, just write 'inactive'
|
||||
* to the array state and let mdmon clear up.
|
||||
*/
|
||||
|
@ -371,7 +376,7 @@ int Manage_runstop(char *devname, int fd, int runstop,
|
|||
out:
|
||||
if (mdi)
|
||||
sysfs_free(mdi);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
12
mdadm.c
12
mdadm.c
|
@ -1301,8 +1301,10 @@ int main(int argc, char *argv[])
|
|||
c.update, c.force);
|
||||
if (!rv && c.readonly < 0)
|
||||
rv = Manage_ro(devlist->devname, mdfd, c.readonly);
|
||||
if (!rv && c.runstop)
|
||||
rv = Manage_runstop(devlist->devname, mdfd, c.runstop, c.verbose, 0);
|
||||
if (!rv && c.runstop > 0)
|
||||
rv = Manage_run(devlist->devname, mdfd, c.verbose);
|
||||
if (!rv && c.runstop < 0)
|
||||
rv = Manage_stop(devlist->devname, mdfd, c.verbose, 0);
|
||||
break;
|
||||
case ASSEMBLE:
|
||||
if (devs_found == 1 && ident.uuid_set == 0 &&
|
||||
|
@ -1727,7 +1729,7 @@ static int stop_scan(int verbose)
|
|||
}
|
||||
mdfd = open_mddev(name, 1);
|
||||
if (mdfd >= 0) {
|
||||
if (Manage_runstop(name, mdfd, -1, verbose, !last))
|
||||
if (Manage_stop(name, mdfd, verbose, !last))
|
||||
err = 1;
|
||||
else
|
||||
progress = 1;
|
||||
|
@ -1805,9 +1807,9 @@ static int misc_list(struct mddev_dev *devlist,
|
|||
if (mdfd>=0) {
|
||||
switch(dv->disposition) {
|
||||
case 'R':
|
||||
rv |= Manage_runstop(dv->devname, mdfd, 1, c->verbose, 0); break;
|
||||
rv |= Manage_run(dv->devname, mdfd, c->verbose); break;
|
||||
case 'S':
|
||||
rv |= Manage_runstop(dv->devname, mdfd, -1, c->verbose, 0); break;
|
||||
rv |= Manage_stop(dv->devname, mdfd, c->verbose, 0); break;
|
||||
case 'o':
|
||||
rv |= Manage_ro(dv->devname, mdfd, 1); break;
|
||||
case 'w':
|
||||
|
|
3
mdadm.h
3
mdadm.h
|
@ -1158,7 +1158,8 @@ extern int add_dev(const char *name, const struct stat *stb, int flag, struct FT
|
|||
|
||||
|
||||
extern int Manage_ro(char *devname, int fd, int readonly);
|
||||
extern int Manage_runstop(char *devname, int fd, int runstop, int quiet,
|
||||
extern int Manage_run(char *devname, int fd, int quiet);
|
||||
extern int Manage_stop(char *devname, int fd, int quiet,
|
||||
int will_retry);
|
||||
extern int Manage_subdevs(char *devname, int fd,
|
||||
struct mddev_dev *devlist, int verbose, int test,
|
||||
|
|
Loading…
Reference in New Issue