#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)
struct ptlrpc_request *req = desc->bd_req;
time64_t start = ktime_get_seconds();
time64_t deadline;
- struct l_wait_info lwi;
int rc = 0;
ENTRY;
do {
time64_t timeoutl = deadline - ktime_get_seconds();
- long timeout_jiffies = timeoutl <= 0 ?
- 1 : cfs_time_seconds(timeoutl);
time64_t rq_deadline;
- 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;
GOTO(cleanup, rc = 0);
while (test_bit(LAD_IN_DOUBLE_SCAN, &lad->lad_flags)) {
+ int seconds = 30;
+
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. */
- 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 (rc == -ETIMEDOUT)
+ if (seconds == 0)
continue;
- if (rc < 0)
- GOTO(cleanup, rc);
-
p2_next:
rc = lao->la_handler_p2(env, com);
if (rc != 0)
*/
static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
{
- int rc;
- struct l_wait_info lwi;
-
/*
* Might sleep.
*/
* 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;
+ int seconds = LONG_UNLINK;
/*
* 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);
}
- LASSERT(rc == -ETIMEDOUT);
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)
{
- struct l_wait_info lwi;
- int rc;
-
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 */
- 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)
return;
- LASSERT(rc == -ETIMEDOUT);
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;
- struct l_wait_info lwi;
- int rc;
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.
*/
- 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);
}
- LASSERT(rc == -ETIMEDOUT);
DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p",
desc);
}
{
struct ptlrpc_service_part *svcpt;
struct ptlrpc_request_buffer_desc *rqbd;
- struct l_wait_info lwi;
int rc;
int i;
*/
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
*/
- 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);
}