Whamcloud - gitweb
b=17682 limit performance impact of rpctrace, dlmtrace & quota
[fs/lustre-release.git] / lustre / ptlrpc / service.c
index 94d4429..4818e7a 100644 (file)
@@ -774,8 +774,8 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay)
                         exp->exp_obd->obd_eviction_timer =
                                 cfs_time_current_sec() + 3 * PING_INTERVAL;
                         CDEBUG(D_HA, "%s: Think about evicting %s from "CFS_TIME_T"\n",
-                               exp->exp_obd->obd_name, obd_export_nid2str(exp),
-                               oldest_time);
+                               exp->exp_obd->obd_name, 
+                               obd_export_nid2str(oldest_exp), oldest_time);
                 }
         } else {
                 if (cfs_time_current_sec() >
@@ -1575,16 +1575,6 @@ ptlrpc_server_handle_request(struct ptlrpc_service *svc,
 
         ptlrpc_rqphase_move(request, RQ_PHASE_COMPLETE);
 
-        CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc "
-               "%s:%s+%d:%d:x"LPU64":%s:%d\n", cfs_curproc_comm(),
-               (request->rq_export ?
-                (char *)request->rq_export->exp_client_uuid.uuid : "0"),
-               (request->rq_export ?
-                atomic_read(&request->rq_export->exp_refcount) : -99),
-               lustre_msg_get_status(request->rq_reqmsg), request->rq_xid,
-               libcfs_id2str(request->rq_peer),
-               lustre_msg_get_opc(request->rq_reqmsg));
-
 put_rpc_export:
         if (export != NULL)
                 class_export_rpc_put(export);
@@ -1604,15 +1594,26 @@ put_conn:
 
         do_gettimeofday(&work_end);
         timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
-        CDEBUG(D_RPCTRACE, "request x"LPU64" opc %u from %s processed in "
-               "%ldus (%ldus total) trans "LPU64" rc %d/%d\n",
-               request->rq_xid, lustre_msg_get_opc(request->rq_reqmsg),
-               libcfs_id2str(request->rq_peer), timediff,
-               cfs_timeval_sub(&work_end, &request->rq_arrival_time, NULL),
-               request->rq_repmsg ? lustre_msg_get_transno(request->rq_repmsg) :
-               request->rq_transno, request->rq_status,
-               request->rq_repmsg ? lustre_msg_get_status(request->rq_repmsg):
-               -999);
+        CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc "
+               "%s:%s+%d:%d:x"LPU64":%s:%d Request procesed in "
+               "%lds (%lds total) trans "LPU64" rc %d/%d\n",
+                cfs_curproc_comm(),
+                (request->rq_export ?
+                 (char *)request->rq_export->exp_client_uuid.uuid : "0"),
+                (request->rq_export ?
+                 atomic_read(&request->rq_export->exp_refcount) : -99),
+                lustre_msg_get_status(request->rq_reqmsg),
+                request->rq_xid,
+                libcfs_id2str(request->rq_peer),
+                lustre_msg_get_opc(request->rq_reqmsg),
+                timediff,
+                cfs_timeval_sub(&work_end, &request->rq_arrival_time, NULL),
+                (request->rq_repmsg ?
+                 lustre_msg_get_transno(request->rq_repmsg) :
+                 request->rq_transno),
+                request->rq_status,
+                (request->rq_repmsg ?
+                 lustre_msg_get_status(request->rq_repmsg) : -999));
         if (likely(svc->srv_stats != NULL && request->rq_reqmsg != NULL)) {
                 __u32 op = lustre_msg_get_opc(request->rq_reqmsg);
                 int opc = opcode_offset(op);
@@ -1947,7 +1948,7 @@ static int ptlrpc_main(void *arg)
 
         /* XXX maintain a list of all managed devices: insert here */
 
-        while ((thread->t_flags & SVC_STOPPING) == 0) {
+        while (!(thread->t_flags & SVC_STOPPING) && !svc->srv_is_stopping) {
                 /* Don't exit while there are replies to be handled */
                 struct l_wait_info lwi = LWI_TIMEOUT(svc->srv_rqbd_timeout,
                                                      ptlrpc_retry_rqbds, svc);
@@ -1957,7 +1958,8 @@ static int ptlrpc_main(void *arg)
                 cond_resched();
 
                 l_wait_event_exclusive (svc->srv_waitq,
-                              ((thread->t_flags & SVC_STOPPING) != 0) ||
+                              thread->t_flags & SVC_STOPPING ||
+                              svc->srv_is_stopping ||
                               (!list_empty(&svc->srv_idle_rqbds) &&
                                svc->srv_rqbd_timeout == 0) ||
                               !list_empty(&svc->srv_req_in_queue) ||
@@ -1967,15 +1969,17 @@ static int ptlrpc_main(void *arg)
                               svc->srv_at_check,
                               &lwi);
 
+                if (thread->t_flags & SVC_STOPPING || svc->srv_is_stopping)
+                        break;
+
                 lc_watchdog_touch(thread->t_watchdog, GET_TIMEOUT(svc));
 
                 ptlrpc_check_rqbd_pool(svc);
 
-                if ((svc->srv_threads_started < svc->srv_threads_max) &&
-                    (svc->srv_n_active_reqs >= (svc->srv_threads_started - 1))){
+                if (svc->srv_threads_started < svc->srv_threads_max &&
+                    svc->srv_n_active_reqs >= (svc->srv_threads_started - 1)) 
                         /* Ignore return code - we tried... */
                         ptlrpc_start_thread(dev, svc);
-                }
 
                 if (!list_empty(&svc->srv_req_in_queue)) {
                         /* Process all incoming reqs before handling any */
@@ -2176,24 +2180,19 @@ 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 : %u ]\n",
+               thread, thread->t_pid);
+
         spin_lock(&svc->srv_lock);
-        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;
+        /* let the thread know that we would like it to stop asap */
+        thread->t_flags |= SVC_STOPPING;
         spin_unlock(&svc->srv_lock);
 
-        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);
-        }
+        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);
@@ -2239,6 +2238,7 @@ int ptlrpc_start_threads(struct obd_device *dev, struct ptlrpc_service *svc)
                         CERROR("cannot start %s thread #%d: rc %d\n",
                                svc->srv_thread_name, i, rc);
                         ptlrpc_stop_all_threads(svc);
+                        break;
                 }
         }
         RETURN(rc);
@@ -2256,6 +2256,10 @@ int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc)
         CDEBUG(D_RPCTRACE, "%s started %d min %d max %d running %d\n",
                svc->srv_name, svc->srv_threads_started, svc->srv_threads_min,
                svc->srv_threads_max, svc->srv_threads_running);
+
+        if (unlikely(svc->srv_is_stopping))
+                RETURN(-ESRCH);
+
         if (unlikely(svc->srv_threads_started >= svc->srv_threads_max) ||
             (OBD_FAIL_CHECK(OBD_FAIL_TGT_TOOMANY_THREADS) &&
              svc->srv_threads_started == svc->srv_threads_min - 1))