Whamcloud - gitweb
LU-10467 ptlrpc: convert waiting in sptlrpc_req_refresh_ctx() 87/35987/10
authorMr NeilBrown <neilb@suse.com>
Mon, 30 Dec 2019 15:01:24 +0000 (10:01 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 10 Jan 2020 07:40:35 +0000 (07:40 +0000)
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>
lustre/ptlrpc/sec.c

index a65e430..808fbd8 100644 (file)
@@ -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: