grow: don't wait forever for critical section to pass.
If an array reshape completed within 1 second, then --grow will not notice that it has finished and will keep waiting for the critical section to pass. So be more cautious in the test. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
b9d77223eb
commit
93ecfa01d4
8
Grow.c
8
Grow.c
|
@ -815,6 +815,14 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
|
|||
}
|
||||
if (comp >= nstripe)
|
||||
break;
|
||||
if (comp == 0) {
|
||||
/* Maybe it finished already */
|
||||
char action[20];
|
||||
if (sysfs_get_str(sra, NULL, "sync_action",
|
||||
action, 20) > 0 &&
|
||||
strncmp(action, "reshape", 7) != 0)
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
|
|
2
mdadm.h
2
mdadm.h
|
@ -369,6 +369,8 @@ extern int sysfs_set_num(struct mdinfo *sra, struct mdinfo *dev,
|
|||
extern int sysfs_uevent(struct mdinfo *sra, char *event);
|
||||
extern int sysfs_get_ll(struct mdinfo *sra, struct mdinfo *dev,
|
||||
char *name, unsigned long long *val);
|
||||
extern int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
|
||||
char *name, char *val, int size);
|
||||
extern int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms);
|
||||
extern int sysfs_set_array(struct mdinfo *info, int vers);
|
||||
extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd);
|
||||
|
|
19
sysfs.c
19
sysfs.c
|
@ -466,6 +466,25 @@ int sysfs_get_ll(struct mdinfo *sra, struct mdinfo *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
|
||||
char *name, char *val, int size)
|
||||
{
|
||||
char fname[50];
|
||||
int n;
|
||||
int fd;
|
||||
sprintf(fname, "/sys/block/%s/md/%s/%s",
|
||||
sra->sys_name, dev?dev->sys_name:"", name);
|
||||
fd = open(fname, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
n = read(fd, val, size);
|
||||
close(fd);
|
||||
if (n <= 0)
|
||||
return -1;
|
||||
val[n] = 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms)
|
||||
{
|
||||
unsigned long sec;
|
||||
|
|
Loading…
Reference in New Issue