Change "mdadm --run" to use the same code as "mdadm --IRs".

Current "mdadm --run /dev/mdX" will not handle external metadata
properly.  mdmon won't be started etc.

So use the code from "mdadm -IRs" instead - that already does all
the right things.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2013-08-26 15:24:53 +10:00
parent 4c0ea7b0d9
commit d3786cdcd0
4 changed files with 14 additions and 14 deletions

View File

@ -1278,7 +1278,7 @@ static int try_spare(char *devname, int *dfdp, struct dev_policy *pol,
return rv;
}
int IncrementalScan(int verbose)
int IncrementalScan(int verbose, char *devnm)
{
/* look at every device listed in the 'map' file.
* If one is found that is not running then:
@ -1298,7 +1298,11 @@ int IncrementalScan(int verbose)
mdu_array_info_t array;
mdu_bitmap_file_t bmf;
struct mdinfo *sra;
int mdfd = open_dev(me->devnm);
int mdfd;
if (devnm && strcmp(devnm, me->devnm) != 0)
continue;
mdfd = open_dev(me->devnm);
if (mdfd < 0)
continue;

View File

@ -175,23 +175,19 @@ int Manage_run(char *devname, int fd, int verbose)
/* Run the array. Array must already be configured
* Requires >= 0.90.0
*/
mdu_param_t param; /* unused */
int rv = 0;
char nm[32], *nmp;
if (md_get_version(fd) < 9000) {
pr_err("need md driver version 0.90.0 or later\n");
return 1;
}
if (ioctl(fd, RUN_ARRAY, &param)) {
if (verbose >= 0)
pr_err("failed to run array %s: %s\n",
devname, strerror(errno));
nmp = fd2devnm(fd);
if (!nmp) {
pr_err("Cannot find %s in sysfs!!\n", devname);
return 1;
}
if (verbose >= 0)
pr_err("started %s\n", devname);
return rv;
strcpy(nm, nmp);
return IncrementalScan(verbose, nm);
}
int Manage_stop(char *devname, int fd, int verbose, int will_retry)

View File

@ -1535,7 +1535,7 @@ int main(int argc, char *argv[])
pr_err("--incremental --scan --fail not supported.\n");
break;
}
rv = IncrementalScan(c.verbose);
rv = IncrementalScan(c.verbose, NULL);
}
if (!devlist) {
if (!rebuild_map && !c.scan) {

View File

@ -1235,7 +1235,7 @@ extern int WaitClean(char *dev, int sock, int verbose);
extern int Incremental(char *devname, struct context *c,
struct supertype *st);
extern void RebuildMap(void);
extern int IncrementalScan(int verbose);
extern int IncrementalScan(int verbose, char *devnm);
extern int IncrementalRemove(char *devname, char *path, int verbose);
extern int CreateBitmap(char *filename, int force, char uuid[16],
unsigned long chunksize, unsigned long daemon_sleep,