Whamcloud - gitweb
LU-13005 lnet: drop refcounting from event queues. 46/36846/10
authorMr NeilBrown <neilb@suse.de>
Wed, 20 Nov 2019 02:31:09 +0000 (13:31 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 14 Apr 2020 08:10:01 +0000 (08:10 +0000)
The refcount is no longer incremented or decremented
as there is no interesting state and no long term
references.  Nothing checks if LNetEQFree returns -EBUSY
any more - though a few calls LASSERT() that the return
value is 0.

So discard the refcounting, change LNetEQFree to return
'void', and remove all the LASSERTs.

Change-Id: I976834e7c6193765948e3b1a4f02069e33cdbe1e
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/36846
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/api.h
lnet/include/lnet/lib-types.h
lnet/lnet/api-ni.c
lnet/lnet/lib-eq.c
lnet/lnet/lib-md.c
lnet/selftest/rpc.c

index a36510b..1bd0f94 100644 (file)
@@ -152,7 +152,7 @@ int LNetMDUnlink(struct lnet_handle_md md_in);
 struct lnet_eq *
 LNetEQAlloc(lnet_eq_handler_t handler);
 
-int LNetEQFree(struct lnet_eq *eventq_in);
+void LNetEQFree(struct lnet_eq *eventq_in);
 
 /** @} lnet_eq */
 
index 4e315f4..6486e83 100644 (file)
@@ -184,7 +184,6 @@ struct lnet_libhandle {
 
 struct lnet_eq {
        lnet_eq_handler_t       eq_callback;
-       int                     **eq_refs;      /* percpt refcount for EQ */
 };
 
 struct lnet_me {
index e554429..110b13a 100644 (file)
@@ -1254,8 +1254,6 @@ lnet_prepare(lnet_pid_t requested_pid)
 static int
 lnet_unprepare (void)
 {
-       int rc;
-
        /* NB no LNET_LOCK since this is the last reference.  All LND instances
         * have shut down already, so it is safe to unlink and free all
         * descriptors, even those that appear committed to a network op (eg MD
@@ -1273,9 +1271,8 @@ lnet_unprepare (void)
        }
 
        if (the_lnet.ln_mt_eq) {
-               rc = LNetEQFree(the_lnet.ln_mt_eq);
+               LNetEQFree(the_lnet.ln_mt_eq);
                the_lnet.ln_mt_eq = NULL;
-               LASSERT(rc == 0);
        }
 
        lnet_portals_destroy();
@@ -1697,7 +1694,7 @@ lnet_ping_target_setup(struct lnet_ping_buffer **ppbuf,
        };
        struct lnet_me *me;
        struct lnet_md md = { NULL };
-       int rc, rc2;
+       int rc;
 
        if (set_eq) {
                the_lnet.ln_ping_target_eq =
@@ -1751,10 +1748,9 @@ fail_decref_ping_buffer:
        lnet_ping_buffer_decref(*ppbuf);
        *ppbuf = NULL;
 fail_free_eq:
-       if (set_eq) {
-               rc2 = LNetEQFree(the_lnet.ln_ping_target_eq);
-               LASSERT(rc2 == 0);
-       }
+       if (set_eq)
+               LNetEQFree(the_lnet.ln_ping_target_eq);
+
        return rc;
 }
 
@@ -1855,13 +1851,10 @@ lnet_ping_target_update(struct lnet_ping_buffer *pbuf,
 static void
 lnet_ping_target_fini(void)
 {
-       int             rc;
-
        lnet_ping_md_unlink(the_lnet.ln_ping_target,
                            &the_lnet.ln_ping_target_md);
 
-       rc = LNetEQFree(the_lnet.ln_ping_target_eq);
-       LASSERT(rc == 0);
+       LNetEQFree(the_lnet.ln_ping_target_eq);
 
        lnet_ping_target_destroy();
 }
@@ -4280,10 +4273,7 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
        rc = pbuf->pb_info.pi_nnis;
 
  fail_free_eq:
-       rc2 = LNetEQFree(eq);
-       if (rc2 != 0)
-               CERROR("rc2 %d\n", rc2);
-       LASSERT(rc2 == 0);
+       LNetEQFree(eq);
 
  fail_ping_buffer_decref:
        lnet_ping_buffer_decref(pbuf);
index 261eba5..4bcf3b4 100644 (file)
@@ -66,19 +66,7 @@ LNetEQAlloc(lnet_eq_handler_t callback)
 
        eq->eq_callback = callback;
 
-       eq->eq_refs = cfs_percpt_alloc(lnet_cpt_table(),
-                                      sizeof(*eq->eq_refs[0]));
-       if (eq->eq_refs == NULL)
-               goto failed;
-
        return eq;
-
-failed:
-       if (eq->eq_refs != NULL)
-               cfs_percpt_free(eq->eq_refs);
-
-       lnet_eq_free(eq);
-       return ERR_PTR(-ENOMEM);
 }
 EXPORT_SYMBOL(LNetEQAlloc);
 
@@ -88,45 +76,11 @@ EXPORT_SYMBOL(LNetEQAlloc);
  *
  * \param eq The event queue to be released.
  *
- * \retval 0 If the EQ is not in use and freed.
- * \retval -EBUSY  If the EQ is still in use by some MDs.
  */
-int
+void
 LNetEQFree(struct lnet_eq *eq)
 {
-       int             **refs = NULL;
-       int             *ref;
-       int             rc = 0;
-       int             i;
-
-       lnet_res_lock(LNET_LOCK_EX);
-       /* NB: hold lnet_eq_wait_lock for EQ link/unlink, so we can do
-        * both EQ lookup and poll event with only lnet_eq_wait_lock */
-       lnet_eq_wait_lock();
-
-       cfs_percpt_for_each(ref, i, eq->eq_refs) {
-               LASSERT(*ref >= 0);
-               if (*ref == 0)
-                       continue;
-
-               CDEBUG(D_NET, "Event equeue (%d: %d) busy on destroy.\n",
-                      i, *ref);
-               rc = -EBUSY;
-               goto out;
-       }
-
-       /* stash for free after lock dropped */
-       refs    = eq->eq_refs;
-
        lnet_eq_free(eq);
- out:
-       lnet_eq_wait_unlock();
-       lnet_res_unlock(LNET_LOCK_EX);
-
-       if (refs != NULL)
-               cfs_percpt_free(refs);
-
-       return rc;
 }
 EXPORT_SYMBOL(LNetEQFree);
 
index 46b9c5c..caab997 100644 (file)
@@ -68,13 +68,6 @@ lnet_md_unlink(struct lnet_libmd *md)
 
        CDEBUG(D_NET, "Unlinking md %p\n", md);
 
-       if (md->md_eq != NULL) {
-               int     cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie);
-
-               LASSERT(*md->md_eq->eq_refs[cpt] > 0);
-               (*md->md_eq->eq_refs[cpt])--;
-       }
-
        LASSERT(!list_empty(&md->md_list));
        list_del_init(&md->md_list);
        lnet_md_free(md);
@@ -261,10 +254,8 @@ lnet_md_link(struct lnet_libmd *md, struct lnet_eq *eq, int cpt)
         * maybe there we shouldn't even allow LNET_EQ_NONE!)
         * LASSERT (eq == NULL);
         */
-       if (eq) {
+       if (eq)
                md->md_eq = eq;
-               (*md->md_eq->eq_refs[cpt])++;
-       }
 
        lnet_res_lh_initialize(container, &md->md_lh);
 
index 1bb716e..57d21e2 100644 (file)
@@ -1680,8 +1680,7 @@ srpc_shutdown (void)
                rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
                rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
                LASSERT(rc == 0);
-               rc = LNetEQFree(srpc_data.rpc_lnet_eq);
-               LASSERT(rc == 0); /* the EQ should have no user by now */
+               LNetEQFree(srpc_data.rpc_lnet_eq);
                /* fallthrough */
 
        case SRPC_STATE_NI_INIT: