From: Mr NeilBrown Date: Wed, 20 Nov 2019 02:31:09 +0000 (+1100) Subject: LU-13005 lnet: drop refcounting from event queues. X-Git-Tag: 2.13.54~209 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c927c62f93feb66aa440c43e1b85ceb86863c01a LU-13005 lnet: drop refcounting from event queues. 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 Reviewed-on: https://review.whamcloud.com/36846 Reviewed-by: Chris Horn Reviewed-by: Serguei Smirnov Tested-by: jenkins Tested-by: Maloo Reviewed-by: Amir Shehata Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lnet/include/lnet/api.h b/lnet/include/lnet/api.h index a36510b..1bd0f94 100644 --- a/lnet/include/lnet/api.h +++ b/lnet/include/lnet/api.h @@ -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 */ diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 4e315f4..6486e83 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -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 { diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index e554429..110b13a 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -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); diff --git a/lnet/lnet/lib-eq.c b/lnet/lnet/lib-eq.c index 261eba5..4bcf3b4 100644 --- a/lnet/lnet/lib-eq.c +++ b/lnet/lnet/lib-eq.c @@ -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); diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c index 46b9c5c..caab997 100644 --- a/lnet/lnet/lib-md.c +++ b/lnet/lnet/lib-md.c @@ -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); diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index 1bb716e..57d21e2 100644 --- a/lnet/selftest/rpc.c +++ b/lnet/selftest/rpc.c @@ -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: