Skip to content

Commit a7a0d8a

Browse files
committed
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 <[email protected]>
1 parent b4924f4 commit a7a0d8a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Grow.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,7 @@ static int reshape_array(char *container, int fd, char *devname,
32283228
do {
32293229
struct mdstat_ent *mds, *m;
32303230
delayed = 0;
3231-
mds = mdstat_read(0, 0);
3231+
mds = mdstat_read(1, 0);
32323232
for (m = mds; m; m = m->next)
32333233
if (strcmp(m->devnm, sra->sys_name) == 0) {
32343234
if (m->resync &&
@@ -3248,9 +3248,9 @@ static int reshape_array(char *container, int fd, char *devname,
32483248
delayed = 0;
32493249
}
32503250
if (delayed)
3251-
sleep(30 - (delayed-1) * 25);
3251+
mdstat_wait(30 - (delayed-1) * 25);
32523252
} while (delayed);
3253-
3253+
mdstat_close();
32543254
close(fd);
32553255
if (check_env("MDADM_GROW_VERIFY"))
32563256
fd = open(devname, O_RDONLY | O_DIRECT);

mdadm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ struct mdstat_ent {
465465
};
466466

467467
extern struct mdstat_ent *mdstat_read(int hold, int start);
468+
extern void mdstat_close(void);
468469
extern void free_mdstat(struct mdstat_ent *ms);
469470
extern void mdstat_wait(int seconds);
470471
extern void mdstat_wait_fd(int fd, const sigset_t *sigmask);

mdstat.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ struct mdstat_ent *mdstat_read(int hold, int start)
289289
return rv;
290290
}
291291

292+
void mdstat_close(void)
293+
{
294+
if (mdstat_fd >= 0)
295+
close(mdstat_fd);
296+
mdstat_fd = -1;
297+
}
298+
292299
void mdstat_wait(int seconds)
293300
{
294301
fd_set fds;

0 commit comments

Comments
 (0)