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

staging: lustre: replace simple cases of l_wait_event() with wait_event().



When the lwi arg is full of zeros, l_wait_event() behaves almost
identically to the standard wait_event_idle() interface, so use that
instead.

l_wait_event() uses TASK_INTERRUPTIBLE, but blocks all signals.
wait_event_idle() uses the new TASK_IDLE and so avoids adding
to the load average without needing to block signals.

In one case, wait_event_idle_exclusive() is needed.

Also remove all l_wait_condition*() macros which were short-cuts
for setting lwi to {0}.

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 7f76eb1a
Loading
Loading
Loading
Loading
+1 −18
Original line number Diff line number Diff line
@@ -333,24 +333,7 @@ do { \
	__ret;						  \
})

#define l_wait_condition(wq, condition)			 \
({							      \
	struct l_wait_info lwi = { 0 };			 \
	l_wait_event(wq, condition, &lwi);		      \
})

#define l_wait_condition_exclusive(wq, condition)	       \
({							      \
	struct l_wait_info lwi = { 0 };			 \
	l_wait_event_exclusive(wq, condition, &lwi);	    \
})

#define l_wait_condition_exclusive_head(wq, condition)	  \
({							      \
	struct l_wait_info lwi = { 0 };			 \
	l_wait_event_exclusive_head(wq, condition, &lwi);       \
})

/** @} lib */


#endif /* _LUSTRE_LIB_H */
+1 −3
Original line number Diff line number Diff line
@@ -1913,14 +1913,12 @@ void ldlm_cancel_callback(struct ldlm_lock *lock)
		ldlm_set_bl_done(lock);
		wake_up_all(&lock->l_waitq);
	} else if (!ldlm_is_bl_done(lock)) {
		struct l_wait_info lwi = { 0 };

		/*
		 * The lock is guaranteed to have been canceled once
		 * returning from this function.
		 */
		unlock_res_and_lock(lock);
		l_wait_event(lock->l_waitq, is_bl_done(lock), &lwi);
		wait_event_idle(lock->l_waitq, is_bl_done(lock));
		lock_res_and_lock(lock);
	}
}
+3 −5
Original line number Diff line number Diff line
@@ -833,17 +833,15 @@ static int ldlm_bl_thread_main(void *arg)
	/* cannot use bltd after this, it is only on caller's stack */

	while (1) {
		struct l_wait_info lwi = { 0 };
		struct ldlm_bl_work_item *blwi = NULL;
		struct obd_export *exp = NULL;
		int rc;

		rc = ldlm_bl_get_work(blp, &blwi, &exp);
		if (!rc)
			l_wait_event_exclusive(blp->blp_waitq,
			wait_event_idle_exclusive(blp->blp_waitq,
						  ldlm_bl_get_work(blp, &blwi,
								&exp),
					       &lwi);
								   &exp));
		atomic_inc(&blp->blp_busy_threads);

		if (ldlm_bl_thread_need_create(blp, blwi))
+2 −3
Original line number Diff line number Diff line
@@ -1031,7 +1031,6 @@ static int ldlm_pools_thread_main(void *arg)

static int ldlm_pools_thread_start(void)
{
	struct l_wait_info lwi = { 0 };
	struct task_struct *task;

	if (ldlm_pools_thread)
@@ -1052,8 +1051,8 @@ static int ldlm_pools_thread_start(void)
		ldlm_pools_thread = NULL;
		return PTR_ERR(task);
	}
	l_wait_event(ldlm_pools_thread->t_ctl_waitq,
		     thread_is_running(ldlm_pools_thread), &lwi);
	wait_event_idle(ldlm_pools_thread->t_ctl_waitq,
			thread_is_running(ldlm_pools_thread));
	return 0;
}

+20 −30
Original line number Diff line number Diff line
@@ -864,7 +864,6 @@ static int ll_agl_thread(void *arg)
	struct ll_sb_info	*sbi    = ll_i2sbi(dir);
	struct ll_statahead_info *sai;
	struct ptlrpc_thread *thread;
	struct l_wait_info	lwi    = { 0 };

	sai = ll_sai_get(dir);
	thread = &sai->sai_agl_thread;
