Whamcloud - gitweb
LU-10467 ptlrpc: convert use of l_wait_event_exclusive_head()
[fs/lustre-release.git] / lustre / ptlrpc / service.c
index eb6057e..fefcb29 100644 (file)
@@ -1072,8 +1072,6 @@ void ptlrpc_request_change_export(struct ptlrpc_request *req,
        /* request takes one export refcount */
        req->rq_export = class_export_get(export);
        class_export_rpc_inc(export);
-
-       return;
 }
 
 /**
@@ -2296,7 +2294,7 @@ static int ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
               (request->rq_export ?
                (char *)request->rq_export->exp_client_uuid.uuid : "0"),
               (request->rq_export ?
-               atomic_read(&request->rq_export->exp_refcount) : -99),
+               refcount_read(&request->rq_export->exp_handle.h_ref) : -99),
               lustre_msg_get_status(request->rq_reqmsg), request->rq_xid,
               libcfs_id2str(request->rq_peer),
               lustre_msg_get_opc(request->rq_reqmsg),
@@ -2336,7 +2334,7 @@ put_conn:
               (request->rq_export ?
               (char *)request->rq_export->exp_client_uuid.uuid : "0"),
               (request->rq_export ?
-              atomic_read(&request->rq_export->exp_refcount) : -99),
+               refcount_read(&request->rq_export->exp_handle.h_ref) : -99),
               lustre_msg_get_status(request->rq_reqmsg),
               request->rq_xid,
               libcfs_id2str(request->rq_peer),
@@ -2556,14 +2554,6 @@ static void ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt)
        }
 }
 
-static int ptlrpc_retry_rqbds(void *arg)
-{
-       struct ptlrpc_service_part *svcpt = (struct ptlrpc_service_part *)arg;
-
-       svcpt->scp_rqbd_timeout = 0;
-       return -ETIMEDOUT;
-}
-
 static inline int ptlrpc_threads_enough(struct ptlrpc_service_part *svcpt)
 {
        return svcpt->scp_nreqs_active <
@@ -2707,20 +2697,28 @@ static __attribute__((__noinline__)) int
 ptlrpc_wait_event(struct ptlrpc_service_part *svcpt,
                  struct ptlrpc_thread *thread)
 {
-       /* Don't exit while there are replies to be handled */
-       struct l_wait_info lwi = LWI_TIMEOUT(svcpt->scp_rqbd_timeout,
-                                            ptlrpc_retry_rqbds, svcpt);
-
        ptlrpc_watchdog_disable(&thread->t_watchdog);
 
        cond_resched();
 
-       l_wait_event_exclusive_head(svcpt->scp_waitq,
-                               ptlrpc_thread_stopping(thread) ||
-                               ptlrpc_server_request_incoming(svcpt) ||
-                               ptlrpc_server_request_pending(svcpt, false) ||
-                               ptlrpc_rqbd_pending(svcpt) ||
-                               ptlrpc_at_check(svcpt), &lwi);
+       if (svcpt->scp_rqbd_timeout == 0)
+               /* Don't exit while there are replies to be handled */
+               wait_event_idle_exclusive_lifo(
+                       svcpt->scp_waitq,
+                       ptlrpc_thread_stopping(thread) ||
+                       ptlrpc_server_request_incoming(svcpt) ||
+                       ptlrpc_server_request_pending(svcpt, false) ||
+                       ptlrpc_rqbd_pending(svcpt) ||
+                       ptlrpc_at_check(svcpt));
+       else if (wait_event_idle_exclusive_lifo_timeout(
+                        svcpt->scp_waitq,
+                        ptlrpc_thread_stopping(thread) ||
+                        ptlrpc_server_request_incoming(svcpt) ||
+                        ptlrpc_server_request_pending(svcpt, false) ||
+                        ptlrpc_rqbd_pending(svcpt) ||
+                        ptlrpc_at_check(svcpt),
+                        svcpt->scp_rqbd_timeout) == 0)
+               svcpt->scp_rqbd_timeout = 0;
 
        if (ptlrpc_thread_stopping(thread))
                return -EINTR;
@@ -2851,6 +2849,9 @@ static int ptlrpc_main(void *arg)
 
                /* reset le_ses to initial state */
                env->le_ses = NULL;
+               /* Refill the context before execution to make sure
+                * all thread keys are allocated */
+               lu_env_refill(env);
                /* Process all incoming reqs before handling any */
                if (ptlrpc_server_request_incoming(svcpt)) {
                        lu_context_enter(&env->le_ctx);
@@ -3367,13 +3368,10 @@ void ptlrpc_hr_fini(void)
 static void ptlrpc_wait_replies(struct ptlrpc_service_part *svcpt)
 {
        while (1) {
-               int rc;
-               struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(10),
-                                                    NULL, NULL);
-
-               rc = l_wait_event(svcpt->scp_waitq,
-                    atomic_read(&svcpt->scp_nreps_difficult) == 0, &lwi);
-               if (rc == 0)
+               if (wait_event_idle_timeout(
+                       svcpt->scp_waitq,
+                       atomic_read(&svcpt->scp_nreps_difficult) == 0,
+                       cfs_time_seconds(10)) > 0)
                        break;
                CWARN("Unexpectedly long timeout %s %p\n",
                      svcpt->scp_service->srv_name, svcpt->scp_service);
@@ -3398,7 +3396,6 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc)
 {
        struct ptlrpc_service_part *svcpt;
        struct ptlrpc_request_buffer_desc *rqbd;
-       struct l_wait_info lwi;
        int rc;
        int i;
 
@@ -3436,18 +3433,21 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc)
                 */
                spin_lock(&svcpt->scp_lock);
                while (svcpt->scp_nrqbds_posted != 0) {
+                       int seconds = LONG_UNLINK;
+
                        spin_unlock(&svcpt->scp_lock);
                        /*
                         * Network access will complete in finite time but
                         * the HUGE timeout lets us CWARN for visibility
                         * of sluggish NALs
                         */
-                       lwi = LWI_TIMEOUT_INTERVAL(
-                                       cfs_time_seconds(LONG_UNLINK),
-                                       cfs_time_seconds(1), NULL, NULL);
-                       rc = l_wait_event(svcpt->scp_waitq,
-                                         svcpt->scp_nrqbds_posted == 0, &lwi);
-                       if (rc == -ETIMEDOUT) {
+                       while (seconds > 0 &&
+                              wait_event_idle_timeout(
+                                      svcpt->scp_waitq,
+                                      svcpt->scp_nrqbds_posted == 0,
+                                      cfs_time_seconds(1)) == 0)
+                               seconds -= 1;
+                       if (seconds == 0) {
                                CWARN("Service %s waiting for request buffers\n",
                                      svcpt->scp_service->srv_name);
                        }