From: Mr NeilBrown Date: Wed, 2 Oct 2019 02:19:01 +0000 (+1000) Subject: LU-10467 lustre: don't use l_wait_event() for simple sleep. X-Git-Tag: 2.13.51~182 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=077b35568be57f02c389b31553e17d5247d76897 LU-10467 lustre: don't use l_wait_event() for simple sleep. 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 Change-Id: I5a77e631c68f6dfb45fdd7ea01d60b13268240cc Reviewed-on: https://review.whamcloud.com/35966 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Petros Koutoupis Reviewed-by: Oleg Drokin --- diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index a8ca087..9629f4e 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -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); } diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 7abf85d..e7a7b77 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -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; } } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index e029696..b94cf99 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef HAVE_UIDGID_HEADER # include #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; } diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index e66858f..660a05c 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -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; } } diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index f80a2c7..3f51caa 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -35,6 +35,7 @@ #define DEBUG_SUBSYSTEM S_CLASS #include +#include #ifdef HAVE_UIDGID_HEADER # include #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); }