[PATCH 05/19] 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: James Simmons Signed-off-by: NeilBrown --- 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 | 11 - 14 files changed, 68 insertions(+), 103 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 773abe78708a..95bea351d21d 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_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); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 622245a5f049..a0e486b57e08 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_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))
Re: [PATCH 05/19] 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: James Simmons > Signed-off-by: NeilBrown > --- > 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 | 11 - > 14 files changed, 68 insertions(+), 103 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > index 773abe78708a..95bea351d21d 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_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); > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c > b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c > index 622245a5f049..a0e486b57e08 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_idle_timeout(thread->t_ctl_waitq, > + thread_is_stopping(thread) || > + thread_is_event(thread), > +
[PATCH 05/19] 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. Signed-off-by: NeilBrown --- 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 | 11 - 14 files changed, 68 insertions(+), 103 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 773abe78708a..95bea351d21d 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_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); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 622245a5f049..a0e486b57e08 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_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; dif