if (unlikely(lfsck == NULL))
RETURN(-ENXIO);
- if (unlikely(lfsck->li_stopping))
- GOTO(put, rc = -ENXIO);
-
/* System is not ready, try again later. */
if (unlikely(lfsck->li_namespace == NULL ||
lfsck_dev_site(lfsck)->ss_server_fld == NULL))
GOTO(out, rc);
}
- wait_event_idle(thread->t_ctl_waitq,
- thread_is_running(thread) ||
- thread_is_stopped(thread));
+ wait_event_interruptible(thread->t_ctl_waitq,
+ thread_is_running(thread) ||
+ thread_is_stopped(thread));
if (start == NULL || !(start->ls_flags & LPF_BROADCAST)) {
lfsck->li_start_unplug = 1;
wake_up(&thread->t_ctl_waitq);
lfsck->li_start_unplug = 1;
wake_up(&thread->t_ctl_waitq);
- wait_event_idle(thread->t_ctl_waitq,
- thread_is_stopped(thread));
+ wait_event_interruptible(thread->t_ctl_waitq,
+ thread_is_stopped(thread));
}
} else {
lfsck->li_start_unplug = 1;
int rc1 = 0;
ENTRY;
+ LASSERT(stop);
lfsck = lfsck_instance_find(key, true, false);
if (unlikely(lfsck == NULL))
RETURN(-ENXIO);
thread = &lfsck->li_thread;
- if (stop && stop->ls_flags & LPF_BROADCAST && !lfsck->li_master) {
+ if ((stop->ls_flags & LPF_BROADCAST) && !lfsck->li_master) {
CERROR("%s: only allow to specify '-A' via MDS\n",
lfsck_lfsck2name(lfsck));
GOTO(put, rc = -EPERM);
}
spin_lock(&lfsck->li_lock);
- /* The target is umounted */
- if (stop && stop->ls_status == LS_PAUSED)
- lfsck->li_stopping = 1;
-
- if (thread_is_init(thread) || thread_is_stopped(thread))
- /* no error if LFSCK stopped already, or not started */
+ if (thread_is_init(thread) || thread_is_stopped(thread) ||
+ thread_is_stopping(thread))
+ /* no error if LFSCK is stopped, or not started */
GOTO(unlock, rc = 0);
- if (thread_is_stopping(thread) && stop->ls_status != LS_PAUSED)
- /* Someone is stopping LFSCK and it is not umount. */
- GOTO(unlock, rc = -EINPROGRESS);
-
- if (stop) {
- lfsck->li_status = stop->ls_status;
- lfsck->li_flags = stop->ls_flags;
- } else {
- lfsck->li_status = LS_STOPPED;
- lfsck->li_flags = 0;
- }
+ lfsck->li_status = stop->ls_status;
+ lfsck->li_flags = stop->ls_flags;
thread_set_flags(thread, SVC_STOPPING);
}
wake_up(&thread->t_ctl_waitq);
+ EXIT;
+unlock:
spin_unlock(&lfsck->li_lock);
- if (stop && stop->ls_flags & LPF_BROADCAST)
- rc1 = lfsck_stop_all(env, lfsck, stop);
-
- /* It was me set the status as 'stopping' just now, if it is not
- * 'stopping' now, then either stopped, or re-started by race.
- */
- wait_event_idle(thread->t_ctl_waitq,
- !thread_is_stopping(thread));
- GOTO(put, rc = 0);
+ if (stop->ls_flags & LPF_BROADCAST)
+ rc1 = lfsck_stop_all(env, lfsck, stop);
-unlock:
- spin_unlock(&lfsck->li_lock);
+ wait_event_interruptible(thread->t_ctl_waitq,
+ !thread_is_stopping(thread));
put:
lfsck_instance_put(env, lfsck);