From: NeilBrown Date: Wed, 10 Jul 2013 01:10:54 +0000 (+1000) Subject: Grow: use mdstat_wait to wait for delayed reshape. X-Git-Tag: mdadm-3.3-rc2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7a0d8a116c11b2208e70fd4dcc8ab920e472b8b;p=thirdparty%2Fmdadm.git Grow: use mdstat_wait to wait for delayed reshape. Having a fix time for a wait is clumsy and can make us wait much too long. So use mdstat_wait and keep the mdstat_fd open. This requires an 'mdstat_close' so it doesn't stay open forever. Signed-off-by: NeilBrown --- diff --git a/Grow.c b/Grow.c index 7baa5f8a..84f0a295 100644 --- a/Grow.c +++ b/Grow.c @@ -3228,7 +3228,7 @@ started: do { struct mdstat_ent *mds, *m; delayed = 0; - mds = mdstat_read(0, 0); + mds = mdstat_read(1, 0); for (m = mds; m; m = m->next) if (strcmp(m->devnm, sra->sys_name) == 0) { if (m->resync && @@ -3248,9 +3248,9 @@ started: delayed = 0; } if (delayed) - sleep(30 - (delayed-1) * 25); + mdstat_wait(30 - (delayed-1) * 25); } while (delayed); - + mdstat_close(); close(fd); if (check_env("MDADM_GROW_VERIFY")) fd = open(devname, O_RDONLY | O_DIRECT); diff --git a/mdadm.h b/mdadm.h index fed3bc8c..c1c0bb2e 100644 --- a/mdadm.h +++ b/mdadm.h @@ -465,6 +465,7 @@ struct mdstat_ent { }; extern struct mdstat_ent *mdstat_read(int hold, int start); +extern void mdstat_close(void); extern void free_mdstat(struct mdstat_ent *ms); extern void mdstat_wait(int seconds); extern void mdstat_wait_fd(int fd, const sigset_t *sigmask); diff --git a/mdstat.c b/mdstat.c index 9ebfc075..8b16d3e8 100644 --- a/mdstat.c +++ b/mdstat.c @@ -289,6 +289,13 @@ struct mdstat_ent *mdstat_read(int hold, int start) return rv; } +void mdstat_close(void) +{ + if (mdstat_fd >= 0) + close(mdstat_fd); + mdstat_fd = -1; +} + void mdstat_wait(int seconds) { fd_set fds;