Whamcloud - gitweb
LU-10467 lustre: use l_wait_event_abortable where appropriate. 75/35975/8
authorMr NeilBrown <neilb@suse.com>
Mon, 26 Aug 2019 05:59:07 +0000 (15:59 +1000)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Feb 2020 07:13:03 +0000 (07:13 +0000)
If the lwi passed to l_wait_event() was created with

    lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);

the effect is to wait with no timeout and blocking any
non-fatal signals.
For this, we now have l_wait_event_abortable(), or for one
case l_wait_event_abortable_exclusive();
So use those.

l_wait_event_abortable() will return -ERESTARTSYS if a signal was
received, while l_wait_event() returens -EINTR.  We need to be
careful to handle this difference.

Signed-off-by: Mr NeilBrown <neilb@suse.com>
Change-Id: Iadf0fab92fcfd46802766198dcbe6b6b349214fa
Reviewed-on: https://review.whamcloud.com/35975
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/llite_lib.c
lustre/obdclass/genops.c
lustre/obdclass/llog_obd.c
lustre/osc/osc_page.c
lustre/osc/osc_request.c
lustre/ptlrpc/import.c

index e384d64..240fad2 100644 (file)
@@ -1231,14 +1231,13 @@ void ll_put_super(struct super_block *sb)
 
        /* Wait for unstable pages to be committed to stable storage */
        if (force == 0) {
-               struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
-               rc = l_wait_event(sbi->ll_cache->ccc_unstable_waitq,
-                                 atomic_long_read(&sbi->ll_cache->ccc_unstable_nr) == 0,
-                                 &lwi);
+               rc = l_wait_event_abortable(
+                       sbi->ll_cache->ccc_unstable_waitq,
+                       atomic_long_read(&sbi->ll_cache->ccc_unstable_nr) == 0);
        }
 
        ccc_count = atomic_long_read(&sbi->ll_cache->ccc_unstable_nr);
-       if (force == 0 && rc != -EINTR)
+       if (force == 0 && rc != -ERESTARTSYS)
                LASSERTF(ccc_count == 0, "count: %li\n", ccc_count);
 
        /* We need to set force before the lov_disconnect in
index 092ed77..2c822cb 100644 (file)
@@ -1990,7 +1990,6 @@ static bool obd_request_slot_avail(struct client_obd *cli,
 int obd_get_request_slot(struct client_obd *cli)
 {
        struct obd_request_slot_waiter   orsw;
-       struct l_wait_info               lwi;
        int                              rc;
 
        spin_lock(&cli->cl_loi_list_lock);
@@ -2005,11 +2004,9 @@ int obd_get_request_slot(struct client_obd *cli)
        orsw.orsw_signaled = false;
        spin_unlock(&cli->cl_loi_list_lock);
 
-       lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
-       rc = l_wait_event(orsw.orsw_waitq,
-                         obd_request_slot_avail(cli, &orsw) ||
-                         orsw.orsw_signaled,
-                         &lwi);
+       rc = l_wait_event_abortable(orsw.orsw_waitq,
+                                   obd_request_slot_avail(cli, &orsw) ||
+                                   orsw.orsw_signaled);
 
        /* Here, we must take the lock to avoid the on-stack 'orsw' to be
         * freed but other (such as obd_put_request_slot) is using it. */
@@ -2021,6 +2018,7 @@ int obd_get_request_slot(struct client_obd *cli)
                        else
                                list_del(&orsw.orsw_entry);
                }
+               rc = -EINTR;
        }
 
        if (orsw.orsw_signaled) {
index 1d1f953..b0eddf9 100644 (file)
@@ -105,7 +105,6 @@ EXPORT_SYMBOL(__llog_ctxt_put);
 
 int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 {
-       struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
        struct obd_llog_group *olg;
        int rc, idx;
 
@@ -135,8 +134,8 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
                CERROR("Error %d while cleaning up ctxt %p\n",
                        rc, ctxt);
 
-       l_wait_event(olg->olg_waitq,
-                    llog_group_ctxt_null(olg, idx), &lwi);
+       l_wait_event_abortable(olg->olg_waitq,
+                              llog_group_ctxt_null(olg, idx));
 
        RETURN(rc);
 }
index 9dae62a..eabe5fd 100644 (file)
@@ -795,7 +795,6 @@ out:
 static int osc_lru_alloc(const struct lu_env *env, struct client_obd *cli,
                         struct osc_page *opg)
 {
-       struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
        struct osc_io *oio = osc_env_io(env);
        int rc = 0;
 
@@ -819,11 +818,13 @@ static int osc_lru_alloc(const struct lu_env *env, struct client_obd *cli,
                        continue;
 
                cond_resched();
-               rc = l_wait_event(osc_lru_waitq,
-                               atomic_long_read(cli->cl_lru_left) > 0,
-                               &lwi);
-               if (rc < 0)
+               rc = l_wait_event_abortable(
+                       osc_lru_waitq,
+                       atomic_long_read(cli->cl_lru_left) > 0);
+               if (rc < 0) {
+                       rc = -EINTR;
                        break;
+               }
        }
 
 out:
index cf3136e..6152adf 100644 (file)
@@ -613,17 +613,16 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
 
        req->rq_interpret_reply = osc_destroy_interpret;
        if (!osc_can_send_destroy(cli)) {
-               struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
-
                /*
                 * Wait until the number of on-going destroy RPCs drops
                 * under max_rpc_in_flight
                 */
-               rc = l_wait_event_exclusive(cli->cl_destroy_waitq,
-                                           osc_can_send_destroy(cli), &lwi);
+               rc = l_wait_event_abortable_exclusive(
+                       cli->cl_destroy_waitq,
+                       osc_can_send_destroy(cli));
                if (rc) {
                        ptlrpc_req_finished(req);
-                       RETURN(rc);
+                       RETURN(-EINTR);
                }
        }
 
index a21549e..3a4a48a 100644 (file)
@@ -496,12 +496,11 @@ int ptlrpc_reconnect_import(struct obd_import *imp)
        ptlrpc_disconnect_import(imp, 1);
        /* Wait for all invalidate calls to finish */
        if (atomic_read(&imp->imp_inval_count) > 0) {
-               struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
                int rc;
 
-               rc = l_wait_event(imp->imp_recovery_waitq,
-                                 (atomic_read(&imp->imp_inval_count) == 0),
-                                 &lwi);
+               rc = l_wait_event_abortable(
+                       imp->imp_recovery_waitq,
+                       (atomic_read(&imp->imp_inval_count) == 0));
                if (rc)
                        CERROR("Interrupted, inval=%d\n",
                               atomic_read(&imp->imp_inval_count));