when l_wait_event() is called with an lwi initialised with
LWI_TIMEOUT_INTERVAL(t1, t2, NULL, NUL),
waits for a total of t1 jiffies, but wakes up every t2 jiffies
to check the condition - incase the condition changed without
triggering a wakeup.
In (nearly) every case, t2 is one second.
So this is effectively a poll loop around wait_event_timeout.
So replace with with
seconds = t1;
while (seconds > 0 &&
wait_event_timeout(q, cond, cfs_time_seconds(1)) == 0)
seconds -= 1;
Then if seconds is zero at the end, the whole loop timed out.
In the one exception ("nearly" above) if t1 is small, t2 is set to one
jiffies, so we always wait a little bit and check the condition. For
that case, we count to "seconds >= 0" and adjust the timeout
accordingly when seconds == 0.
Note that in one case, the on_timeout function is
target_bulk_timeout() instead of NULL. As this always returns '1', it
behaves exactly like passing NULL.
Change-Id: I4cddbd2c28f07012cce7915489eedcb668c7e808
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/35973
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
#endif
#ifdef HAVE_SERVER_SUPPORT
#endif
#ifdef HAVE_SERVER_SUPPORT
-static int target_bulk_timeout(void *data)
-{
- ENTRY;
- /*
- * We don't fail the connection here, because having the export
- * killed makes the (vital) call to commitrw very sad.
- */
- RETURN(1);
-}
-
static inline const char *bulk2type(struct ptlrpc_request *req)
{
if (req->rq_bulk_read)
static inline const char *bulk2type(struct ptlrpc_request *req)
{
if (req->rq_bulk_read)
struct ptlrpc_request *req = desc->bd_req;
time64_t start = ktime_get_seconds();
time64_t deadline;
struct ptlrpc_request *req = desc->bd_req;
time64_t start = ktime_get_seconds();
time64_t deadline;
- struct l_wait_info lwi;
do {
time64_t timeoutl = deadline - ktime_get_seconds();
do {
time64_t timeoutl = deadline - ktime_get_seconds();
- long timeout_jiffies = timeoutl <= 0 ?
- 1 : cfs_time_seconds(timeoutl);
- lwi = LWI_TIMEOUT_INTERVAL(timeout_jiffies,
- cfs_time_seconds(1),
- target_bulk_timeout, desc);
- rc = l_wait_event(desc->bd_waitq,
- !ptlrpc_server_bulk_active(desc) ||
- exp->exp_failed ||
- exp->exp_conn_cnt >
- lustre_msg_get_conn_cnt(req->rq_reqmsg),
- &lwi);
- LASSERT(rc == 0 || rc == -ETIMEDOUT);
+ while (timeoutl >= 0 &&
+ wait_event_idle_timeout(
+ desc->bd_waitq,
+ !ptlrpc_server_bulk_active(desc) ||
+ exp->exp_failed ||
+ exp->exp_conn_cnt >
+ lustre_msg_get_conn_cnt(req->rq_reqmsg),
+ timeoutl ? cfs_time_seconds(1) : 1) == 0)
+ timeoutl -= 1;
+ rc = timeoutl < 0 ? -ETIMEDOUT : 0;
+
/* Wait again if we changed rq_deadline. */
rq_deadline = READ_ONCE(req->rq_deadline);
deadline = start + bulk_timeout;
/* Wait again if we changed rq_deadline. */
rq_deadline = READ_ONCE(req->rq_deadline);
deadline = start + bulk_timeout;
GOTO(cleanup, rc = 0);
while (test_bit(LAD_IN_DOUBLE_SCAN, &lad->lad_flags)) {
GOTO(cleanup, rc = 0);
while (test_bit(LAD_IN_DOUBLE_SCAN, &lad->lad_flags)) {
rc = lfsck_assistant_query_others(env, com);
if (lfsck_phase2_next_ready(lad))
goto p2_next;
rc = lfsck_assistant_query_others(env, com);
if (lfsck_phase2_next_ready(lad))
goto p2_next;
/* Pull LFSCK status on related targets once
* per 30 seconds if we are not notified. */
/* Pull LFSCK status on related targets once
* per 30 seconds if we are not notified. */
- lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(30),
- cfs_time_seconds(1),
- NULL, NULL);
- rc = l_wait_event(athread->t_ctl_waitq,
- lfsck_phase2_next_ready(lad) ||
- test_bit(LAD_EXIT, &lad->lad_flags) ||
- !thread_is_running(mthread),
- &lwi);
+ while (seconds > 0 &&
+ wait_event_idle_timeout(
+ athread->t_ctl_waitq,
+ lfsck_phase2_next_ready(lad) ||
+ test_bit(LAD_EXIT,
+ &lad->lad_flags) ||
+ !thread_is_running(mthread),
+ cfs_time_seconds(1)) == 0)
+ seconds -= 1;
if (unlikely(
test_bit(LAD_EXIT, &lad->lad_flags) ||
!thread_is_running(mthread)))
GOTO(cleanup, rc = 0);
if (unlikely(
test_bit(LAD_EXIT, &lad->lad_flags) ||
!thread_is_running(mthread)))
GOTO(cleanup, rc = 0);
- if (rc < 0)
- GOTO(cleanup, rc);
-
p2_next:
rc = lao->la_handler_p2(env, com);
if (rc != 0)
p2_next:
rc = lao->la_handler_p2(env, com);
if (rc != 0)
*/
static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
{
*/
static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
{
- int rc;
- struct l_wait_info lwi;
-
* unlinked before returning a req to the pool.
*/
for (;;) {
* unlinked before returning a req to the pool.
*/
for (;;) {
- /* The wq argument is ignored by user-space wait_event macros */
wait_queue_head_t *wq = (request->rq_set) ?
&request->rq_set->set_waitq :
&request->rq_reply_waitq;
wait_queue_head_t *wq = (request->rq_set) ?
&request->rq_set->set_waitq :
&request->rq_reply_waitq;
+ int seconds = LONG_UNLINK;
/*
* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs
*/
/*
* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs
*/
- lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
- cfs_time_seconds(1), NULL, NULL);
- rc = l_wait_event(*wq, !ptlrpc_client_recv_or_unlink(request),
- &lwi);
- if (rc == 0) {
+ while (seconds > 0 &&
+ wait_event_idle_timeout(
+ *wq,
+ !ptlrpc_client_recv_or_unlink(request),
+ cfs_time_seconds(1)) == 0)
+ seconds -= 1;
+ if (seconds > 0) {
ptlrpc_rqphase_move(request, request->rq_next_phase);
RETURN(1);
}
ptlrpc_rqphase_move(request, request->rq_next_phase);
RETURN(1);
}
- LASSERT(rc == -ETIMEDOUT);
DEBUG_REQ(D_WARNING, request,
"Unexpectedly long timeout receiving_reply=%d req_ulinked=%d reply_unlinked=%d",
request->rq_receiving_reply,
DEBUG_REQ(D_WARNING, request,
"Unexpectedly long timeout receiving_reply=%d req_ulinked=%d reply_unlinked=%d",
request->rq_receiving_reply,
*/
void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc)
{
*/
void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc)
{
- struct l_wait_info lwi;
- int rc;
-
LASSERT(!in_interrupt()); /* might sleep */
if (!ptlrpc_server_bulk_active(desc)) /* completed or */
LASSERT(!in_interrupt()); /* might sleep */
if (!ptlrpc_server_bulk_active(desc)) /* completed or */
for (;;) {
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
for (;;) {
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
- lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
- cfs_time_seconds(1), NULL, NULL);
- rc = l_wait_event(desc->bd_waitq,
- !ptlrpc_server_bulk_active(desc), &lwi);
- if (rc == 0)
+ int seconds = LONG_UNLINK;
+
+ while (seconds > 0 &&
+ wait_event_idle_timeout(desc->bd_waitq,
+ !ptlrpc_server_bulk_active(desc),
+ cfs_time_seconds(1)) == 0)
+ seconds -= 1;
+ if (seconds > 0)
- LASSERT(rc == -ETIMEDOUT);
CWARN("Unexpectedly long timeout: desc %p\n", desc);
}
}
CWARN("Unexpectedly long timeout: desc %p\n", desc);
}
}
int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async)
{
struct ptlrpc_bulk_desc *desc = req->rq_bulk;
int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async)
{
struct ptlrpc_bulk_desc *desc = req->rq_bulk;
- struct l_wait_info lwi;
- int rc;
ENTRY;
LASSERT(!in_interrupt()); /* might sleep */
ENTRY;
LASSERT(!in_interrupt()); /* might sleep */
* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs.
*/
* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs.
*/
- lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
- cfs_time_seconds(1), NULL, NULL);
- rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi);
- if (rc == 0) {
+ int seconds = LONG_UNLINK;
+
+ while (seconds > 0 &&
+ wait_event_idle_timeout(*wq,
+ !ptlrpc_client_bulk_active(req),
+ cfs_time_seconds(1)) == 0)
+ seconds -= 1;
+ if (seconds > 0) {
ptlrpc_rqphase_move(req, req->rq_next_phase);
RETURN(1);
}
ptlrpc_rqphase_move(req, req->rq_next_phase);
RETURN(1);
}
- LASSERT(rc == -ETIMEDOUT);
DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p",
desc);
}
DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p",
desc);
}
{
struct ptlrpc_service_part *svcpt;
struct ptlrpc_request_buffer_desc *rqbd;
{
struct ptlrpc_service_part *svcpt;
struct ptlrpc_request_buffer_desc *rqbd;
- struct l_wait_info lwi;
*/
spin_lock(&svcpt->scp_lock);
while (svcpt->scp_nrqbds_posted != 0) {
*/
spin_lock(&svcpt->scp_lock);
while (svcpt->scp_nrqbds_posted != 0) {
+ int seconds = LONG_UNLINK;
+
spin_unlock(&svcpt->scp_lock);
/*
* Network access will complete in finite time but
* the HUGE timeout lets us CWARN for visibility
* of sluggish NALs
*/
spin_unlock(&svcpt->scp_lock);
/*
* Network access will complete in finite time but
* the HUGE timeout lets us CWARN for visibility
* of sluggish NALs
*/
- lwi = LWI_TIMEOUT_INTERVAL(
- cfs_time_seconds(LONG_UNLINK),
- cfs_time_seconds(1), NULL, NULL);
- rc = l_wait_event(svcpt->scp_waitq,
- svcpt->scp_nrqbds_posted == 0, &lwi);
- if (rc == -ETIMEDOUT) {
+ while (seconds > 0 &&
+ wait_event_idle_timeout(
+ svcpt->scp_waitq,
+ svcpt->scp_nrqbds_posted == 0,
+ cfs_time_seconds(1)) == 0)
+ seconds -= 1;
+ if (seconds == 0) {
CWARN("Service %s waiting for request buffers\n",
svcpt->scp_service->srv_name);
}
CWARN("Service %s waiting for request buffers\n",
svcpt->scp_service->srv_name);
}