staging: lustre: remove back_to_sleep()
authorNeilBrown <neilb@suse.com>
Mon, 12 Feb 2018 23:47:59 +0000 (10:47 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2018 14:19:11 +0000 (15:19 +0100)
When 'back_to_sleep()' is passed as the 'timeout' function,
the effect is to wait indefinitely for the event, polling
once after the timeout.
If LWI_ON_SIGNAL_NOOP is given, then after the timeout
we allow fatal signals to interrupt the wait.

Make this more obvious in both places "back_to_sleep()" is
used but using two explicit sleeps.

The code in ptlrpcd_add_req() looks odd - why not just have one
wait_event_idle()?  However I believe this is a faithful
transformation of the existing code.

Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre_lib.h
drivers/staging/lustre/lustre/ptlrpc/import.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c

index b2a64d0e682c41ae43417f43d0c07316c15fee72..1939e959b92acc7e900ca094b59cee06617a2428 100644 (file)
@@ -140,10 +140,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
  * XXX nikita: some ptlrpc daemon threads have races of that sort.
  *
  */
-static inline int back_to_sleep(void *arg)
-{
-       return 0;
-}
 
 #define LWI_ON_SIGNAL_NOOP ((void (*)(void *))(-1))
 
index 5d62c9de27ebeb1a692caf24f396e50b85efa0f3..faf0f606f013c5656147ad1f093ac6109afb4610 100644 (file)
@@ -1496,7 +1496,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
        }
 
        if (ptlrpc_import_in_recovery(imp)) {
-               struct l_wait_info lwi;
                long timeout;
 
                if (AT_OFF) {
@@ -1510,10 +1509,12 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
                        timeout = at_get(&imp->imp_at.iat_service_estimate[idx]) * HZ;
                }
 
-               lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout),
-                                      back_to_sleep, LWI_ON_SIGNAL_NOOP, NULL);
-               rc = l_wait_event(imp->imp_recovery_waitq,
-                                 !ptlrpc_import_in_recovery(imp), &lwi);
+               if (wait_event_idle_timeout(imp->imp_recovery_waitq,
+                                           !ptlrpc_import_in_recovery(imp),
+                                           cfs_timeout_cap(timeout)) == 0)
+                       l_wait_event_abortable(
+                               imp->imp_recovery_waitq,
+                               !ptlrpc_import_in_recovery(imp));
        }
 
        spin_lock(&imp->imp_lock);
index dad2f9290f700d56cf0974eb51612c52e37765d3..437b4b2a9072d63d18a1be1672f78c8dc8eb0a00 100644 (file)
@@ -230,12 +230,13 @@ void ptlrpcd_add_req(struct ptlrpc_request *req)
 
        spin_lock(&req->rq_lock);
        if (req->rq_invalid_rqset) {
-               struct l_wait_info lwi = LWI_TIMEOUT(5 * HZ,
-                                                    back_to_sleep, NULL);
-
                req->rq_invalid_rqset = 0;
                spin_unlock(&req->rq_lock);
-               l_wait_event(req->rq_set_waitq, !req->rq_set, &lwi);
+               if (wait_event_idle_timeout(req->rq_set_waitq,
+                                           !req->rq_set,
+                                           5 * HZ) == 0)
+                       wait_event_idle(req->rq_set_waitq,
+                                       !req->rq_set);
        } else if (req->rq_set) {
                /* If we have a valid "rq_set", just reuse it to avoid double
                 * linked.