Whamcloud - gitweb
LU-2889 ptlrpc: Race between start and stop service threads
[fs/lustre-release.git] / lustre / ptlrpc / service.c
index 7e176c0..1dbdc88 100644 (file)
@@ -2865,11 +2865,19 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
                CERROR("cannot start thread '%s': rc %d\n",
                       thread->t_name, rc);
                spin_lock(&svcpt->scp_lock);
-               cfs_list_del(&thread->t_link);
                --svcpt->scp_nthrs_starting;
-               spin_unlock(&svcpt->scp_lock);
-
-                OBD_FREE(thread, sizeof(*thread));
+               if (thread_is_stopping(thread)) {
+                       /* this ptlrpc_thread is being hanled
+                        * by ptlrpc_svcpt_stop_threads now
+                        */
+                       thread_add_flags(thread, SVC_STOPPED);
+                       cfs_waitq_signal(&thread->t_ctl_waitq);
+                       spin_unlock(&svcpt->scp_lock);
+               } else {
+                       cfs_list_del(&thread->t_link);
+                       spin_unlock(&svcpt->scp_lock);
+                       OBD_FREE_PTR(thread);
+               }
                 RETURN(rc);
         }