Whamcloud - gitweb
Branch HEAD
authorfanyong <fanyong>
Thu, 29 Oct 2009 02:16:02 +0000 (02:16 +0000)
committerfanyong <fanyong>
Thu, 29 Oct 2009 02:16:02 +0000 (02:16 +0000)
b=21064
i=robert.read
i=rahul.deshmukh

1) do not wait service thread in "ptlrpc_stop_thread()" if it has stopped already.
2) give more debug information if service thread can not stop.

lustre/include/lustre_net.h
lustre/ptlrpc/service.c

index 5f5e840..2433ea8 100644 (file)
@@ -681,6 +681,10 @@ struct ptlrpc_thread {
          */
         unsigned int t_id;
         /**
+         * service thread pid
+         */
+        pid_t t_pid; 
+        /**
          * put watchdog in the structure per thread b=14840
          */
         struct lc_watchdog *t_watchdog;
index 44a6c00..94d4429 100644 (file)
@@ -1867,6 +1867,7 @@ static int ptlrpc_main(void *arg)
         int counter = 0, rc = 0;
         ENTRY;
 
+        thread->t_pid = cfs_curproc_pid();
         cfs_daemonize_ctxt(data->name);
 
 #if defined(HAVE_NODE_TO_CPUMASK) && defined(CONFIG_NUMA)
@@ -2019,7 +2020,8 @@ out_srv_fini:
 
         lu_context_fini(&env.le_ctx);
 out:
-        CDEBUG(D_NET, "service thread %d exiting: rc %d\n", thread->t_id, rc);
+        CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n",
+               thread, thread->t_pid, thread->t_id, rc);
 
         spin_lock(&svc->srv_lock);
         svc->srv_threads_running--; /* must know immediately */
@@ -2174,17 +2176,24 @@ static void ptlrpc_stop_thread(struct ptlrpc_service *svc,
                                struct ptlrpc_thread *thread)
 {
         struct l_wait_info lwi = { 0 };
+        int stopped = 0;
         ENTRY;
 
-        CDEBUG(D_RPCTRACE, "Stopping thread %p\n", thread);
         spin_lock(&svc->srv_lock);
-        /* let the thread know that we would like it to stop asap */
-        thread->t_flags |= SVC_STOPPING;
+        if (unlikely(thread->t_flags & SVC_STOPPED))
+                stopped = 1;
+        else
+                /* let the thread know that we would like it to stop asap */
+                thread->t_flags |= SVC_STOPPING;
         spin_unlock(&svc->srv_lock);
 
-        cfs_waitq_broadcast(&svc->srv_waitq);
-        l_wait_event(thread->t_ctl_waitq, (thread->t_flags & SVC_STOPPED),
-                     &lwi);
+        if (likely(!stopped)) {
+                CDEBUG(D_RPCTRACE, "Stopping thread [ %p : %u ]\n",
+                       thread, thread->t_pid);
+                cfs_waitq_broadcast(&svc->srv_waitq);
+                l_wait_event(thread->t_ctl_waitq,
+                             (thread->t_flags & SVC_STOPPED), &lwi);
+        }
 
         spin_lock(&svc->srv_lock);
         list_del(&thread->t_link);