@@ -885,10 +884,9 @@ static int ll_agl_thread(void *arg)
	wake_up(&thread->t_ctl_waitq);

	while (1) {
		l_wait_event(thread->t_ctl_waitq,
		wait_event_idle(thread->t_ctl_waitq,
				!list_empty(&sai->sai_agls) ||
			     !thread_is_running(thread),
			     &lwi);
				!thread_is_running(thread));

		if (!thread_is_running(thread))
			break;
@@ -932,7 +930,6 @@ static int ll_agl_thread(void *arg)
static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
{
	struct ptlrpc_thread *thread = &sai->sai_agl_thread;
	struct l_wait_info    lwi    = { 0 };
	struct ll_inode_info  *plli;
	struct task_struct *task;

@@ -948,9 +945,8 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
		return;
	}

	l_wait_event(thread->t_ctl_waitq,
		     thread_is_running(thread) || thread_is_stopped(thread),
		     &lwi);
	wait_event_idle(thread->t_ctl_waitq,
			thread_is_running(thread) || thread_is_stopped(thread));
}

/* statahead thread main function */
@@ -968,7 +964,6 @@ static int ll_statahead_thread(void *arg)
	int		       first  = 0;
	int		       rc     = 0;
	struct md_op_data *op_data;
	struct l_wait_info	lwi    = { 0 };

	sai = ll_sai_get(dir);
	sa_thread = &sai->sai_thread;
@@ -1069,12 +1064,11 @@ static int ll_statahead_thread(void *arg)

			/* wait for spare statahead window */
			do {
				l_wait_event(sa_thread->t_ctl_waitq,
				wait_event_idle(sa_thread->t_ctl_waitq,
						!sa_sent_full(sai) ||
						sa_has_callback(sai) ||
						!list_empty(&sai->sai_agls) ||
					     !thread_is_running(sa_thread),
					     &lwi);
						!thread_is_running(sa_thread));
				sa_handle_callback(sai);

				spin_lock(&lli->lli_agl_lock);
@@ -1128,11 +1122,10 @@ static int ll_statahead_thread(void *arg)
	 * for file release to stop me.
	 */
	while (thread_is_running(sa_thread)) {
		l_wait_event(sa_thread->t_ctl_waitq,
		wait_event_idle(sa_thread->t_ctl_waitq,
				sa_has_callback(sai) ||
				!agl_list_empty(sai) ||
			     !thread_is_running(sa_thread),
			     &lwi);
				!thread_is_running(sa_thread));

		sa_handle_callback(sai);
	}
@@ -1145,9 +1138,8 @@ out:

		CDEBUG(D_READA, "stop agl thread: sai %p pid %u\n",
		       sai, (unsigned int)agl_thread->t_pid);
		l_wait_event(agl_thread->t_ctl_waitq,
			     thread_is_stopped(agl_thread),
			     &lwi);
		wait_event_idle(agl_thread->t_ctl_waitq,
				thread_is_stopped(agl_thread));
	} else {
		/* Set agl_thread flags anyway. */
		thread_set_flags(agl_thread, SVC_STOPPED);
@@ -1159,7 +1151,7 @@ out:
	 */
	while (sai->sai_sent != sai->sai_replied) {
		/* in case we're not woken up, timeout wait */
		lwi = LWI_TIMEOUT(msecs_to_jiffies(MSEC_PER_SEC >> 3),
		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);
@@ -1520,7 +1512,6 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
{
	struct ll_inode_info *lli = ll_i2info(dir);
	struct ll_statahead_info *sai = NULL;
	struct l_wait_info lwi = { 0 };
	struct ptlrpc_thread *thread;
	struct task_struct *task;
	struct dentry *parent = dentry->d_parent;
@@ -1570,9 +1561,8 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
		goto out;
	}

	l_wait_event(thread->t_ctl_waitq,
		     thread_is_running(thread) || thread_is_stopped(thread),
		     &lwi);
	wait_event_idle(thread->t_ctl_waitq,
			thread_is_running(thread) || thread_is_stopped(thread));
	ll_sai_put(sai);

	/*
Loading