int __LNetMDUnlink(struct lnet_handle_md md_in, bool discard);
#define LNetMDUnlink(handle) __LNetMDUnlink(handle, false)
-void lnet_assert_handler_unused(lnet_handler_t handler);
+bool lnet_assert_handler_unused(lnet_handler_t handler, bool assert);
/** @} lnet_md */
/** \defgroup lnet_data Data movement operations
the_lnet.ln_mt_zombie_rstqs = NULL;
}
- lnet_assert_handler_unused(the_lnet.ln_mt_handler);
+ lnet_assert_handler_unused(the_lnet.ln_mt_handler, true);
the_lnet.ln_mt_handler = NULL;
lnet_portals_destroy();
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_assert_handler_unused(the_lnet.ln_ping_target_handler, true);
lnet_ping_target_destroy();
}
the_lnet.ln_push_target_nbytes = 0;
LNetClearLazyPortal(LNET_RESERVED_PORTAL);
- lnet_assert_handler_unused(the_lnet.ln_push_target_handler);
+ lnet_assert_handler_unused(the_lnet.ln_push_target_handler, true);
the_lnet.ln_push_target_handler = NULL;
}
list_add(&md->md_list, &container->rec_active);
}
-void lnet_assert_handler_unused(lnet_handler_t handler)
+bool lnet_assert_handler_unused(lnet_handler_t handler, bool assert)
{
struct lnet_res_container *container;
int cpt;
+ bool handler_in_use = false;
if (!handler)
- return;
+ return handler_in_use;
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);
+ list_for_each_entry(md, &container->rec_active, md_list) {
+ if (assert) {
+ LASSERT(md->md_handler != handler);
+ } else if (md->md_handler == handler) {
+ handler_in_use = true;
+ break;
+ }
+ }
lnet_res_unlock(cpt);
}
+ return handler_in_use;
}
EXPORT_SYMBOL(lnet_assert_handler_unused);
static int lnet_peer_discovery(void *arg)
{
struct lnet_peer *lp;
+ int retry = 3;
int rc;
wait_for_completion(&the_lnet.ln_started);
lnet_net_unlock(LNET_LOCK_EX);
}
+cleanup:
CDEBUG(D_NET, "stopping\n");
/*
* Clean up before telling lnet_peer_discovery_stop() that
}
lnet_net_unlock(LNET_LOCK_EX);
- lnet_assert_handler_unused(the_lnet.ln_dc_handler);
+ if (lnet_assert_handler_unused(the_lnet.ln_dc_handler, --retry <= 0))
+ goto cleanup;
+
the_lnet.ln_dc_handler = NULL;
the_lnet.ln_dc_state = LNET_DC_STATE_SHUTDOWN;
rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
LASSERT(rc == 0);
- lnet_assert_handler_unused(srpc_data.rpc_lnet_handler);
+ lnet_assert_handler_unused(srpc_data.rpc_lnet_handler, true);
fallthrough;
case SRPC_STATE_NI_INIT:
percpu_ref_kill(&ptlrpc_pending);
wait_for_completion(&ptlrpc_done);
- lnet_assert_handler_unused(ptlrpc_handler);
+ lnet_assert_handler_unused(ptlrpc_handler, true);
LNetNIFini();
}