X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=monitor.c;h=7ac59072144ca5c309625e52a74bfb433a408667;hb=9e6d9291275267d3fd4b6d85d7232081f89cd8e2;hp=fb2288d02db62c7f28c7909fd595c0db942917a3;hpb=6d4225a131ae1169717e6dd6e4c95ad4f49de64c;p=thirdparty%2Fmdadm.git diff --git a/monitor.c b/monitor.c index fb2288d0..7ac59072 100644 --- a/monitor.c +++ b/monitor.c @@ -219,6 +219,7 @@ static int read_and_act(struct active_array *a) int deactivate = 0; struct mdinfo *mdi; int dirty = 0; + int count = 0; a->next_state = bad_word; a->next_action = bad_action; @@ -311,7 +312,10 @@ static int read_and_act(struct active_array *a) mdi->curr_state); if (! (mdi->curr_state & DS_INSYNC)) check_degraded = 1; + count++; } + if (count != a->info.array.raid_disks) + check_degraded = 1; } if (!deactivate && @@ -421,6 +425,7 @@ static int read_and_act(struct active_array *a) if (remove_result > 0) { dprintf(" %d:removed", mdi->disk.raid_disk); close(mdi->state_fd); + close(mdi->recovery_fd); mdi->state_fd = -1; } } @@ -534,7 +539,7 @@ static int wait_and_act(struct supertype *container, int nowait) /* once an array has been deactivated we want to * ask the manager to discard it. */ - if (!a->container || (a->info.array.level == 0)) { + if (!a->container) { if (discard_this) { ap = &(*ap)->next; continue; @@ -562,7 +567,11 @@ static int wait_and_act(struct supertype *container, int nowait) * problem as there are no active arrays, there is * 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) { /* OK, we are safe to leave */ if (sigterm && !dirty_arrays) @@ -583,10 +592,18 @@ static int wait_and_act(struct supertype *container, int nowait) if (!nowait) { 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); sigdelset(&set, SIGUSR1); 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; if (rv == -1 && errno == EINTR) rv = 0;