for (j = 0; j < LNET_PEER_HASH_SIZE; j++)
LASSERT(list_empty(&hash[j]));
- LIBCFS_FREE(hash, LNET_PEER_HASH_SIZE * sizeof(*hash));
+ CFS_FREE_PTR_ARRAY(hash, LNET_PEER_HASH_SIZE);
}
cfs_percpt_free(the_lnet.ln_peer_tables);
"Waiting for %d zombies on peer table\n",
ptable->pt_zombies);
}
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(cfs_time_seconds(1) >> 1);
+ schedule_timeout_uninterruptible(cfs_time_seconds(1) >> 1);
spin_lock(&ptable->pt_zombie_lock);
}
spin_unlock(&ptable->pt_zombie_lock);
if (oldnids) {
size = sizeof(*nids) * (lpni->lpni_pref_nnids - 1);
- LIBCFS_FREE(oldnids, sizeof(*oldnids) * size);
+ CFS_FREE_PTR_ARRAY(oldnids, size);
}
out:
if (rc == -EEXIST && (lpni->lpni_state & LNET_PEER_NI_NON_MR_PREF)) {
if (oldnids) {
size = sizeof(*nids) * (lpni->lpni_pref_nnids + 1);
- LIBCFS_FREE(oldnids, sizeof(*oldnids) * size);
+ CFS_FREE_PTR_ARRAY(oldnids, size);
}
out:
CDEBUG(D_NET, "peer %s nid %s: %d\n",
/* Add peer_ni to peer_net */
lpni->lpni_peer_net = lpn;
list_add_tail(&lpni->lpni_peer_nis, &lpn->lpn_peer_nis);
+ lnet_update_peer_net_healthv(lpni);
lnet_peer_net_addref_locked(lpn);
/* Add peer_net to peer */
ptable->pt_zombies--;
spin_unlock(&ptable->pt_zombie_lock);
- if (lpni->lpni_pref_nnids > 1) {
- LIBCFS_FREE(lpni->lpni_pref.nids,
- sizeof(*lpni->lpni_pref.nids) * lpni->lpni_pref_nnids);
- }
+ if (lpni->lpni_pref_nnids > 1)
+ CFS_FREE_PTR_ARRAY(lpni->lpni_pref.nids, lpni->lpni_pref_nnids);
+
LIBCFS_FREE(lpni, sizeof(*lpni));
lnet_peer_net_decref_locked(lpn);
lp->lp_state &= ~LNET_PEER_ROUTER_ENABLED;
spin_unlock(&lp->lp_lock);
- nnis = MAX(lp->lp_nnis, pbuf->pb_info.pi_nnis);
- LIBCFS_ALLOC(curnis, nnis * sizeof(*curnis));
- LIBCFS_ALLOC(addnis, nnis * sizeof(*addnis));
- LIBCFS_ALLOC(delnis, nnis * sizeof(*delnis));
+ nnis = max_t(int, lp->lp_nnis, pbuf->pb_info.pi_nnis);
+ CFS_ALLOC_PTR_ARRAY(curnis, nnis);
+ CFS_ALLOC_PTR_ARRAY(addnis, nnis);
+ CFS_ALLOC_PTR_ARRAY(delnis, nnis);
if (!curnis || !addnis || !delnis) {
rc = -ENOMEM;
goto out;
*/
rc = 0;
out:
- LIBCFS_FREE(curnis, nnis * sizeof(*curnis));
- LIBCFS_FREE(addnis, nnis * sizeof(*addnis));
- LIBCFS_FREE(delnis, nnis * sizeof(*delnis));
+ CFS_FREE_PTR_ARRAY(curnis, nnis);
+ CFS_FREE_PTR_ARRAY(addnis, nnis);
+ CFS_FREE_PTR_ARRAY(delnis, nnis);
lnet_ping_buffer_decref(pbuf);
CDEBUG(D_NET, "peer %s (%p): %d\n", libcfs_nid2str(lp->lp_primary_nid), lp, rc);
pnid = lnet_peer_select_nid(lp);
lnet_net_unlock(cpt);
- nnis = MAX(lp->lp_data_nnis, LNET_INTERFACES_MIN);
+ nnis = max(lp->lp_data_nnis, LNET_INTERFACES_MIN);
rc = lnet_send_ping(pnid, &lp->lp_ping_mdh, nnis, lp,
- the_lnet.ln_dc_eqh, false);
+ the_lnet.ln_dc_eq, false);
/*
* if LNetMDBind in lnet_send_ping fails we need to decrement the
md.threshold = 2; /* Put/Ack */
md.max_size = 0;
md.options = 0;
- md.eq_handle = the_lnet.ln_dc_eqh;
+ md.eq_handle = the_lnet.ln_dc_eq;
md.user_ptr = lp;
rc = LNetMDBind(md, LNET_UNLINK, &lp->lp_push_mdh);
wait_for_completion(&the_lnet.ln_started);
CDEBUG(D_NET, "started\n");
- cfs_block_allsigs();
for (;;) {
if (lnet_peer_discovery_wait_for_work())
lnet_push_target_resize();
lnet_net_lock(LNET_LOCK_EX);
- if (the_lnet.ln_dc_state == LNET_DC_STATE_STOPPING)
+ if (the_lnet.ln_dc_state == LNET_DC_STATE_STOPPING) {
+ lnet_net_unlock(LNET_LOCK_EX);
break;
+ }
/*
* Process all incoming discovery work requests. When
/* Queue cleanup 2: wait for the expired queue to clear. */
while (!list_empty(&the_lnet.ln_dc_expired))
- schedule_timeout(cfs_time_seconds(1));
+ schedule_timeout_uninterruptible(cfs_time_seconds(1));
/* Queue cleanup 3: clear the request queue. */
lnet_net_lock(LNET_LOCK_EX);
}
lnet_net_unlock(LNET_LOCK_EX);
- LNetEQFree(the_lnet.ln_dc_eqh);
- LNetInvalidateEQHandle(&the_lnet.ln_dc_eqh);
+ LNetEQFree(the_lnet.ln_dc_eq);
+ the_lnet.ln_dc_eq = NULL;
the_lnet.ln_dc_state = LNET_DC_STATE_SHUTDOWN;
wake_up(&the_lnet.ln_dc_waitq);
int lnet_peer_discovery_start(void)
{
struct task_struct *task;
- int rc;
+ int rc = 0;
if (the_lnet.ln_dc_state != LNET_DC_STATE_SHUTDOWN)
return -EALREADY;
- rc = LNetEQAlloc(0, lnet_discovery_event_handler, &the_lnet.ln_dc_eqh);
- if (rc != 0) {
+ the_lnet.ln_dc_eq = LNetEQAlloc(lnet_discovery_event_handler);
+ if (IS_ERR(the_lnet.ln_dc_eq)) {
+ rc = PTR_ERR(the_lnet.ln_dc_eq);
CERROR("Can't allocate discovery EQ: %d\n", rc);
return rc;
}
rc = PTR_ERR(task);
CERROR("Can't start peer discovery thread: %d\n", rc);
- LNetEQFree(the_lnet.ln_dc_eqh);
- LNetInvalidateEQHandle(&the_lnet.ln_dc_eqh);
+ LNetEQFree(the_lnet.ln_dc_eq);
+ the_lnet.ln_dc_eq = NULL;
the_lnet.ln_dc_state = LNET_DC_STATE_SHUTDOWN;
}
if (list_empty(&lpni->lpni_recovery) &&
atomic_read(&lpni->lpni_healthv) < LNET_MAX_HEALTH_VALUE) {
- CERROR("lpni %s added to recovery queue. Health = %d\n",
+ CDEBUG(D_NET, "lpni %s added to recovery queue. Health = %d\n",
libcfs_nid2str(lpni->lpni_nid),
atomic_read(&lpni->lpni_healthv));
list_add_tail(&lpni->lpni_recovery, &the_lnet.ln_mt_peerNIRecovq);