Commit 98b09280 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman
Browse files

staging: lustre: use wait_event_idle_timeout() where appropriate.



When the lwi arg has a timeout, but no timeout
callback function, l_wait_event() acts much the same as
wait_event_idle_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 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_idle().

So replace all such calls with wait_event_idle_timeout(), being
careful of the return value.

In one case, there is no event expected, only the timeout
is needed.  So use schedule_timeout_uninterruptible().

Note that the presence or absence of LWI_ON_SIGNAL_NOOP
has no effect in these cases.  It only has effect if the timeout
callback is non-NULL, or the timeout is zero, or
LWI_TIMEOUT_INTR_ALL() is used.

Reviewed-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Reviewed-by: default avatarPatrick Farrell <paf@cray.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 672b63e5
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -1349,7 +1349,6 @@ out:
		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 @@ out:
				}
			}

			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,
			wait_event_idle_timeout(lock->l_waitq,
						lock->l_flags & wait_flags,
				     &lwi);
						obd_timeout * HZ);
			if (!ldlm_is_lvb_ready(lock)) {
				if (flags & LDLM_FL_TEST_LOCK)
					LDLM_LOCK_RELEASE(lock);
+4 −8
Original line number Diff line number Diff line
@@ -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,
		wait_event_idle_timeout(thread->t_ctl_waitq,
					thread_is_stopping(thread) ||
					thread_is_event(thread),
			     &lwi);
					c_time * HZ);

		if (thread_test_and_clear_flags(thread, SVC_STOPPING))
			break;
+5 −9
Original line number Diff line number Diff line
@@ -1151,10 +1151,9 @@ out:
	 */
	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 */
@@ -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_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.
+1 −4
Original line number Diff line number Diff line
@@ -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 @@ restart_bulk:
			       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;
	}
+6 −9
Original line number Diff line number Diff line
@@ -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_idle_timeout(rq_waitq,
					rq_state & (RQ_STOP | RQ_PRECLEANUP),
					to);

		/*
		 * iterate & processing through the list. for each cld, process
@@ -1628,9 +1627,7 @@ restart:

		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 @@ restart:
			 */
			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;
Loading