X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Flnet%2Flib-ptl.c;h=b55e9934ef0abea780e5e98bca8105c72780a601;hb=26f85bf14573e7477abe82143dc6ef71509184b2;hp=621a27ac5a5c2706de908c8594696e3439068224;hpb=1cbd19abbed9dbfd3bbc485f0991cfaeb02b7dae;p=fs%2Flustre-release.git diff --git a/lnet/lnet/lib-ptl.c b/lnet/lnet/lib-ptl.c index 621a27a..b55e993 100644 --- a/lnet/lnet/lib-ptl.c +++ b/lnet/lnet/lib-ptl.c @@ -21,7 +21,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -264,10 +264,10 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg) { struct lnet_match_table *mtable; struct lnet_portal *ptl; - int nmaps; - int rotor; - int routed; - int cpt; + unsigned int nmaps; + unsigned int rotor; + unsigned int cpt; + bool routed; /* NB: called w/o lock */ LASSERT(info->mi_portal < the_lnet.ln_nportals); @@ -714,7 +714,7 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, lnet_ptl_unlock(ptl); } -void +static void lnet_ptl_cleanup(struct lnet_portal *ptl) { struct lnet_match_table *mtable; @@ -725,11 +725,6 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) LASSERT(list_empty(&ptl->ptl_msg_delayed)); LASSERT(list_empty(&ptl->ptl_msg_stealing)); -#ifndef __KERNEL__ -# ifdef HAVE_LIBPTHREAD - pthread_mutex_destroy(&ptl->ptl_lock); -# endif -#endif cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) { struct list_head *mhash; lnet_me_t *me; @@ -757,7 +752,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) ptl->ptl_mtables = NULL; } -int +static int lnet_ptl_setup(struct lnet_portal *ptl, int index) { struct lnet_match_table *mtable; @@ -775,13 +770,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index) ptl->ptl_index = index; INIT_LIST_HEAD(&ptl->ptl_msg_delayed); INIT_LIST_HEAD(&ptl->ptl_msg_stealing); -#ifdef __KERNEL__ spin_lock_init(&ptl->ptl_lock); -#else -# ifdef HAVE_LIBPTHREAD - pthread_mutex_init(&ptl->ptl_lock, NULL); -# endif -#endif cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) { /* the extra entry is for MEs with ignore bits */ LIBCFS_CPT_ALLOC(mhash, lnet_cpt_table(), i, @@ -900,20 +889,11 @@ LNetSetLazyPortal(int portal) } EXPORT_SYMBOL(LNetSetLazyPortal); -/** - * Turn off the lazy portal attribute. Delayed requests on the portal, - * if any, will be all dropped when this function returns. - * - * \param portal Index of the portal to disable the lazy attribute on. - * - * \retval 0 On success. - * \retval -EINVAL If \a portal is not a valid index. - */ int -LNetClearLazyPortal(int portal) +lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason) { struct lnet_portal *ptl; - struct list_head zombies = LIST_HEAD_INIT(zombies); + struct list_head zombies = LIST_HEAD_INIT(zombies); if (portal < 0 || portal >= the_lnet.ln_nportals) return -EINVAL; @@ -929,21 +909,48 @@ LNetClearLazyPortal(int portal) return 0; } - if (the_lnet.ln_shutdown) - CWARN("Active lazy portal %d on exit\n", portal); - else - CDEBUG(D_NET, "clearing portal %d lazy\n", portal); + if (ni != NULL) { + struct lnet_msg *msg, *tmp; + + /* grab all messages which are on the NI passed in */ + list_for_each_entry_safe(msg, tmp, &ptl->ptl_msg_delayed, + msg_list) { + if (msg->msg_rxpeer->lp_ni == ni) + list_move(&msg->msg_list, &zombies); + } + } else { + if (the_lnet.ln_shutdown) + CWARN("Active lazy portal %d on exit\n", portal); + else + CDEBUG(D_NET, "clearing portal %d lazy\n", portal); - /* grab all the blocked messages atomically */ - list_splice_init(&ptl->ptl_msg_delayed, &zombies); + /* grab all the blocked messages atomically */ + list_splice_init(&ptl->ptl_msg_delayed, &zombies); - lnet_ptl_unsetopt(ptl, LNET_PTL_LAZY); + lnet_ptl_unsetopt(ptl, LNET_PTL_LAZY); + } lnet_ptl_unlock(ptl); lnet_res_unlock(LNET_LOCK_EX); - lnet_drop_delayed_msg_list(&zombies, "Clearing lazy portal attr"); + lnet_drop_delayed_msg_list(&zombies, reason); return 0; } + +/** + * Turn off the lazy portal attribute. Delayed requests on the portal, + * if any, will be all dropped when this function returns. + * + * \param portal Index of the portal to disable the lazy attribute on. + * + * \retval 0 On success. + * \retval -EINVAL If \a portal is not a valid index. + */ +int +LNetClearLazyPortal(int portal) +{ + return lnet_clear_lazy_portal(NULL, portal, + "Clearing lazy portal attr"); +} EXPORT_SYMBOL(LNetClearLazyPortal);