···61static void autostart_arrays(int part);62#endif6364+/* pers_list is a list of registered personalities protected65+ * by pers_lock.66+ * pers_lock does extra service to protect accesses to67+ * mddev->thread when the mutex cannot be held.68+ */69static LIST_HEAD(pers_list);70static DEFINE_SPINLOCK(pers_lock);71···739 } else740 mutex_unlock(&mddev->reconfig_mutex);741742+ /* was we've dropped the mutex we need a spinlock to743+ * make sur the thread doesn't disappear744+ */745+ spin_lock(&pers_lock);746 md_wakeup_thread(mddev->thread);747+ spin_unlock(&pers_lock);748}749750static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr)···6429 return thread;6430}64316432+void md_unregister_thread(mdk_thread_t **threadp)6433{6434+ mdk_thread_t *thread = *threadp;6435 if (!thread)6436 return;6437 dprintk("interrupting MD-thread pid %d\n", task_pid_nr(thread->tsk));6438+ /* Locking ensures that mddev_unlock does not wake_up a6439+ * non-existent thread6440+ */6441+ spin_lock(&pers_lock);6442+ *threadp = NULL;6443+ spin_unlock(&pers_lock);64446445 kthread_stop(thread->tsk);6446 kfree(thread);···7340 mdk_rdev_t *rdev;73417342 /* resync has finished, collect result */7343+ md_unregister_thread(&mddev->sync_thread);07344 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&7345 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {7346 /* success...*/