The l_wait_event call in sptlrpc_req_refresh_ctx() is somewhat complex
as it is passed both an on_timeout and on_signal handler, and
on_timeout doesn't return a constant value.
The net effect is to wait for the timeout with signals blocked. Then,
if the condition still isn't true, run the on_timeout handler and if
that returns zero, wait again - indefinitely this time - and allow
some signals. If a signal was received, call the on_signal handler.
This is fairly straight forward to write out in C, as shown in the
patch.
Change-Id: I7f9cfb8a8ff234bed4045ab21b53d018337cd615
Signed-off-by: Mr NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/35987
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
-int ctx_refresh_timeout(void *data)
+int ctx_refresh_timeout(struct ptlrpc_request *req)
- struct ptlrpc_request *req = data;
int rc;
/* conn_cnt is needed in expire_one_request */
int rc;
/* conn_cnt is needed in expire_one_request */
-void ctx_refresh_interrupt(void *data)
+void ctx_refresh_interrupt(struct ptlrpc_request *req)
- struct ptlrpc_request *req = data;
spin_lock(&req->rq_lock);
req->rq_intr = 1;
spin_lock(&req->rq_lock);
req->rq_intr = 1;
{
struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
struct ptlrpc_sec *sec;
{
struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
struct ptlrpc_sec *sec;
- struct l_wait_info lwi;
req->rq_restart = 0;
spin_unlock(&req->rq_lock);
req->rq_restart = 0;
spin_unlock(&req->rq_lock);
- lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout),
- ctx_refresh_timeout,
- ctx_refresh_interrupt, req);
- rc = l_wait_event(req->rq_reply_waitq, ctx_check_refresh(ctx), &lwi);
+ if (wait_event_idle_timeout(req->rq_reply_waitq,
+ ctx_check_refresh(ctx),
+ cfs_time_seconds(timeout)) == 0) {
+ rc = -ETIMEDOUT;
+ if (!ctx_refresh_timeout(req) &&
+ l_wait_event_abortable(req->rq_reply_waitq,
+ ctx_check_refresh(ctx))
+ == -ERESTARTSYS) {
+ rc = -EINTR;
+ ctx_refresh_interrupt(req);
+ }
+ }
/*
* following cases could lead us here:
/*
* following cases could lead us here: