mdmon: don't wait for O_EXCL when shutting down.
If mdmon is shutting down because there are no devices left to look at, then don't wait 5 seconds for an O_EXCL open, and that can block progress of --grow. Only wait for O_EXCL if we received a signal. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
4e2c1a9a32
commit
d998b738f5
1
mdadm.h
1
mdadm.h
|
@ -1086,6 +1086,7 @@ extern int check_partitions(int fd, char *dname,
|
||||||
extern int get_mdp_major(void);
|
extern int get_mdp_major(void);
|
||||||
extern int dev_open(char *dev, int flags);
|
extern int dev_open(char *dev, int flags);
|
||||||
extern int open_dev(int devnum);
|
extern int open_dev(int devnum);
|
||||||
|
extern int open_dev_flags(int devnum, int flags);
|
||||||
extern int open_dev_excl(int devnum);
|
extern int open_dev_excl(int devnum);
|
||||||
extern int is_standard(char *dev, int *nump);
|
extern int is_standard(char *dev, int *nump);
|
||||||
extern int same_dev(char *one, char *two);
|
extern int same_dev(char *one, char *two);
|
||||||
|
|
16
monitor.c
16
monitor.c
|
@ -563,7 +563,11 @@ static int wait_and_act(struct supertype *container, int nowait)
|
||||||
* problem as there are no active arrays, there is
|
* problem as there are no active arrays, there is
|
||||||
* nothing that we need to be ready to do.
|
* nothing that we need to be ready to do.
|
||||||
*/
|
*/
|
||||||
int fd = open_dev_excl(container->devnum);
|
int fd;
|
||||||
|
if (sigterm)
|
||||||
|
fd = open_dev_excl(container->devnum);
|
||||||
|
else
|
||||||
|
fd = open_dev_flags(container->devnum, O_RDONLY|O_EXCL);
|
||||||
if (fd >= 0 || errno != EBUSY) {
|
if (fd >= 0 || errno != EBUSY) {
|
||||||
/* OK, we are safe to leave */
|
/* OK, we are safe to leave */
|
||||||
if (sigterm && !dirty_arrays)
|
if (sigterm && !dirty_arrays)
|
||||||
|
@ -584,10 +588,18 @@ static int wait_and_act(struct supertype *container, int nowait)
|
||||||
|
|
||||||
if (!nowait) {
|
if (!nowait) {
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = 24*3600;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
if (*aap == NULL) {
|
||||||
|
/* just waiting to get O_EXCL access */
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 20000000ULL;
|
||||||
|
}
|
||||||
sigprocmask(SIG_UNBLOCK, NULL, &set);
|
sigprocmask(SIG_UNBLOCK, NULL, &set);
|
||||||
sigdelset(&set, SIGUSR1);
|
sigdelset(&set, SIGUSR1);
|
||||||
monitor_loop_cnt |= 1;
|
monitor_loop_cnt |= 1;
|
||||||
rv = pselect(maxfd+1, NULL, NULL, &rfds, NULL, &set);
|
rv = pselect(maxfd+1, NULL, NULL, &rfds, &ts, &set);
|
||||||
monitor_loop_cnt += 1;
|
monitor_loop_cnt += 1;
|
||||||
if (rv == -1 && errno == EINTR)
|
if (rv == -1 && errno == EINTR)
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
9
util.c
9
util.c
|
@ -998,12 +998,17 @@ int dev_open(char *dev, int flags)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int open_dev(int devnum)
|
int open_dev_flags(int devnum, int flags)
|
||||||
{
|
{
|
||||||
char buf[20];
|
char buf[20];
|
||||||
|
|
||||||
sprintf(buf, "%d:%d", dev2major(devnum), dev2minor(devnum));
|
sprintf(buf, "%d:%d", dev2major(devnum), dev2minor(devnum));
|
||||||
return dev_open(buf, O_RDONLY);
|
return dev_open(buf, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
int open_dev(int devnum)
|
||||||
|
{
|
||||||
|
return open_dev_flags(devnum, O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int open_dev_excl(int devnum)
|
int open_dev_excl(int devnum)
|
||||||
|
|
Loading…
Reference in New Issue