Whamcloud - gitweb
LU-13005 lnet: Support checking for MD leaks. 59/38059/4
authorMr NeilBrown <neilb@suse.de>
Wed, 25 Mar 2020 05:26:28 +0000 (16:26 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 14 Apr 2020 08:10:53 +0000 (08:10 +0000)
Since we dropped the refcounting on LNetEQ we no longer get
confirmation that all MDs for a given handler a gone by the
time they should be.

So add lnet_assert_handler_unused() which searches the per-cpt
containers and ensures there are no MDs for a given handler, and call
that are the same place that we used to call LNetEQFree().

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ic04e5b4f67a79055c49994bd1d92e275fa71dd4b
Reviewed-on: https://review.whamcloud.com/38059
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/api.h
lnet/lnet/api-ni.c
lnet/lnet/lib-md.c
lnet/lnet/peer.c
lnet/selftest/rpc.c
lustre/ptlrpc/events.c

index 02b43ce..bc6e9d9 100644 (file)
@@ -128,6 +128,8 @@ int LNetMDBind(struct lnet_md        md_in,
               struct lnet_handle_md *md_handle_out);
 
 int LNetMDUnlink(struct lnet_handle_md md_in);
+
+void lnet_assert_handler_unused(lnet_handler_t handler);
 /** @} lnet_md */
 
 /** \defgroup lnet_data Data movement operations
index c5ffd6d..5922a6a 100644 (file)
@@ -1270,6 +1270,7 @@ lnet_unprepare (void)
                the_lnet.ln_mt_zombie_rstqs = NULL;
        }
 
+       lnet_assert_handler_unused(the_lnet.ln_mt_handler);
        the_lnet.ln_mt_handler = NULL;
 
        lnet_portals_destroy();
@@ -1842,6 +1843,7 @@ lnet_ping_target_fini(void)
        lnet_ping_md_unlink(the_lnet.ln_ping_target,
                            &the_lnet.ln_ping_target_md);
 
+       lnet_assert_handler_unused(the_lnet.ln_ping_target_handler);
        lnet_ping_target_destroy();
 }
 
@@ -2015,6 +2017,7 @@ static void lnet_push_target_fini(void)
        the_lnet.ln_push_target_nnis = 0;
 
        LNetClearLazyPortal(LNET_RESERVED_PORTAL);
+       lnet_assert_handler_unused(the_lnet.ln_push_target_handler);
        the_lnet.ln_push_target_handler = NULL;
 }
 
index 0d1cc3e..de72e45 100644 (file)
@@ -264,6 +264,24 @@ lnet_md_link(struct lnet_libmd *md, lnet_handler_t handler, int cpt)
        return 0;
 }
 
+void lnet_assert_handler_unused(lnet_handler_t handler)
+{
+       struct lnet_res_container *container;
+       int cpt;
+
+       if (!handler)
+               return;
+       cfs_percpt_for_each(container, cpt, the_lnet.ln_md_containers) {
+               struct lnet_libmd *md;
+
+               lnet_res_lock(cpt);
+               list_for_each_entry(md, &container->rec_active, md_list)
+                       LASSERT(md->md_handler != handler);
+               lnet_res_unlock(cpt);
+       }
+}
+EXPORT_SYMBOL(lnet_assert_handler_unused);
+
 /* must be called with lnet_res_lock held */
 void
 lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev)
index c77417a..f4c45ed 100644 (file)
@@ -3475,6 +3475,7 @@ static int lnet_peer_discovery(void *arg)
        }
        lnet_net_unlock(LNET_LOCK_EX);
 
+       lnet_assert_handler_unused(the_lnet.ln_dc_handler);
        the_lnet.ln_dc_handler = NULL;
 
        the_lnet.ln_dc_state = LNET_DC_STATE_SHUTDOWN;
index 5ebd0e5..99e3774 100644 (file)
@@ -1674,6 +1674,7 @@ srpc_shutdown (void)
                rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
                rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
                LASSERT(rc == 0);
+               lnet_assert_handler_unused(srpc_data.rpc_lnet_handler);
                /* fallthrough */
 
        case SRPC_STATE_NI_INIT:
index 0578529..52be97b 100644 (file)
@@ -567,6 +567,7 @@ static void ptlrpc_ni_fini(void)
        percpu_ref_kill(&ptlrpc_pending);
        wait_for_completion(&ptlrpc_done);
 
+       lnet_assert_handler_unused(ptlrpc_handler);
        LNetNIFini();
 }