From a7ff5d050ee7db0e80baac5fb3848ffcfa04dea6 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 2 Jan 2020 19:30:32 -0500 Subject: [PATCH] LU-10467 lustre: use wait_event_idle_timeout() as appropriate. If l_wait_event() is passed an lwi initialised with one of LWI_TIMEOUT_INTR( time, NULL, NULL, NULL) LWI_TIMEOUT_INTR( time, NULL, LWI_ON_SIGNAL_NOOP, NULL) LWI_TIMEOUT( time, NULL, NULL) where time != 0, then it behaves much like wait_event_idle_timeout(). All signals are blocked, and it waits either for the condition to be true, or for the timeout (in jiffies). Note that LWI_ON_SIGNAL_NOOP has no effect here. l_wait_event() returns 0 when the condition is true, or -ETIMEDOUT when the timeout occurs. wait_event_idle_timeout() instead returns a positive number when the condition is true, and 0 when the timeout occurs. So in the cases where return value is used, handling needs to be adjusted accordingly. Note that in some cases where cfs_fail_val gives the time to wait for, the current code re-tests the wait time against zero as cfs_fail_val can change asynchronously. This is because l_wait_event() behaves quite differently if the timeout is zero. The new code doesn't need to do that as wait_event_idle_timeout() treat 0 just as a very short wait, which is exactly the correct behavior here. This patch also removes a comment which is no longer meaningful (CAN_MATCH) and corrects a debug message which reported the wait time as "seconds" rather than the correct "jiffies". This patch doesn't change the timed wait in cl_sync_io_wait(). That is a bit more complicated, so it left to a separate patch. Change-Id: I632afc290935e321926f45b144d5367799a01381 Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/35977 Tested-by: jenkins Reviewed-by: Shaun Tancheff Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_lock.c | 10 ++++---- lustre/lfsck/lfsck_layout.c | 52 ++++++++++++++++-------------------------- lustre/lfsck/lfsck_lib.c | 20 +++++----------- lustre/llite/statahead.c | 15 +++++------- lustre/mgc/mgc_request.c | 19 ++++++++------- lustre/osc/osc_cache.c | 26 +++++++++++---------- lustre/osd-ldiskfs/osd_scrub.c | 16 +++++-------- lustre/osd-zfs/osd_scrub.c | 18 +++++++-------- lustre/osp/osp_sync.c | 11 ++++----- lustre/ptlrpc/import.c | 11 +++++---- lustre/ptlrpc/pack_generic.c | 9 ++++---- lustre/ptlrpc/recover.c | 13 +++++++---- lustre/ptlrpc/service.c | 11 ++++----- lustre/quota/qsd_handler.c | 15 ++++++------ lustre/quota/qsd_writeback.c | 10 ++++---- lustre/target/barrier.c | 12 ++++------ 16 files changed, 119 insertions(+), 149 deletions(-) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 2de1815..8af3366 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1460,7 +1460,6 @@ enum ldlm_mode ldlm_lock_match_with_skip(struct ldlm_namespace *ns, (!ldlm_is_lvb_ready(lock))) { __u64 wait_flags = LDLM_FL_LVB_READY | LDLM_FL_DESTROYED | LDLM_FL_FAIL_NOTIFIED; - struct l_wait_info lwi; if (lock->l_completion_ast) { int err = lock->l_completion_ast(lock, @@ -1470,12 +1469,11 @@ enum ldlm_mode ldlm_lock_match_with_skip(struct ldlm_namespace *ns, GOTO(out_fail_match, matched = 0); } - lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(obd_timeout), - NULL, LWI_ON_SIGNAL_NOOP, NULL); + wait_event_idle_timeout( + lock->l_waitq, + lock->l_flags & wait_flags, + cfs_time_seconds(obd_timeout)); - /* XXX FIXME see comment on CAN_MATCH in lustre_dlm.h */ - l_wait_event(lock->l_waitq, lock->l_flags & wait_flags, - &lwi); if (!ldlm_is_lvb_ready(lock)) GOTO(out_fail_match, matched = 0); } diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index 2bd58b0..6a1a5b0 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -1391,23 +1391,15 @@ lfsck_layout_lastid_load(const struct lu_env *env, if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_DELAY4) && cfs_fail_val > 0) { - struct l_wait_info lwi = LWI_TIMEOUT( - cfs_time_seconds(cfs_fail_val), - NULL, NULL); - - /* Some others may changed the cfs_fail_val - * as zero after above check, re-check it for - * sure to avoid falling into wait for ever. */ - if (likely(lwi.lwi_timeout > 0)) { - struct ptlrpc_thread *thread = - &lfsck->li_thread; - - up_write(&com->lc_sem); - l_wait_event(thread->t_ctl_waitq, - !thread_is_running(thread), - &lwi); - down_write(&com->lc_sem); - } + struct ptlrpc_thread *thread = + &lfsck->li_thread; + + up_write(&com->lc_sem); + wait_event_idle_timeout( + thread->t_ctl_waitq, + !thread_is_running(thread), + cfs_time_seconds(cfs_fail_val)); + down_write(&com->lc_sem); } } @@ -5748,13 +5740,11 @@ static int lfsck_layout_slave_exec_oit(const struct lu_env *env, if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_DELAY5) && cfs_fail_val == lfsck_dev_idx(lfsck)) { - struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(1), - NULL, NULL); struct ptlrpc_thread *thread = &lfsck->li_thread; - l_wait_event(thread->t_ctl_waitq, - !thread_is_running(thread), - &lwi); + wait_event_idle_timeout(thread->t_ctl_waitq, + !thread_is_running(thread), + cfs_time_seconds(1)); } lfsck_rbtree_update_bitmap(env, com, fid, false); @@ -6205,9 +6195,6 @@ static int lfsck_layout_slave_double_scan(const struct lu_env *env, LFSCK_CHECKPOINT_INTERVAL; while (1) { - struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(30), - NULL, NULL); - rc = lfsck_layout_slave_query_master(env, com); if (list_empty(&llsd->llsd_master_list)) { if (unlikely(!thread_is_running(thread))) @@ -6221,21 +6208,22 @@ static int lfsck_layout_slave_double_scan(const struct lu_env *env, if (rc < 0) GOTO(done, rc); - rc = l_wait_event(thread->t_ctl_waitq, - !thread_is_running(thread) || - lo->ll_flags & LF_INCOMPLETE || - list_empty(&llsd->llsd_master_list), - &lwi); + rc = wait_event_idle_timeout( + thread->t_ctl_waitq, + !thread_is_running(thread) || + lo->ll_flags & LF_INCOMPLETE || + list_empty(&llsd->llsd_master_list), + cfs_time_seconds(30)); if (unlikely(!thread_is_running(thread))) GOTO(done, rc = 0); if (lo->ll_flags & LF_INCOMPLETE) GOTO(done, rc = 1); - if (rc == -ETIMEDOUT) + if (rc == 0) continue; - GOTO(done, rc = (rc < 0 ? rc : 1)); + GOTO(done, rc = 1); } done: diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 6b5d58e..f0be125 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -1895,16 +1895,12 @@ bool __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit) void lfsck_control_speed(struct lfsck_instance *lfsck) { struct ptlrpc_thread *thread = &lfsck->li_thread; - struct l_wait_info lwi; if (lfsck->li_sleep_jif > 0 && lfsck->li_new_scanned >= lfsck->li_sleep_rate) { - lwi = LWI_TIMEOUT_INTR(lfsck->li_sleep_jif, NULL, - LWI_ON_SIGNAL_NOOP, NULL); - - l_wait_event(thread->t_ctl_waitq, - !thread_is_running(thread), - &lwi); + wait_event_idle_timeout(thread->t_ctl_waitq, + !thread_is_running(thread), + lfsck->li_sleep_jif); lfsck->li_new_scanned = 0; } } @@ -1913,16 +1909,12 @@ void lfsck_control_speed_by_self(struct lfsck_component *com) { struct lfsck_instance *lfsck = com->lc_lfsck; struct ptlrpc_thread *thread = &lfsck->li_thread; - struct l_wait_info lwi; if (lfsck->li_sleep_jif > 0 && com->lc_new_scanned >= lfsck->li_sleep_rate) { - lwi = LWI_TIMEOUT_INTR(lfsck->li_sleep_jif, NULL, - LWI_ON_SIGNAL_NOOP, NULL); - - l_wait_event(thread->t_ctl_waitq, - !thread_is_running(thread), - &lwi); + wait_event_idle_timeout(thread->t_ctl_waitq, + !thread_is_running(thread), + lfsck->li_sleep_jif); com->lc_new_scanned = 0; } } diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 9ab4854..d1f114e 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -985,7 +985,6 @@ static int ll_statahead_thread(void *arg) int first = 0; struct md_op_data *op_data; struct ll_dir_chain chain; - struct l_wait_info lwi = { 0 }; struct page *page = NULL; __u64 pos = 0; int rc = 0; @@ -1182,9 +1181,9 @@ out: * safely because statahead RPC will access sai data */ while (sai->sai_sent != sai->sai_replied) { /* in case we're not woken up, timeout wait */ - lwi = LWI_TIMEOUT(cfs_time_seconds(1) >> 3, NULL, NULL); - l_wait_event(sa_thread->t_ctl_waitq, - sai->sai_sent == sai->sai_replied, &lwi); + wait_event_idle_timeout(sa_thread->t_ctl_waitq, + sai->sai_sent == sai->sai_replied, + cfs_time_seconds(1) >> 3); } /* release resources held by statahead RPCs */ @@ -1410,7 +1409,6 @@ static int revalidate_statahead_dentry(struct inode *dir, bool unplug) { struct sa_entry *entry = NULL; - struct l_wait_info lwi = { 0 }; struct ll_dentry_data *ldd; struct ll_inode_info *lli = ll_i2info(dir); int rc = 0; @@ -1458,10 +1456,9 @@ static int revalidate_statahead_dentry(struct inode *dir, spin_lock(&lli->lli_sa_lock); sai->sai_index_wait = entry->se_index; spin_unlock(&lli->lli_sa_lock); - lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(30), NULL, - LWI_ON_SIGNAL_NOOP, NULL); - rc = l_wait_event(sai->sai_waitq, sa_ready(entry), &lwi); - if (rc < 0) { + rc = wait_event_idle_timeout(sai->sai_waitq, sa_ready(entry), + cfs_time_seconds(30)); + if (rc == 0) { /* * entry may not be ready, so it may be used by inflight * statahead RPC, don't free it. diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 08f1c8c..943ee3a 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -629,7 +629,6 @@ static int mgc_requeue_thread(void *data) spin_lock(&config_list_lock); rq_state |= RQ_RUNNING; while (!(rq_state & RQ_STOP)) { - struct l_wait_info lwi; struct config_llog_data *cld, *cld_prev; int rand = prandom_u32_max(MGC_TIMEOUT_RAND_CENTISEC); int to; @@ -644,13 +643,14 @@ static int mgc_requeue_thread(void *data) } /* Always wait a few seconds to allow the server who - caused the lock revocation to finish its setup, plus some - random so everyone doesn't try to reconnect at once. */ + * caused the lock revocation to finish its setup, plus some + * random so everyone doesn't try to reconnect at once. + */ to = cfs_time_seconds(MGC_TIMEOUT_MIN_SECONDS * 100 + rand); /* rand is centi-seconds */ - lwi = LWI_TIMEOUT(to / 100, NULL, NULL); - l_wait_event(rq_waitq, rq_state & (RQ_STOP | RQ_PRECLEANUP), - &lwi); + wait_event_idle_timeout(rq_waitq, + rq_state & (RQ_STOP | RQ_PRECLEANUP), + to/100); /* * iterate & processing through the list. for each cld, process @@ -2084,7 +2084,6 @@ restart: if (rcl == -ESHUTDOWN && atomic_read(&mgc->u.cli.cl_mgc_refcount) > 0 && !retry) { struct obd_import *imp; - struct l_wait_info lwi; long timeout = cfs_time_seconds(obd_timeout); mutex_unlock(&cld->cld_lock); @@ -2098,9 +2097,9 @@ restart: * FULL or closed */ ptlrpc_pinger_force(imp); - lwi = LWI_TIMEOUT(timeout, NULL, NULL); - l_wait_event(imp->imp_recovery_waitq, - !mgc_import_in_recovery(imp), &lwi); + wait_event_idle_timeout(imp->imp_recovery_waitq, + !mgc_import_in_recovery(imp), + timeout); if (imp->imp_state == LUSTRE_IMP_FULL) { retry = true; diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 05f0c61..ff0652f 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -932,8 +932,6 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, enum osc_extent_state state) { struct osc_object *obj = ext->oe_obj; - struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(600), NULL, - LWI_ON_SIGNAL_NOOP, NULL); int rc = 0; ENTRY; @@ -955,17 +953,19 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, osc_extent_release(env, ext); /* wait for the extent until its state becomes @state */ - rc = l_wait_event(ext->oe_waitq, extent_wait_cb(ext, state), &lwi); - if (rc == -ETIMEDOUT) { + rc = wait_event_idle_timeout(ext->oe_waitq, extent_wait_cb(ext, state), + cfs_time_seconds(600)); + if (rc == 0) { OSC_EXTENT_DUMP(D_ERROR, ext, "%s: wait ext to %u timedout, recovery in progress?\n", cli_name(osc_cli(obj)), state); wait_event_idle(ext->oe_waitq, extent_wait_cb(ext, state)); - rc = 0; } - if (rc == 0 && ext->oe_rc < 0) + if (ext->oe_rc < 0) rc = ext->oe_rc; + else + rc = 0; RETURN(rc); } @@ -1586,13 +1586,9 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, struct osc_object *osc = oap->oap_obj; struct lov_oinfo *loi = osc->oo_oinfo; struct osc_cache_waiter ocw; - struct l_wait_info lwi; int rc = -EDQUOT; ENTRY; - lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(AT_OFF ? obd_timeout : at_max), - NULL, LWI_ON_SIGNAL_NOOP, NULL); - OSC_DUMP_GRANT(D_CACHE, cli, "need:%d\n", bytes); spin_lock(&cli->cl_loi_list_lock); @@ -1632,13 +1628,19 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, CDEBUG(D_CACHE, "%s: sleeping for cache space @ %p for %p\n", cli_name(cli), &ocw, oap); - rc = l_wait_event(ocw.ocw_waitq, ocw_granted(cli, &ocw), &lwi); + rc = wait_event_idle_timeout(ocw.ocw_waitq, + ocw_granted(cli, &ocw), + cfs_time_seconds(AT_OFF ? + obd_timeout : + at_max)); spin_lock(&cli->cl_loi_list_lock); - if (rc < 0) { + if (rc <= 0) { /* l_wait_event is interrupted by signal or timed out */ list_del_init(&ocw.ocw_entry); + if (rc == 0) + rc = -ETIMEDOUT; break; } LASSERT(list_empty(&ocw.ocw_entry)); diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 144e335..b692261 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -783,16 +783,12 @@ static int osd_scrub_next(struct osd_thread_info *info, struct osd_device *dev, struct osd_inode_id *lid; int rc; - if (OBD_FAIL_CHECK(OBD_FAIL_OSD_SCRUB_DELAY) && cfs_fail_val > 0) { - struct l_wait_info lwi; - - lwi = LWI_TIMEOUT(cfs_time_seconds(cfs_fail_val), NULL, NULL); - if (likely(lwi.lwi_timeout > 0)) - l_wait_event(thread->t_ctl_waitq, - !list_empty(&scrub->os_inconsistent_items) || - !thread_is_running(thread), - &lwi); - } + if (OBD_FAIL_CHECK(OBD_FAIL_OSD_SCRUB_DELAY) && cfs_fail_val > 0) + wait_event_idle_timeout( + thread->t_ctl_waitq, + !list_empty(&scrub->os_inconsistent_items) || + !thread_is_running(thread), + cfs_time_seconds(cfs_fail_val)); if (OBD_FAIL_CHECK(OBD_FAIL_OSD_SCRUB_CRASH)) { spin_lock(&scrub->os_lock); diff --git a/lustre/osd-zfs/osd_scrub.c b/lustre/osd-zfs/osd_scrub.c index 5b6f3a0..97cfb2d 100644 --- a/lustre/osd-zfs/osd_scrub.c +++ b/lustre/osd-zfs/osd_scrub.c @@ -414,7 +414,6 @@ osd_scrub_wakeup(struct lustre_scrub *scrub, struct osd_otable_it *it) static int osd_scrub_next(const struct lu_env *env, struct osd_device *dev, struct lu_fid *fid, uint64_t *oid) { - struct l_wait_info lwi = { 0 }; struct lustre_scrub *scrub = &dev->od_scrub; struct ptlrpc_thread *thread = &scrub->os_thread; struct osd_otable_it *it = dev->od_otable_it; @@ -425,15 +424,14 @@ static int osd_scrub_next(const struct lu_env *env, struct osd_device *dev, ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSD_SCRUB_DELAY) && cfs_fail_val > 0) { - lwi = LWI_TIMEOUT(cfs_time_seconds(cfs_fail_val), NULL, NULL); - if (likely(lwi.lwi_timeout > 0)) { - l_wait_event(thread->t_ctl_waitq, - !list_empty(&scrub->os_inconsistent_items) || - !thread_is_running(thread), - &lwi); - if (unlikely(!thread_is_running(thread))) - RETURN(SCRUB_NEXT_EXIT); - } + wait_event_idle_timeout( + thread->t_ctl_waitq, + !list_empty(&scrub->os_inconsistent_items) || + !thread_is_running(thread), + cfs_time_seconds(cfs_fail_val)); + + if (unlikely(!thread_is_running(thread))) + RETURN(SCRUB_NEXT_EXIT); } if (OBD_FAIL_CHECK(OBD_FAIL_OSD_SCRUB_CRASH)) { diff --git a/lustre/osp/osp_sync.c b/lustre/osp/osp_sync.c index 5d20e0b..2907c70 100644 --- a/lustre/osp/osp_sync.c +++ b/lustre/osp/osp_sync.c @@ -1208,7 +1208,6 @@ static int osp_sync_thread(void *_arg) { struct osp_device *d = _arg; struct ptlrpc_thread *thread = &d->opd_sync_thread; - struct l_wait_info lwi = { 0 }; struct llog_ctxt *ctxt; struct obd_device *obd = d->opd_obd; struct llog_handle *llh; @@ -1319,11 +1318,11 @@ next: while (atomic_read(&d->opd_sync_rpcs_in_progress) > 0) { osp_sync_process_committed(&env, d); - lwi = LWI_TIMEOUT(cfs_time_seconds(5), NULL, NULL); - rc = l_wait_event(d->opd_sync_waitq, - atomic_read(&d->opd_sync_rpcs_in_progress) == 0, - &lwi); - if (rc == -ETIMEDOUT) + rc = wait_event_idle_timeout( + d->opd_sync_waitq, + atomic_read(&d->opd_sync_rpcs_in_progress) == 0, + cfs_time_seconds(5)); + if (rc == 0) count++; LASSERTF(count < 10, "%s: %d %d %sempty\n", d->opd_obd->obd_name, diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 96ab1d9..ab38eb5 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -471,7 +471,6 @@ int ptlrpc_reconnect_import(struct obd_import *imp) { #ifdef ENABLE_PINGER long timeout_jiffies = cfs_time_seconds(obd_timeout); - struct l_wait_info lwi; int rc; ptlrpc_pinger_force(imp); @@ -479,9 +478,13 @@ int ptlrpc_reconnect_import(struct obd_import *imp) CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", obd2cli_tgt(imp->imp_obd), obd_timeout); - lwi = LWI_TIMEOUT(timeout_jiffies, NULL, NULL); - rc = l_wait_event(imp->imp_recovery_waitq, - !ptlrpc_import_in_recovery(imp), &lwi); + rc = wait_event_idle_timeout(imp->imp_recovery_waitq, + !ptlrpc_import_in_recovery(imp), + timeout_jiffies); + if (rc == 0) + rc = -ETIMEDOUT; + else + rc = 0; CDEBUG(D_HA, "%s: recovery finished s:%s\n", obd2cli_tgt(imp->imp_obd), ptlrpc_import_state_name(imp->imp_state)); return rc; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 4d3879e..0f138ae 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -287,16 +287,15 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) /* See if we have anything in a pool, and wait if nothing */ while (list_empty(&svcpt->scp_rep_idle)) { - struct l_wait_info lwi; int rc; spin_unlock(&svcpt->scp_rep_lock); /* If we cannot get anything for some long time, we better * bail out instead of waiting infinitely */ - lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL); - rc = l_wait_event(svcpt->scp_rep_waitq, - !list_empty(&svcpt->scp_rep_idle), &lwi); - if (rc != 0) + rc = wait_event_idle_timeout(svcpt->scp_rep_waitq, + !list_empty(&svcpt->scp_rep_idle), + cfs_time_seconds(10)); + if (rc <= 0) goto out; spin_lock(&svcpt->scp_rep_lock); } diff --git a/lustre/ptlrpc/recover.c b/lustre/ptlrpc/recover.c index 62890ec..d2da4a4 100644 --- a/lustre/ptlrpc/recover.c +++ b/lustre/ptlrpc/recover.c @@ -345,15 +345,18 @@ int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid, int async) GOTO(out, rc); if (!async) { - struct l_wait_info lwi; long timeout = cfs_time_seconds(obd_timeout); - CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", + CDEBUG(D_HA, "%s: recovery started, waiting %u jiffies\n", obd2cli_tgt(imp->imp_obd), obd_timeout); - lwi = LWI_TIMEOUT(timeout, NULL, NULL); - rc = l_wait_event(imp->imp_recovery_waitq, - !ptlrpc_import_in_recovery(imp), &lwi); + rc = wait_event_idle_timeout(imp->imp_recovery_waitq, + !ptlrpc_import_in_recovery(imp), + timeout); + if (rc == 0) + rc = -ETIMEDOUT; + else + rc = 0; CDEBUG(D_HA, "%s: recovery finished\n", obd2cli_tgt(imp->imp_obd)); } diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index e68643c..64ecbc1 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -3368,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); diff --git a/lustre/quota/qsd_handler.c b/lustre/quota/qsd_handler.c index 02ebad1..3fff49a 100644 --- a/lustre/quota/qsd_handler.c +++ b/lustre/quota/qsd_handler.c @@ -694,7 +694,6 @@ static int qsd_op_begin0(const struct lu_env *env, struct qsd_qtype_info *qqi, enum osd_quota_local_flags *local_flags) { struct lquota_entry *lqe; - struct l_wait_info lwi; enum osd_quota_local_flags qtype_flag = 0; int rc, ret = -EINPROGRESS; ENTRY; @@ -737,16 +736,18 @@ static int qsd_op_begin0(const struct lu_env *env, struct qsd_qtype_info *qqi, /* acquire quota space for the operation, cap overall wait time to * prevent a service thread from being stuck for too long */ - lwi = LWI_TIMEOUT(cfs_time_seconds(qsd_wait_timeout(qqi->qqi_qsd)), - NULL, NULL); - rc = l_wait_event(lqe->lqe_waiters, qsd_acquire(env, lqe, space, &ret), - &lwi); + rc = wait_event_idle_timeout( + lqe->lqe_waiters, qsd_acquire(env, lqe, space, &ret), + cfs_time_seconds(qsd_wait_timeout(qqi->qqi_qsd))); - if (rc == 0 && ret == 0) { + if (rc > 0 && ret == 0) { qid->lqi_space += space; + rc = 0; } else { - if (rc == 0) + if (rc > 0) rc = ret; + else if (rc == 0) + rc = -ETIMEDOUT; LQUOTA_DEBUG(lqe, "acquire quota failed:%d", rc); diff --git a/lustre/quota/qsd_writeback.c b/lustre/quota/qsd_writeback.c index 6ebfd8c..9a40013 100644 --- a/lustre/quota/qsd_writeback.c +++ b/lustre/quota/qsd_writeback.c @@ -433,7 +433,6 @@ static int qsd_upd_thread(void *arg) { struct qsd_instance *qsd = (struct qsd_instance *)arg; struct ptlrpc_thread *thread = &qsd->qsd_upd_thread; - struct l_wait_info lwi; struct list_head queue; struct qsd_upd_rec *upd, *n; struct lu_env *env; @@ -458,11 +457,12 @@ static int qsd_upd_thread(void *arg) wake_up(&thread->t_ctl_waitq); INIT_LIST_HEAD(&queue); - lwi = LWI_TIMEOUT(cfs_time_seconds(QSD_WB_INTERVAL), NULL, NULL); while (1) { - l_wait_event(thread->t_ctl_waitq, - qsd_job_pending(qsd, &queue, &uptodate) || - !thread_is_running(thread), &lwi); + wait_event_idle_timeout( + thread->t_ctl_waitq, + qsd_job_pending(qsd, &queue, &uptodate) || + !thread_is_running(thread), + cfs_time_seconds(QSD_WB_INTERVAL)); list_for_each_entry_safe(upd, n, &queue, qur_link) { list_del_init(&upd->qur_link); diff --git a/lustre/target/barrier.c b/lustre/target/barrier.c index 54b3e56..6ed91f7 100644 --- a/lustre/target/barrier.c +++ b/lustre/target/barrier.c @@ -199,13 +199,11 @@ static int barrier_freeze(const struct lu_env *env, RETURN(1); if (phase1 && inflight != 0) { - struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(left), - NULL, NULL); - - rc = l_wait_event(barrier->bi_waitq, - percpu_counter_sum(&barrier->bi_writers) == 0, - &lwi); - if (rc) + rc = wait_event_idle_timeout( + barrier->bi_waitq, + percpu_counter_sum(&barrier->bi_writers) == 0, + cfs_time_seconds(left)); + if (rc <= 0) RETURN(1); /* sync again after all inflight modifications done. */ -- 1.8.3.1