Honor safemode_delay at Create() and Incremental() time

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Dan Williams 2008-09-15 20:58:42 -07:00
parent 301406c9fd
commit 8ed3e5e1bf
4 changed files with 18 additions and 0 deletions

View File

@ -78,6 +78,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
struct mdinfo *sra;
struct mdinfo info, *infos;
int did_default = 0;
unsigned long safe_mode_delay = 0;
int major_num = BITMAP_MAJOR_HI;
@ -703,6 +704,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
st->ss->add_to_super(st, &inf->disk,
fd, dv->devname);
st->ss->getinfo_super(st, inf);
safe_mode_delay = inf->safe_mode_delay;
/* getinfo_super might have lost these ... */
inf->disk.major = major(stb.st_rdev);
@ -757,6 +759,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
"readonly");
break;
}
sysfs_set_safemode(sra, safe_mode_delay);
} else {
mdu_param_t param;
if (ioctl(mdfd, RUN_ARRAY, &param)) {

View File

@ -841,6 +841,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
ping_monitor(devnum2devname(st->container_dev));
break;
}
sysfs_set_safemode(sra, ra->safe_mode_delay);
if (verbose >= 0)
printf("Started %s with %d devices\n",
chosen_name, working);

View File

@ -346,6 +346,7 @@ extern int sysfs_set_num(struct mdinfo *sra, struct mdinfo *dev,
char *name, unsigned long long val);
extern int sysfs_get_ll(struct mdinfo *sra, struct mdinfo *dev,
char *name, unsigned long long *val);
extern int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms);
extern int sysfs_set_array(struct mdinfo *sra,
struct mdinfo *info);
extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd);

13
sysfs.c
View File

@ -346,6 +346,19 @@ int sysfs_get_ll(struct mdinfo *sra, struct mdinfo *dev,
return 0;
}
int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms)
{
unsigned long sec;
unsigned long msec;
char delay[30];
sec = ms / 1000;
msec = ms - (sec * 1000);
sprintf(delay, "%ld.%ld", sec, msec);
return sysfs_set_str(sra, NULL, "safe_mode_delay", delay);
}
int sysfs_set_array(struct mdinfo *sra,
struct mdinfo *info)
{