Whamcloud - gitweb
LU-10467 lustre: don't use l_wait_event() for simple sleep. 66/35966/6
authorMr NeilBrown <neilb@suse.com>
Wed, 2 Oct 2019 02:19:01 +0000 (12:19 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 6 Dec 2019 00:57:56 +0000 (00:57 +0000)
Passing '0' as the condition to l_wait_event() means that
it just waits for the given timeout.
This can be done more simply with ssleep(seconds) or in
one case, a schedule_timeout_killable() loop.

In most of these case, l_wait_event() in configured to ignore signals,
so ssleep() - which also ignores signals - is appropriate.
In one case (lfsck_lib.c) l_wait_event() is configured to respond
to fatal signals, and as there is no ssleep_killable, we
need to opencode one.

ssleep() and schedule_timeout_killable() *will* add to the load
average, while l_wait_event() does not, so if these sleeps happen a
lot, it will add to the load average.  I don't think that will be a
problem for these sleeps.

So remove these l_wait_event() calls and associated variables,
and do it the simpler ways.

Signed-off-by: Mr NeilBrown <neilb@suse.com>
Change-Id: I5a77e631c68f6dfb45fdd7ea01d60b13268240cc
Reviewed-on: https://review.whamcloud.com/35966
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/fid/fid_request.c
lustre/lfsck/lfsck_lib.c
lustre/mdc/mdc_request.c
lustre/ptlrpc/events.c
lustre/target/tgt_handler.c

index a8ca087..9629f4e 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/delay.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
@@ -196,17 +197,11 @@ static int seq_client_alloc_meta(const struct lu_env *env,
                         * (MDT0)yet */
                        rc = seq_client_rpc(seq, &seq->lcs_space,
                                            SEQ_ALLOC_META, "meta");
-                       if (rc == -EINPROGRESS || rc == -EAGAIN) {
-                               wait_queue_head_t waitq;
-                               struct l_wait_info  lwi;
-
+                       if (rc == -EINPROGRESS || rc == -EAGAIN)
                                /* MDT0 is not ready, let's wait for 2
                                 * seconds and retry. */
-                               init_waitqueue_head(&waitq);
-                               lwi = LWI_TIMEOUT(cfs_time_seconds(2), NULL,
-                                                 NULL);
-                               l_wait_event(waitq, 0, &lwi);
-                       }
+                               ssleep(2);
+
                } while (rc == -EINPROGRESS || rc == -EAGAIN);
        }
 
index 7abf85d..e7a7b77 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/kthread.h>
 #include <linux/sched.h>
 #include <linux/list.h>
+#include <linux/delay.h>
 #include <lu_object.h>
 #include <dt_object.h>
 #include <md_object.h>
@@ -3627,17 +3628,16 @@ again:
                            que->lu_mdts_count[i][LS_SCANNING_PHASE2] != 0 ||
                            que->lu_osts_count[i][LS_SCANNING_PHASE1] != 0 ||
                            que->lu_osts_count[i][LS_SCANNING_PHASE2] != 0) {
-                               struct l_wait_info lwi;
-
                                /* If it is required to wait, then sleep
-                                * 3 seconds and try to query again. */
-                               lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(3),
-                                                      NULL,
-                                                      LWI_ON_SIGNAL_NOOP,
-                                                      NULL);
-                               rc = l_wait_event(lfsck->li_thread.t_ctl_waitq,
-                                                 0, &lwi);
-                               if (rc == -ETIMEDOUT)
+                                * 3 seconds and try to query again.
+                                */
+                               unsigned long timeout =
+                                       msecs_to_jiffies(3000) + 1;
+                               while (timeout &&
+                                      !fatal_signal_pending(current))
+                                       timeout = schedule_timeout_killable(
+                                               timeout);
+                               if (timeout == 0)
                                        goto again;
                        }
                }
index e029696..b94cf99 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/pagemap.h>
 #include <linux/user_namespace.h>
 #include <linux/utsname.h>
+#include <linux/delay.h>
 #ifdef HAVE_UIDGID_HEADER
 # include <linux/uidgid.h>
 #endif
@@ -1035,14 +1036,11 @@ static int mdc_getpage(struct obd_export *exp, const struct lu_fid *fid,
        struct ptlrpc_request   *req;
        struct ptlrpc_bulk_desc *desc;
        int                      i;
-       wait_queue_head_t        waitq;
        int                      resends = 0;
-       struct l_wait_info       lwi;
        int                      rc;
        ENTRY;
 
        *request = NULL;
-       init_waitqueue_head(&waitq);
 
 restart_bulk:
        req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE);
@@ -1087,9 +1085,7 @@ restart_bulk:
                               exp->exp_obd->obd_name, -EIO);
                        RETURN(-EIO);
                }
-               lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL,
-                                      NULL);
-               l_wait_event(waitq, 0, &lwi);
+               ssleep(resends);
 
                goto restart_bulk;
        }
index e66858f..660a05c 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <libcfs/libcfs.h>
 #include <linux/kernel.h>
+#include <linux/delay.h>
 #include <obd_class.h>
 #include <lustre_net.h>
 #include <lustre_sec.h>
@@ -546,8 +547,6 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
 
 void ptlrpc_ni_fini(void)
 {
-       wait_queue_head_t         waitq;
-       struct l_wait_info  lwi;
        int                 rc;
        int                 retries;
 
@@ -571,9 +570,7 @@ void ptlrpc_ni_fini(void)
                                CWARN("Event queue still busy\n");
 
                        /* Wait for a bit */
-                       init_waitqueue_head(&waitq);
-                       lwi = LWI_TIMEOUT(cfs_time_seconds(2), NULL, NULL);
-                       l_wait_event(waitq, 0, &lwi);
+                       ssleep(2);
                        break;
                }
        }
index f80a2c7..3f51caa 100644 (file)
@@ -35,6 +35,7 @@
 #define DEBUG_SUBSYSTEM S_CLASS
 
 #include <linux/user_namespace.h>
+#include <linux/delay.h>
 #ifdef HAVE_UIDGID_HEADER
 # include <linux/uidgid.h>
 #endif
@@ -2381,14 +2382,9 @@ out_lock:
         * to reorder. */
        if (unlikely(CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CLIENT_BULK_CB2)) &&
            desc) {
-               wait_queue_head_t        waitq;
-               struct l_wait_info       lwi1;
-
                CDEBUG(D_INFO, "reorder BULK\n");
-               init_waitqueue_head(&waitq);
 
-               lwi1 = LWI_TIMEOUT_INTR(cfs_time_seconds(3), NULL, NULL, NULL);
-               l_wait_event(waitq, 0, &lwi1);
+               ssleep(3);
                target_bulk_io(exp, desc);
                ptlrpc_free_bulk(desc);
        }