Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760525AbdLRUY3 (ORCPT ); Mon, 18 Dec 2017 15:24:29 -0500 Received: from esa1.cray.iphmx.com ([68.232.142.33]:44433 "EHLO esa1.cray.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760422AbdLRUXt (ORCPT ); Mon, 18 Dec 2017 15:23:49 -0500 X-IronPort-AV: E=Sophos;i="5.45,423,1508799600"; d="scan'208";a="17066714" X-Cray-OBMMKR: 1433258124 17066714 From: Patrick Farrell To: NeilBrown , Oleg Drokin , "Andreas Dilger" , James Simmons , Greg Kroah-Hartman CC: lkml , lustre Subject: Re: [lustre-devel] [PATCH 04/16] staging: lustre: use wait_event_timeout() where appropriate. Thread-Topic: [lustre-devel] [PATCH 04/16] staging: lustre: use wait_event_timeout() where appropriate. Thread-Index: AQHTd9CnVH+ietVAGUuRPZhRagwvKKNJJ/UA Date: Mon, 18 Dec 2017 20:23:40 +0000 Message-ID: References: <151358127190.5099.12792810096274074963.stgit@noble> <151358147993.5099.9887255633793256926.stgit@noble> In-Reply-To: <151358147993.5099.9887255633793256926.stgit@noble> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.7.2.170228 authentication-results: spf=none (sender IP is ) smtp.mailfrom=paf@cray.com; x-originating-ip: [136.162.2.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR1101MB2143;6:1efApe7QzJELVfJXI56atHSlle6r23CaUcb12ruSf8sE6hOoicDmH05PoTp8FF4oXE3RYwinxG7tK3yhAFepcYG0i1Rld4q9A9deYx77Ee4hXH9F/u7rXTwMfFBaxK6iAjvGYqKVEkr1ZAy3mPcSxDVsdqS5w5cx9xuQMmusIQ3zgDRnFra+WTACw7SMwRpL5Wo82gFbxl1xqjbvniVyVQFvaHmPdAkzWeeWWaiG5/rIpT4uH3pSmHlc3HKtFSLhGv+gy8z5P95IuizsEymy0UIhEr9+KJXAoWSlvauiJLu34TRKC/USALT+71hUHDGATqskIeZsZYg37O5AeaxgzcQwB9p4UF5RpjexuhAvsjw=;5:gyColvWBLjtLFfb0X50V+xDAnht/uH6ouMenHxnL7omsh9k+abxt2TkJY+uYmgUGvdAImhhSwVxIIVwSAB8ftc6erFOxE/ZvuFwuaTMmHhlOsXj+vcemiF3styiXh4Nc7lb6XoF3X2U3pot0LB1BOeMpWK6vK7sdkrqt+3gCiAQ=;24:rZkd4PP5QPNy/qNcdYh50udMV0aKSIU0tN2qWJSeSfoxGipw7cIq8LVjksdNmcL1MjNkAILP5OWS2PcOy+9arcLxyFjj9x6ND3sS215CNm0=;7:RgBpYE+vF8rGPX1vLVsnc01gx1MPTpgCOXcWxjhAHrDQULtuFFdE5r1khVYA60z50N6++UR+8vYB9RMBUoAgoxTcQClrJII7C73uCr5i0GanJ/G6qSq0nO7M/hTV4oHgv73FJPNtbz32nAJVfltEe+QUZJmRbVuwMtqeOpHvHl9/E4isyMXe9ThMYWXI7Np26b/hzwKbE6qYqlXl5RckRs447q4ZKnSGxkHHGrMjL4Jtc/pt6tnHiFkyiNLmRgc5 x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 4023ea7e-beb3-490e-3075-08d546553a3e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307);SRVR:MWHPR1101MB2143; x-ms-traffictypediagnostic: MWHPR1101MB2143: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231023)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MWHPR1101MB2143;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR1101MB2143; x-forefront-prvs: 0525BB0ADF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39850400004)(376002)(366004)(346002)(396003)(24454002)(189003)(199004)(316002)(76176011)(36756003)(102836003)(6116002)(105586002)(58126008)(3846002)(3660700001)(106356001)(3280700002)(2950100002)(68736007)(99286004)(478600001)(14454004)(8936002)(83506002)(81166006)(81156014)(2900100001)(305945005)(5660300001)(8676002)(7736002)(2906002)(53936002)(6306002)(53946003)(6512007)(66066001)(59450400001)(6436002)(53546011)(77096006)(6486002)(97736004)(229853002)(110136005)(86362001)(25786009)(54906003)(6246003)(4326008)(6506007)(13693001)(21314002)(42262002)(579004);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR1101MB2143;H:MWHPR1101MB2143.namprd11.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 4023ea7e-beb3-490e-3075-08d546553a3e X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2017 20:23:40.3767 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: e7b8488a-c0cd-4614-aae1-996bfabec247 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2143 X-OriginatorOrg: cray.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vBIKOYOl007933 Content-Length: 22205 Lines: 612 Same thing as the other one, ll_statahead_thread should not contribute to load. IMO, mgc_process_log should not contribute to load in the case where it?s waiting for an import to recover, that?s likely to be a pretty long wait and doesn?t really represent load. It?s waiting for network recovery, basically. The OSC functions get the same question as the other ones - they happen from user threads and from daemons. Curious again what Andreas and/or Oleg think. I think ptlrpc_reconnect_import should probably *not* contribute to load, it?s waiting for network recovery. Same with ptlrpc_recover_import. On 12/18/17, 1:17 AM, "lustre-devel on behalf of NeilBrown" wrote: >When the lwi arg has a timeout, but no timeout >callback function, l_wait_event() acts much the same as >wait_event_timeout() - the wait is not interruptible and >simply waits for the event or the timeouts. > >The most noticable difference is that the return value is >-ETIMEDOUT or 0, rather than 0 or non-zero. > >Another difference is that the process waiting is included in >the load-average. This is probably more correct. > >A final difference is that if the timeout is zero, l_wait_event() >will not time out at all. In the one case where that is possible >we need to conditionally use wait_event_noload(). > >So replace all such calls with wait_event_timeout(), being >careful of the return value. > >In one case, there is no event, so use >schedule_timeout_uninterruptible(). > > >Note that the presence or absence of LWI_ON_SIGNAL_NOOP >has no effect in these cases. > >Signed-off-by: NeilBrown >--- > drivers/staging/lustre/lustre/include/lustre_lib.h | 37 >++++++++++++++++++++ > drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 10 ++--- > drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 12 ++---- > drivers/staging/lustre/lustre/llite/statahead.c | 14 +++----- > drivers/staging/lustre/lustre/mdc/mdc_request.c | 5 +-- > drivers/staging/lustre/lustre/mgc/mgc_request.c | 15 +++----- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 17 +++++---- > drivers/staging/lustre/lustre/osc/osc_cache.c | 25 ++++++-------- > drivers/staging/lustre/lustre/ptlrpc/events.c | 7 +--- > drivers/staging/lustre/lustre/ptlrpc/import.c | 12 +++--- > .../staging/lustre/lustre/ptlrpc/pack_generic.c | 9 ++--- > drivers/staging/lustre/lustre/ptlrpc/pinger.c | 12 ++---- > drivers/staging/lustre/lustre/ptlrpc/recover.c | 12 +++--- > drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 10 ++--- > drivers/staging/lustre/lustre/ptlrpc/service.c | 10 ++--- > 15 files changed, 104 insertions(+), 103 deletions(-) > >diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h >b/drivers/staging/lustre/lustre/include/lustre_lib.h >index 08bdd618ea7d..fcf31c779e98 100644 >--- a/drivers/staging/lustre/lustre/include/lustre_lib.h >+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h >@@ -388,4 +388,41 @@ do { \ > schedule()); \ > } while (0) > >+#define __wait_event_noload_timeout(wq_head, condition, timeout) \ >+ ___wait_event(wq_head, ___wait_cond_timeout(condition), \ >+ (TASK_UNINTERRUPTIBLE | TASK_NOLOAD), 0, timeout, \ >+ __ret = schedule_timeout(__ret)) >+ >+/** >+ * wait_event_noload_timeout - sleep until a condition gets true or a >timeout elapses >+ * @wq_head: the waitqueue to wait on >+ * @condition: a C expression for the event to wait for >+ * @timeout: timeout, in jiffies >+ * >+ * The process is put to sleep (TASK_UNINTERRUPTIBLE | TASK_NOLOAD) >until the >+ * @condition evaluates to true. The @condition is checked each time >+ * the waitqueue @wq_head is woken up. >+ * >+ * wake_up() has to be called after changing any variable that could >+ * change the result of the wait condition. >+ * >+ * This is suitable for service threads that are waiting for work to do >+ * where there is no implication that the event not being true yet >implies >+ * any load on the system, and where it is not appropriate for the >+ * soft-lockup detector to warning if the wait is unusually long. >+ * >+ * Returns: >+ * 0 if the @condition evaluated to %false after the @timeout elapsed, >+ * 1 if the @condition evaluated to %true after the @timeout elapsed, >+ * or the remaining jiffies (at least 1) if the @condition evaluated >+ * to %true before the @timeout elapsed. >+ */ >+#define wait_event_noload_timeout(wq_head, condition, timeout) \ >+({ \ >+ long __ret = timeout; \ >+ might_sleep(); \ >+ if (!___wait_cond_timeout(condition)) \ >+ __ret = __wait_event_noload_timeout(wq_head, condition, timeout);\ >+ __ret; \ >+}) > #endif /* _LUSTRE_LIB_H */ >diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c >b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c >index 53500883f243..ba720a888da3 100644 >--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c >+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c >@@ -1349,7 +1349,6 @@ enum ldlm_mode ldlm_lock_match(struct >ldlm_namespace *ns, __u64 flags, > if ((flags & LDLM_FL_LVB_READY) && !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, >@@ -1366,13 +1365,10 @@ enum ldlm_mode ldlm_lock_match(struct >ldlm_namespace *ns, __u64 flags, > } > } > >- lwi = LWI_TIMEOUT_INTR(obd_timeout * HZ, >- NULL, LWI_ON_SIGNAL_NOOP, NULL); >- > /* XXX FIXME see comment on CAN_MATCH in lustre_dlm.h */ >- l_wait_event(lock->l_waitq, >- lock->l_flags & wait_flags, >- &lwi); >+ wait_event_timeout(lock->l_waitq, >+ lock->l_flags & wait_flags, >+ obd_timeout * HZ); > if (!ldlm_is_lvb_ready(lock)) { > if (flags & LDLM_FL_TEST_LOCK) > LDLM_LOCK_RELEASE(lock); >diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c >b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c >index eb1f3d45c68c..c42b65173407 100644 >--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c >+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c >@@ -997,8 +997,6 @@ static int ldlm_pools_thread_main(void *arg) > "ldlm_poold", current_pid()); > > while (1) { >- struct l_wait_info lwi; >- > /* > * Recal all pools on this tick. > */ >@@ -1008,12 +1006,10 @@ static int ldlm_pools_thread_main(void *arg) > * Wait until the next check time, or until we're > * stopped. > */ >- lwi = LWI_TIMEOUT(c_time * HZ, >- NULL, NULL); >- l_wait_event(thread->t_ctl_waitq, >- thread_is_stopping(thread) || >- thread_is_event(thread), >- &lwi); >+ wait_event_noload_timeout(thread->t_ctl_waitq, >+ thread_is_stopping(thread) || >+ thread_is_event(thread), >+ c_time * HZ); > > if (thread_test_and_clear_flags(thread, SVC_STOPPING)) > break; >diff --git a/drivers/staging/lustre/lustre/llite/statahead.c >b/drivers/staging/lustre/lustre/llite/statahead.c >index 9f9897523374..aecad3e6e808 100644 >--- a/drivers/staging/lustre/lustre/llite/statahead.c >+++ b/drivers/staging/lustre/lustre/llite/statahead.c >@@ -1151,10 +1151,9 @@ static int ll_statahead_thread(void *arg) > */ > while (sai->sai_sent != sai->sai_replied) { > /* in case we're not woken up, timeout wait */ >- struct l_wait_info lwi = LWI_TIMEOUT(msecs_to_jiffies(MSEC_PER_SEC >> >3), >- NULL, NULL); >- l_wait_event(sa_thread->t_ctl_waitq, >- sai->sai_sent == sai->sai_replied, &lwi); >+ wait_event_timeout(sa_thread->t_ctl_waitq, >+ sai->sai_sent == sai->sai_replied, >+ HZ>>3); > } > > /* release resources held by statahead RPCs */ >@@ -1374,7 +1373,6 @@ static int revalidate_statahead_dentry(struct inode >*dir, > { > struct ll_inode_info *lli = ll_i2info(dir); > struct sa_entry *entry = NULL; >- struct l_wait_info lwi = { 0 }; > struct ll_dentry_data *ldd; > int rc = 0; > >@@ -1424,10 +1422,8 @@ 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(30 * HZ, NULL, >- LWI_ON_SIGNAL_NOOP, NULL); >- rc = l_wait_event(sai->sai_waitq, sa_ready(entry), &lwi); >- if (rc < 0) { >+ if (0 == wait_event_timeout(sai->sai_waitq, >+ sa_ready(entry), 30 * HZ)) { > /* > * entry may not be ready, so it may be used by inflight > * statahead RPC, don't free it. >diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c >b/drivers/staging/lustre/lustre/mdc/mdc_request.c >index b12518ba5ae9..0409b4948c39 100644 >--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c >+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c >@@ -838,7 +838,6 @@ static int mdc_getpage(struct obd_export *exp, const >struct lu_fid *fid, > struct ptlrpc_bulk_desc *desc; > struct ptlrpc_request *req; > wait_queue_head_t waitq; >- struct l_wait_info lwi; > int resends = 0; > int rc; > int i; >@@ -888,9 +887,7 @@ static int mdc_getpage(struct obd_export *exp, const >struct lu_fid *fid, > exp->exp_obd->obd_name, -EIO); > return -EIO; > } >- lwi = LWI_TIMEOUT_INTR(resends * HZ, NULL, NULL, >- NULL); >- l_wait_event(waitq, 0, &lwi); >+ wait_event_timeout(waitq, 0, resends * HZ); > > goto restart_bulk; > } >diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c >b/drivers/staging/lustre/lustre/mgc/mgc_request.c >index 4c2e20ff95d7..b42ec5b4a24c 100644 >--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c >+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c >@@ -535,7 +535,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; >@@ -556,9 +555,9 @@ static int mgc_requeue_thread(void *data) > to = msecs_to_jiffies(MGC_TIMEOUT_MIN_SECONDS * MSEC_PER_SEC); > /* rand is centi-seconds */ > to += msecs_to_jiffies(rand * MSEC_PER_SEC / 100); >- lwi = LWI_TIMEOUT(to, NULL, NULL); >- l_wait_event(rq_waitq, rq_state & (RQ_STOP | RQ_PRECLEANUP), >- &lwi); >+ wait_event_noload_timeout(rq_waitq, >+ rq_state & (RQ_STOP | RQ_PRECLEANUP), >+ to); > > /* > * iterate & processing through the list. for each cld, process >@@ -1628,9 +1627,7 @@ int mgc_process_log(struct obd_device *mgc, struct >config_llog_data *cld) > > if (rcl == -ESHUTDOWN && > atomic_read(&mgc->u.cli.cl_mgc_refcount) > 0 && !retry) { >- int secs = obd_timeout * HZ; > struct obd_import *imp; >- struct l_wait_info lwi; > > mutex_unlock(&cld->cld_lock); > imp = class_exp2cliimp(mgc->u.cli.cl_mgc_mgsexp); >@@ -1645,9 +1642,9 @@ int mgc_process_log(struct obd_device *mgc, struct >config_llog_data *cld) > */ > ptlrpc_pinger_force(imp); > >- lwi = LWI_TIMEOUT(secs, NULL, NULL); >- l_wait_event(imp->imp_recovery_waitq, >- !mgc_import_in_recovery(imp), &lwi); >+ wait_event_timeout(imp->imp_recovery_waitq, >+ !mgc_import_in_recovery(imp), >+ obd_timeout * HZ); > > if (imp->imp_state == LUSTRE_IMP_FULL) { > retry = true; >diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c >b/drivers/staging/lustre/lustre/obdclass/cl_io.c >index d8be01b9257f..5330962c1f66 100644 >--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c >+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c >@@ -1097,16 +1097,19 @@ EXPORT_SYMBOL(cl_sync_io_init); > int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > long timeout) > { >- struct l_wait_info lwi = LWI_TIMEOUT_INTR(timeout * HZ, >- NULL, NULL, NULL); >- int rc; >+ int rc = 1; > > LASSERT(timeout >= 0); > >- rc = l_wait_event(anchor->csi_waitq, >- atomic_read(&anchor->csi_sync_nr) == 0, >- &lwi); >- if (rc < 0) { >+ if (timeout == 0) >+ wait_event_noload(anchor->csi_waitq, >+ atomic_read(&anchor->csi_sync_nr) == 0); >+ else >+ rc = wait_event_timeout(anchor->csi_waitq, >+ atomic_read(&anchor->csi_sync_nr) == 0, >+ timeout * HZ); >+ if (rc == 0) { >+ rc = -ETIMEDOUT; > CERROR("IO failed: %d, still wait for %d remaining entries\n", > rc, atomic_read(&anchor->csi_sync_nr)); > >diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c >b/drivers/staging/lustre/lustre/osc/osc_cache.c >index e6d99dc048ce..186cc1a0130a 100644 >--- a/drivers/staging/lustre/lustre/osc/osc_cache.c >+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c >@@ -934,8 +934,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(600 * HZ, NULL, >- LWI_ON_SIGNAL_NOOP, NULL); > int rc = 0; > > osc_object_lock(obj); >@@ -958,17 +956,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_timeout(ext->oe_waitq, >+ extent_wait_cb(ext, state), 600 * HZ); >+ 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(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; > } > >@@ -1568,12 +1568,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; >+ unsigned long timeout = (AT_OFF ? obd_timeout : at_max) * HZ; > int rc = -EDQUOT; > >- lwi = LWI_TIMEOUT_INTR((AT_OFF ? obd_timeout : at_max) * HZ, >- NULL, LWI_ON_SIGNAL_NOOP, NULL); >- > OSC_DUMP_GRANT(D_CACHE, cli, "need:%d\n", bytes); > > spin_lock(&cli->cl_loi_list_lock); >@@ -1616,13 +1613,15 @@ 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_timeout(ocw.ocw_waitq, >+ ocw_granted(cli, &ocw), timeout); > > spin_lock(&cli->cl_loi_list_lock); > >- if (rc < 0) { >- /* l_wait_event is interrupted by signal, or timed out */ >+ if (rc == 0) { >+ /* wait_event is interrupted by signal, or timed out */ > list_del_init(&ocw.ocw_entry); >+ rc = -ETIMEDOUT; > break; > } > LASSERT(list_empty(&ocw.ocw_entry)); >diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c >b/drivers/staging/lustre/lustre/ptlrpc/events.c >index 71f7588570ef..130bacc2c891 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/events.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/events.c >@@ -490,8 +490,6 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, > > static void ptlrpc_ni_fini(void) > { >- wait_queue_head_t waitq; >- struct l_wait_info lwi; > int rc; > int retries; > >@@ -515,10 +513,7 @@ static void ptlrpc_ni_fini(void) > if (retries != 0) > CWARN("Event queue still busy\n"); > >- /* Wait for a bit */ >- init_waitqueue_head(&waitq); >- lwi = LWI_TIMEOUT(2 * HZ, NULL, NULL); >- l_wait_event(waitq, 0, &lwi); >+ schedule_timeout_uninterruptible(2 * HZ); > break; > } > } >diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c >b/drivers/staging/lustre/lustre/ptlrpc/import.c >index 0eba5f18bd3b..34b4075fac42 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/import.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c >@@ -430,21 +430,19 @@ void ptlrpc_fail_import(struct obd_import *imp, >__u32 conn_cnt) > > int ptlrpc_reconnect_import(struct obd_import *imp) > { >- struct l_wait_info lwi; >- int secs = obd_timeout * HZ; > int rc; > > ptlrpc_pinger_force(imp); > > CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", >- obd2cli_tgt(imp->imp_obd), secs); >+ obd2cli_tgt(imp->imp_obd), obd_timeout); > >- lwi = LWI_TIMEOUT(secs, NULL, NULL); >- rc = l_wait_event(imp->imp_recovery_waitq, >- !ptlrpc_import_in_recovery(imp), &lwi); >+ rc = wait_event_timeout(imp->imp_recovery_waitq, >+ !ptlrpc_import_in_recovery(imp), >+ obd_timeout * HZ); > CDEBUG(D_HA, "%s: recovery finished s:%s\n", obd2cli_tgt(imp->imp_obd), > ptlrpc_import_state_name(imp->imp_state)); >- return rc; >+ return rc == 0 ? -ETIMEDOUT : 0; > } > EXPORT_SYMBOL(ptlrpc_reconnect_import); > >diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c >b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c >index c060d6f5015a..6a1c3c041096 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c >@@ -260,17 +260,16 @@ 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(10 * HZ, NULL, NULL); >- rc = l_wait_event(svcpt->scp_rep_waitq, >- !list_empty(&svcpt->scp_rep_idle), &lwi); >- if (rc != 0) >+ rc = wait_event_timeout(svcpt->scp_rep_waitq, >+ !list_empty(&svcpt->scp_rep_idle), >+ 10 * HZ); >+ if (rc == 0) > goto out; > spin_lock(&svcpt->scp_rep_lock); > } >diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c >b/drivers/staging/lustre/lustre/ptlrpc/pinger.c >index da3afda72e14..ed919507a50a 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c >@@ -228,7 +228,6 @@ static int ptlrpc_pinger_main(void *arg) > /* And now, loop forever, pinging as needed. */ > while (1) { > unsigned long this_ping = cfs_time_current(); >- struct l_wait_info lwi; > long time_to_next_wake; > struct timeout_item *item; > struct list_head *iter; >@@ -266,13 +265,10 @@ static int ptlrpc_pinger_main(void *arg) > cfs_time_add(this_ping, > PING_INTERVAL * HZ)); > if (time_to_next_wake > 0) { >- lwi = LWI_TIMEOUT(max_t(long, time_to_next_wake, >- HZ), >- NULL, NULL); >- l_wait_event(thread->t_ctl_waitq, >- thread_is_stopping(thread) || >- thread_is_event(thread), >- &lwi); >+ wait_event_noload_timeout(thread->t_ctl_waitq, >+ thread_is_stopping(thread) || >+ thread_is_event(thread), >+ max_t(long, time_to_next_wake, HZ)); > if (thread_test_and_clear_flags(thread, SVC_STOPPING)) > break; > /* woken after adding import to reset timer */ >diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c >b/drivers/staging/lustre/lustre/ptlrpc/recover.c >index 5bbd23eebfa6..c8a7fca6d906 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/recover.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c >@@ -346,17 +346,15 @@ int ptlrpc_recover_import(struct obd_import *imp, >char *new_uuid, int async) > goto out; > > if (!async) { >- struct l_wait_info lwi; >- int secs = obd_timeout * HZ; >- > CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", >- obd2cli_tgt(imp->imp_obd), secs); >+ obd2cli_tgt(imp->imp_obd), obd_timeout); > >- lwi = LWI_TIMEOUT(secs, NULL, NULL); >- rc = l_wait_event(imp->imp_recovery_waitq, >- !ptlrpc_import_in_recovery(imp), &lwi); >+ rc = wait_event_timeout(imp->imp_recovery_waitq, >+ !ptlrpc_import_in_recovery(imp), >+ obd_timeout * HZ); > CDEBUG(D_HA, "%s: recovery finished\n", > obd2cli_tgt(imp->imp_obd)); >+ rc = rc? 0 : -ETIMEDOUT; > } > > out: >diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c >b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c >index e4197a60d1e2..a10890b8324a 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c >@@ -142,7 +142,6 @@ static void sec_do_gc(struct ptlrpc_sec *sec) > static int sec_gc_main(void *arg) > { > struct ptlrpc_thread *thread = arg; >- struct l_wait_info lwi; > > unshare_fs_struct(); > >@@ -179,12 +178,9 @@ static int sec_gc_main(void *arg) > > /* check ctx list again before sleep */ > sec_process_ctx_list(); >- >- lwi = LWI_TIMEOUT(msecs_to_jiffies(SEC_GC_INTERVAL * MSEC_PER_SEC), >- NULL, NULL); >- l_wait_event(thread->t_ctl_waitq, >- thread_is_stopping(thread), >- &lwi); >+ wait_event_noload_timeout(thread->t_ctl_waitq, >+ thread_is_stopping(thread), >+ SEC_GC_INTERVAL * HZ); > > if (thread_test_and_clear_flags(thread, SVC_STOPPING)) > break; >diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c >b/drivers/staging/lustre/lustre/ptlrpc/service.c >index 4a8a591e0067..c568baf8c28f 100644 >--- a/drivers/staging/lustre/lustre/ptlrpc/service.c >+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c >@@ -2588,13 +2588,11 @@ static void ptlrpc_wait_replies(struct >ptlrpc_service_part *svcpt) > { > while (1) { > int rc; >- struct l_wait_info lwi = LWI_TIMEOUT(10 * HZ, >- NULL, NULL); > >- rc = l_wait_event(svcpt->scp_waitq, >- atomic_read(&svcpt->scp_nreps_difficult) == 0, >- &lwi); >- if (rc == 0) >+ rc = wait_event_timeout(svcpt->scp_waitq, >+ atomic_read(&svcpt->scp_nreps_difficult) == 0, >+ 10 * HZ); >+ if (rc > 0) > break; > CWARN("Unexpectedly long timeout %s %p\n", > svcpt->scp_service->srv_name, svcpt->scp_service); > > >_______________________________________________ >lustre-devel mailing list >lustre-devel@lists.lustre.org >http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org