atomic_t lpni_refcount;
/* CPT this peer attached on */
int lpni_cpt;
+ /* state flags -- protected by lpni_lock */
+ unsigned lpni_state;
/* # refs from lnet_route_t::lr_gateway */
int lpni_rtr_refcount;
/* sequence number used to round robin over peer nis within a net */
/* primary NID of the peer */
lnet_nid_t lp_primary_nid;
- /* peer is Multi-Rail enabled peer */
- bool lp_multi_rail;
+ /* lock protecting peer state flags */
+ spinlock_t lp_lock;
+
+ /* peer state flags */
+ unsigned lp_state;
};
+#define LNET_PEER_MULTI_RAIL (1 << 0)
+
struct lnet_peer_net {
/* chain on peer block */
struct list_head lpn_on_peer_list;
return -EHOSTUNREACH;
}
- if (!peer->lp_multi_rail && lnet_get_num_peer_nis(peer) > 1) {
- lnet_net_unlock(cpt);
+ if (!lnet_peer_is_multi_rail(peer) &&
+ lnet_get_num_peer_nis(peer) > 1) {
CERROR("peer %s is declared to be non MR capable, "
"yet configured with more than one NID\n",
libcfs_nid2str(dst_nid));
if (msg->msg_type == LNET_MSG_REPLY ||
msg->msg_type == LNET_MSG_ACK ||
- !peer->lp_multi_rail ||
+ !lnet_peer_is_multi_rail(peer) ||
best_ni) {
/*
* for replies we want to respond on the same peer_ni we
* if the router is not multi-rail then use the best_gw
* found to send the message to
*/
- if (!peer->lp_multi_rail)
+ if (!lnet_peer_is_multi_rail(peer))
best_lpni = best_gw;
else
best_lpni = NULL;
* if the peer is not MR capable, then we should always send to it
* using the first NI in the NET we determined.
*/
- if (!peer->lp_multi_rail) {
+ if (!lnet_peer_is_multi_rail(peer)) {
if (!best_lpni) {
lnet_net_unlock(cpt);
CERROR("no route to %s\n",
INIT_LIST_HEAD(&lp->lp_on_lnet_peer_list);
INIT_LIST_HEAD(&lp->lp_peer_nets);
+ spin_lock_init(&lp->lp_lock);
lp->lp_primary_nid = nid;
/* TODO: update flags */
*
* TODO: update flags if necessary
*/
- if (mr && !lp->lp_multi_rail) {
- lp->lp_multi_rail = true;
- } else if (!mr && lp->lp_multi_rail) {
+ spin_lock(&lp->lp_lock);
+ if (mr && !(lp->lp_state & LNET_PEER_MULTI_RAIL)) {
+ lp->lp_state |= LNET_PEER_MULTI_RAIL;
+ } else if (!mr && (lp->lp_state & LNET_PEER_MULTI_RAIL)) {
/* The mr state is sticky. */
- CDEBUG(D_NET, "Cannot clear multi-flag from peer %s\n",
+ CDEBUG(D_NET, "Cannot clear multi-rail flag from peer %s\n",
libcfs_nid2str(nid));
}
+ spin_unlock(&lp->lp_lock);
return 0;
}
LASSERT(lp);
LASSERT(nid != LNET_NID_ANY);
- if (!mr && !lp->lp_multi_rail) {
+ spin_lock(&lp->lp_lock);
+ if (!mr && !(lp->lp_state & LNET_PEER_MULTI_RAIL)) {
+ spin_unlock(&lp->lp_lock);
CERROR("Cannot add nid %s to non-multi-rail peer %s\n",
libcfs_nid2str(nid),
libcfs_nid2str(lp->lp_primary_nid));
return -EPERM;
}
- if (!lp->lp_multi_rail)
- lp->lp_multi_rail = true;
+ if (!(lp->lp_state & LNET_PEER_MULTI_RAIL))
+ lp->lp_state |= LNET_PEER_MULTI_RAIL;
+ spin_unlock(&lp->lp_lock);
lpni = lnet_find_peer_ni_locked(nid);
if (!lpni)
return -ENOENT;
*primary_nid = lp->lp_primary_nid;
- *mr = lp->lp_multi_rail;
+ *mr = lnet_peer_is_multi_rail(lp);
*nid = lpni->lpni_nid;
snprintf(ni_info.cr_aliveness, LNET_MAX_STR_LEN, "NA");
if (lnet_isrouter(lpni) ||