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,
}
}
- 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_idle_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);
"ldlm_poold", current_pid());
while (1) {
- struct l_wait_info lwi;
-
/*
* Recal all pools on this tick.
*/
* 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_idle_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;
*/
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_idle_timeout(sa_thread->t_ctl_waitq,
+ sai->sai_sent == sai->sai_replied,
+ HZ>>3);
}
/* release resources held by statahead RPCs */
{
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;
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_idle_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.
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;
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_idle_timeout(waitq, 0, resends * HZ);
goto restart_bulk;
}
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;
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_idle_timeout(rq_waitq,
+ rq_state & (RQ_STOP | RQ_PRECLEANUP),
+ to);
/*
* iterate & processing through the list. for each cld, process
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);
*/
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_idle_timeout(imp->imp_recovery_waitq,
+ !mgc_import_in_recovery(imp),
+ obd_timeout * HZ);
if (imp->imp_state == LUSTRE_IMP_FULL) {
retry = true;
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_idle(anchor->csi_waitq,
+ atomic_read(&anchor->csi_sync_nr) == 0);
+ else
+ rc = wait_event_idle_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));
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);
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), 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_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;
}
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);
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), 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));
static void ptlrpc_ni_fini(void)
{
- wait_queue_head_t waitq;
- struct l_wait_info lwi;
int rc;
int retries;
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;
}
}
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_idle_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);
/* 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_idle_timeout(svcpt->scp_rep_waitq,
+ !list_empty(&svcpt->scp_rep_idle),
+ 10 * HZ);
+ if (rc == 0)
goto out;
spin_lock(&svcpt->scp_rep_lock);
}
/* 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;
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_idle_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 */
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_idle_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:
static int sec_gc_main(void *arg)
{
struct ptlrpc_thread *thread = arg;
- struct l_wait_info lwi;
unshare_fs_struct();
/* 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_idle_timeout(thread->t_ctl_waitq,
+ thread_is_stopping(thread),
+ SEC_GC_INTERVAL * HZ);
if (thread_test_and_clear_flags(thread, SVC_STOPPING))
break;
{
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_idle_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);