/** * Start parent FID verification thread. * * See ofd_inconsistency_verification_main(). * * \param[in] ofd OFD device * * \retval 0 on successful start of thread * \retval negative value on error */ int ofd_start_inconsistency_verification_thread(struct ofd_device *ofd) { struct ptlrpc_thread *thread = &ofd->ofd_inconsistency_thread; struct l_wait_info lwi = { 0 }; struct task_struct *task; int rc; spin_lock(&ofd->ofd_inconsistency_lock); if (unlikely(thread_is_running(thread))) { spin_unlock(&ofd->ofd_inconsistency_lock); return -EALREADY; } thread_set_flags(thread, 0); spin_unlock(&ofd->ofd_inconsistency_lock); task = kthread_run(ofd_inconsistency_verification_main, ofd, "inconsistency_verification"); if (IS_ERR(task)) { rc = PTR_ERR(task); CERROR("%s: cannot start self_repair thread: rc = %d\n", ofd_name(ofd), rc); } else { rc = 0; l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); } return rc; }
void mdt_ck_thread_stop(struct mdt_device *mdt) { struct ptlrpc_thread *thread = &mdt->mdt_ck_thread; if (!thread_is_running(thread)) return; thread_set_flags(thread, SVC_STOPPING); wake_up(&thread->t_ctl_waitq); l_wait_condition(thread->t_ctl_waitq, thread_is_stopped(thread)); }
/** * Stop parent FID verification thread. * * \param[in] ofd OFD device * * \retval 0 on successful start of thread * \retval -EALREADY if thread is already stopped */ int ofd_stop_inconsistency_verification_thread(struct ofd_device *ofd) { struct ptlrpc_thread *thread = &ofd->ofd_inconsistency_thread; struct l_wait_info lwi = { 0 }; spin_lock(&ofd->ofd_inconsistency_lock); if (thread_is_init(thread) || thread_is_stopped(thread)) { spin_unlock(&ofd->ofd_inconsistency_lock); return -EALREADY; } thread_set_flags(thread, SVC_STOPPING); spin_unlock(&ofd->ofd_inconsistency_lock); wake_up_all(&thread->t_ctl_waitq); l_wait_event(thread->t_ctl_waitq, thread_is_stopped(thread), &lwi); return 0; }