From c1fad6a9a583b395c23ea1a102f1b67c50640f6f Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 30 Dec 2019 10:01:24 -0500 Subject: [PATCH] LU-10467 ptlrpc: convert waiting in sptlrpc_req_refresh_ctx() 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 Reviewed-on: https://review.whamcloud.com/35987 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/ptlrpc/sec.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index a65e430..808fbd8 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -631,9 +631,8 @@ int ctx_check_refresh(struct ptlrpc_cli_ctx *ctx) } static -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 */ @@ -653,9 +652,8 @@ int ctx_refresh_timeout(void *data) } static -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; @@ -689,7 +687,6 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; struct ptlrpc_sec *sec; - struct l_wait_info lwi; int rc; ENTRY; @@ -823,10 +820,18 @@ again: 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: -- 1.8.3.1