From e531dc437c56a08a65de9074a511faa55184712b Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Sun, 24 Jun 2012 22:52:19 +0800 Subject: [PATCH] LU-56 lnet: multiple cleanups for inspection This patch covered multiple cleanups for previous patches: - user "features" to replace "versions" of router checker ping - code cleanup for lnet_ni_alloc - fix a loading issue on 32-bit system - comments cleanup and some small changes - coding style cleanup Signed-off-by: Liang Zhen Change-Id: I96e5fa260d93082851c5146883df1a5b8a96ef42 Reviewed-on: http://review.whamcloud.com/3180 Reviewed-by: Bobi Jam Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger --- lnet/include/lnet/lib-lnet.h | 2 +- lnet/include/lnet/lib-types.h | 42 +++++++++++++++-------------- lnet/lnet/api-ni.c | 42 ++++++++++++++--------------- lnet/lnet/config.c | 30 +++++++++++++-------- lnet/lnet/lib-eq.c | 28 ++++++++++---------- lnet/lnet/lib-md.c | 6 ++--- lnet/lnet/lib-me.c | 14 +++++----- lnet/lnet/lib-move.c | 23 ++++++++-------- lnet/lnet/lib-msg.c | 4 +-- lnet/lnet/lib-ptl.c | 2 +- lnet/lnet/peer.c | 6 ++--- lnet/lnet/router.c | 61 +++++++++++++++++++++---------------------- lnet/lnet/router_proc.c | 3 ++- 13 files changed, 136 insertions(+), 127 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 2eab4a6..ef2a5b23 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -69,7 +69,7 @@ extern lnet_t the_lnet; /* THE network */ # else /* 64-bit system */ /* * 256 CPTs for thousands of CPUs, allowing more CPTs might make us - * under risk of consuming all lh_cooke. + * under risk of consuming all lh_cookie. */ # define LNET_CPT_MAX_BITS 8 # endif /* BITS_PER_LONG == 32 */ diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index d39553a..ca4512a 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -317,9 +317,7 @@ typedef struct { #define LNET_COOKIE_TYPE_ME 2 #define LNET_COOKIE_TYPE_EQ 3 #define LNET_COOKIE_TYPE_BITS 2 -#define LNET_COOKIE_TYPES (1 << LNET_COOKIE_TYPE_BITS) -/* LNET_COOKIE_TYPES must be a power of 2, so the cookie type can be - * extracted by masking with (LNET_COOKIE_TYPES - 1) */ +#define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL) struct lnet_ni; /* forward ref */ @@ -443,19 +441,23 @@ typedef struct lnet_ni { char *ni_interfaces[LNET_MAX_INTERFACES]; } lnet_ni_t; -#define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL -enum { - LNET_PROTO_PING_UNKNOWN = 0, /* unknown */ - LNET_PROTO_PING_VERSION_1 = 1, /* old version */ - LNET_PROTO_PING_VERSION = 2, /* current version */ -}; +#define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL + +/* NB: value of these features equal to LNET_PROTO_PING_VERSION_x + * of old LNet, so there shouldn't be any compatibility issue */ +#define LNET_PING_FEAT_INVAL (0) /* no feature */ +#define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */ +#define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */ + +#define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \ + LNET_PING_FEAT_NI_STATUS) typedef struct { - __u32 pi_magic; - __u32 pi_version; - lnet_pid_t pi_pid; - __u32 pi_nnis; - lnet_ni_status_t pi_ni[0]; + __u32 pi_magic; + __u32 pi_features; + lnet_pid_t pi_pid; + __u32 pi_nnis; + lnet_ni_status_t pi_ni[0]; } WIRE_ATTR lnet_ping_info_t; /* router checker data, per router */ @@ -496,8 +498,8 @@ typedef struct lnet_peer { int lp_cpt; /* CPT this peer attached on */ /* # refs from lnet_route_t::lr_gateway */ int lp_rtr_refcount; - /* returned RC ping version */ - unsigned int lp_ping_version; + /* returned RC ping features */ + unsigned int lp_ping_feats; cfs_list_t lp_routes; /* routers on this peer */ lnet_rc_data_t *lp_rcd; /* router checker state */ } lnet_peer_t; @@ -688,9 +690,9 @@ typedef struct int ln_nportals; /* the vector of portals */ lnet_portal_t **ln_portals; - /* ME container */ + /* percpt ME containers */ struct lnet_res_container **ln_me_containers; - /* MD container */ + /* percpt MD container */ struct lnet_res_container **ln_md_containers; /* Event Queue container */ @@ -708,7 +710,7 @@ typedef struct #endif /* protect NI, peer table, credits, routers, rtrbuf... */ struct cfs_percpt_lock *ln_net_lock; - /* message container for active/finalizing/freed message */ + /* percpt message containers for active/finalizing/freed message */ struct lnet_msg_container **ln_msg_containers; lnet_counters_t **ln_counters; struct lnet_peer_table **ln_peer_tables; @@ -732,7 +734,7 @@ typedef struct cfs_list_t ln_routers; /* validity stamp */ __u64 ln_routers_version; - /* router buffer pools */ + /* percpt router buffer pools */ lnet_rtrbufpool_t **ln_rtrpools; lnet_handle_md_t ln_ping_target_md; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index fe21414..bdff15c 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -519,7 +519,7 @@ lnet_res_container_cleanup(struct lnet_res_container *rec) { int count = 0; - if (rec->rec_type == 0) /* not set yet, it's a uninitialized */ + if (rec->rec_type == 0) /* not set yet, it's uninitialized */ return; while (!cfs_list_empty(&rec->rec_active)) { @@ -644,7 +644,7 @@ lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie) lnet_libhandle_t *lh; unsigned int hash; - if ((cookie & (LNET_COOKIE_TYPES - 1)) != rec->rec_type) + if ((cookie & LNET_COOKIE_MASK) != rec->rec_type) return NULL; hash = cookie >> (LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS); @@ -691,7 +691,7 @@ int lnet_unprepare(void); int lnet_prepare(lnet_pid_t requested_pid) { - /* Prepare to bring up the network */ + /* Prepare to bring up the network */ struct lnet_res_container **recs; int rc = 0; @@ -738,7 +738,6 @@ lnet_prepare(lnet_pid_t requested_pid) if (rc != 0) goto failed; - /* NB: we will have instance of message container per CPT soon */ rc = lnet_msg_containers_create(); if (rc != 0) goto failed; @@ -756,7 +755,6 @@ lnet_prepare(lnet_pid_t requested_pid) the_lnet.ln_me_containers = recs; - /* NB: we will have instance of MD container per CPT soon */ recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS, sizeof(lnet_libmd_t)); if (recs == NULL) @@ -855,7 +853,7 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number) if (val < number) return val; - return (unsigned int)((key + val + (val >> 1)) % number); + return (unsigned int)(key + val + (val >> 1)) % number; } int @@ -1299,10 +1297,10 @@ LNetInit(void) { int rc; - lnet_assert_wire_constants (); - LASSERT (!the_lnet.ln_init); + lnet_assert_wire_constants(); + LASSERT(!the_lnet.ln_init); - memset(&the_lnet, 0, sizeof(the_lnet)); + memset(&the_lnet, 0, sizeof(the_lnet)); /* refer to global cfs_cpt_table for now */ the_lnet.ln_cpt_table = cfs_cpt_table; @@ -1326,10 +1324,10 @@ LNetInit(void) return -1; } - the_lnet.ln_refcount = 0; - the_lnet.ln_init = 1; - LNetInvalidateHandle(&the_lnet.ln_rc_eqh); - CFS_INIT_LIST_HEAD(&the_lnet.ln_lnds); + the_lnet.ln_refcount = 0; + the_lnet.ln_init = 1; + LNetInvalidateHandle(&the_lnet.ln_rc_eqh); + CFS_INIT_LIST_HEAD(&the_lnet.ln_lnds); CFS_INIT_LIST_HEAD(&the_lnet.ln_rcd_zombie); CFS_INIT_LIST_HEAD(&the_lnet.ln_rcd_deathrow); @@ -1708,7 +1706,7 @@ lnet_create_ping_info(void) pinfo->pi_nnis = n; pinfo->pi_pid = the_lnet.ln_pid; pinfo->pi_magic = LNET_PROTO_PING_MAGIC; - pinfo->pi_version = LNET_PROTO_PING_VERSION; + pinfo->pi_features = LNET_PING_FEAT_NI_STATUS; for (i = 0; i < n; i++) { lnet_ni_status_t *ns = &pinfo->pi_ni[i]; @@ -1731,10 +1729,10 @@ lnet_create_ping_info(void) lnet_ni_decref_locked(ni, 0); lnet_net_unlock(0); - } + } - the_lnet.ln_ping_info = pinfo; - return 0; + the_lnet.ln_ping_info = pinfo; + return 0; } static void @@ -2004,11 +2002,11 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i goto out_1; } - if (info->pi_version != LNET_PROTO_PING_VERSION) { - CERROR("%s: Unexpected version 0x%x\n", - libcfs_id2str(id), info->pi_version); - goto out_1; - } + if ((info->pi_features & LNET_PING_FEAT_NI_STATUS) == 0) { + CERROR("%s: ping w/o NI status: 0x%x\n", + libcfs_id2str(id), info->pi_features); + goto out_1; + } if (nob < offsetof(lnet_ping_info_t, pi_ni[0])) { CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id), diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index 99c9ff3..0c9eb64 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -114,7 +114,7 @@ lnet_ni_free(struct lnet_ni *ni) } lnet_ni_t * -lnet_ni_alloc(__u32 net, struct cfs_expr_list **el, cfs_list_t *nilist) +lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, cfs_list_t *nilist) { struct lnet_tx_queue *tq; struct lnet_ni *ni; @@ -155,11 +155,11 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list **el, cfs_list_t *nilist) cfs_percpt_for_each(tq, i, ni->ni_tx_queues) CFS_INIT_LIST_HEAD(&tq->tq_delayed); - if (el == NULL || *el == NULL) { + if (el == NULL) { ni->ni_cpts = NULL; ni->ni_ncpts = LNET_CPT_NUMBER; } else { - rc = cfs_expr_list_values(*el, LNET_CPT_NUMBER, &ni->ni_cpts); + rc = cfs_expr_list_values(el, LNET_CPT_NUMBER, &ni->ni_cpts); if (rc <= 0) { CERROR("Failed to set CPTs for NI %s: %d\n", libcfs_net2str(net), rc); @@ -173,8 +173,6 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list **el, cfs_list_t *nilist) } ni->ni_ncpts = rc; - cfs_expr_list_free(*el); /* consume it */ - *el = NULL; } /* LND will fill in the address part of the NID */ @@ -275,8 +273,13 @@ lnet_parse_networks(cfs_list_t *nilist, char *networks) } if (LNET_NETTYP(net) != LOLND && /* LO is implicit */ - lnet_ni_alloc(net, &el, nilist) == NULL) - goto failed; + lnet_ni_alloc(net, el, nilist) == NULL) + goto failed; + + if (el != NULL) { + cfs_expr_list_free(el); + el = NULL; + } str = comma; continue; @@ -290,11 +293,16 @@ lnet_parse_networks(cfs_list_t *nilist, char *networks) } nnets++; - ni = lnet_ni_alloc(net, &el, nilist); - if (ni == NULL) - goto failed; + ni = lnet_ni_alloc(net, el, nilist); + if (ni == NULL) + goto failed; + + if (el != NULL) { + cfs_expr_list_free(el); + el = NULL; + } - niface = 0; + niface = 0; iface = bracket + 1; bracket = strchr(iface, ')'); diff --git a/lnet/lnet/lib-eq.c b/lnet/lnet/lib-eq.c index 2fcc98a..1e5011c 100644 --- a/lnet/lnet/lib-eq.c +++ b/lnet/lnet/lib-eq.c @@ -255,8 +255,8 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence)) RETURN(0); - /* We've got a new event... */ - *ev = *new_event; + /* We've got a new event... */ + *ev = *new_event; CDEBUG(D_INFO, "event: %p, sequence: %lu, eq->size: %u\n", new_event, eq->eq_deq_seq, eq->eq_size); @@ -331,10 +331,10 @@ LNetEQWait (lnet_handle_eq_t eventq, lnet_event_t *event) static int lnet_eq_wait_locked(int *timeout_ms) { - int tms = *timeout_ms; - int wait; - cfs_waitlink_t wl; - cfs_time_t now; + int tms = *timeout_ms; + int wait; + cfs_waitlink_t wl; + cfs_time_t now; if (tms == 0) return -1; /* don't want to wait and no new event */ @@ -388,11 +388,11 @@ lnet_eq_cond_wait(struct timespec *ts) static int lnet_eq_wait_locked(int *timeout_ms) { - lnet_ni_t *eq_waitni = NULL; - int tms = *timeout_ms; - int wait; - struct timeval then; - struct timeval now; + lnet_ni_t *eq_waitni = NULL; + int tms = *timeout_ms; + int wait; + struct timeval then; + struct timeval now; if (the_lnet.ln_eq_waitni != NULL) { /* I have a single NI that I have to call into, to get @@ -501,8 +501,8 @@ lnet_eq_wait_locked(int *timeout_ms) * \retval -ENOENT If there's an invalid handle in \a eventqs. */ int -LNetEQPoll (lnet_handle_eq_t *eventqs, int neq, int timeout_ms, - lnet_event_t *event, int *which) +LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, + lnet_event_t *event, int *which) { int wait = 1; int rc; @@ -517,7 +517,7 @@ LNetEQPoll (lnet_handle_eq_t *eventqs, int neq, int timeout_ms, lnet_eq_wait_lock(); - for (;;) { + for (;;) { #ifndef __KERNEL__ lnet_eq_wait_unlock(); diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c index 96b4660..5970963 100644 --- a/lnet/lnet/lib-md.c +++ b/lnet/lnet/lib-md.c @@ -263,7 +263,7 @@ lnet_md_validate(lnet_md_t *umd) */ int LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, - lnet_unlink_t unlink, lnet_handle_md_t *handle) + lnet_unlink_t unlink, lnet_handle_md_t *handle) { CFS_LIST_HEAD (matches); CFS_LIST_HEAD (drops); @@ -294,11 +294,11 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, if (rc != 0) goto failed; - me = lnet_handle2me(&meh); + me = lnet_handle2me(&meh); if (me == NULL) rc = -ENOENT; else if (me->me_md != NULL) - rc = -EBUSY; + rc = -EBUSY; else rc = lnet_md_link(md, umd.eq_handle, cpt); diff --git a/lnet/lnet/lib-me.c b/lnet/lnet/lib-me.c index 4324961..df33c83 100644 --- a/lnet/lnet/lib-me.c +++ b/lnet/lnet/lib-me.c @@ -92,9 +92,9 @@ LNetMEAttach(unsigned int portal, if (mtable == NULL) /* can't match portal type */ return -EPERM; - me = lnet_me_alloc(); - if (me == NULL) - return -ENOMEM; + me = lnet_me_alloc(); + if (me == NULL) + return -ENOMEM; lnet_res_lock(mtable->mt_cpt); @@ -155,9 +155,9 @@ LNetMEInsert(lnet_handle_me_t current_meh, if (pos == LNET_INS_LOCAL) return -EPERM; - new_me = lnet_me_alloc(); - if (new_me == NULL) - return -ENOMEM; + new_me = lnet_me_alloc(); + if (new_me == NULL) + return -ENOMEM; cpt = lnet_cpt_of_cookie(current_meh.cookie); @@ -175,7 +175,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, ptl = the_lnet.ln_portals[current_me->me_portal]; if (lnet_ptl_is_unique(ptl)) { - /* nosense to insertion on unique portal */ + /* nosense to insertion on unique portal */ lnet_me_free_locked(new_me); lnet_res_unlock(cpt); return -EPERM; diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index f556eb2..a37c7bb 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -692,6 +692,7 @@ lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) LASSERT(!msg->msg_sending); LASSERT(msg->msg_receiving); + LASSERT(!msg->msg_rx_ready_delay); LASSERT(ni->ni_lnd->lnd_eager_recv != NULL); msg->msg_rx_ready_delay = 1; @@ -1165,7 +1166,7 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) lp = rtr->lr_gateway; if (!lp->lp_alive || /* gateway is down */ - (lp->lp_ping_version == LNET_PROTO_PING_VERSION && + ((lp->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) != 0 && rtr->lr_downis != 0)) /* NI to target is down */ continue; @@ -1588,15 +1589,15 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) lnet_msg_attach_md(msg, md, 0, mlength); - if (mlength != 0) - lnet_setpayloadbuffer(msg); + if (mlength != 0) + lnet_setpayloadbuffer(msg); lnet_res_unlock(cpt); lnet_build_msg_event(msg, LNET_EVENT_REPLY); - lnet_ni_recv(ni, private, msg, 0, 0, mlength, rlength); - return 0; + lnet_ni_recv(ni, private, msg, 0, 0, mlength, rlength); + return 0; } static int @@ -2139,10 +2140,10 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack, lnet_res_unlock(cpt); lnet_msg_free(msg); - return -ENOENT; - } + return -ENOENT; + } - CDEBUG(D_NET, "LNetPut -> %s\n", libcfs_id2str(target)); + CDEBUG(D_NET, "LNetPut -> %s\n", libcfs_id2str(target)); lnet_msg_attach_md(msg, md, 0, 0); @@ -2216,16 +2217,16 @@ lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *getmsg) getmd); lnet_res_unlock(cpt); goto drop; - } + } - LASSERT (getmd->md_offset == 0); + LASSERT(getmd->md_offset == 0); CDEBUG(D_NET, "%s: Reply from %s md %p\n", libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id), getmd); /* setup information for lnet_build_msg_event */ msg->msg_from = peer_id.nid; - msg->msg_type = LNET_MSG_GET; /* flag this msg as an "optimized" GET */ + msg->msg_type = LNET_MSG_GET; /* flag this msg as an "optimized" GET */ msg->msg_hdr.src_nid = peer_id.nid; msg->msg_hdr.payload_length = getmd->md_length; msg->msg_receiving = 1; /* required by lnet_msg_attach_md */ diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c index 6c705f0..3af278d 100644 --- a/lnet/lnet/lib-msg.c +++ b/lnet/lnet/lib-msg.c @@ -74,7 +74,7 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) ev->target.pid = le32_to_cpu(hdr->dest_pid); ev->initiator.nid = LNET_NID_ANY; ev->initiator.pid = the_lnet.ln_pid; - ev->sender = LNET_NID_ANY; + ev->sender = LNET_NID_ANY; } else { /* event for passive message */ @@ -83,7 +83,7 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) ev->initiator.pid = hdr->src_pid; ev->initiator.nid = hdr->src_nid; ev->rlength = hdr->payload_length; - ev->sender = msg->msg_from; + ev->sender = msg->msg_from; ev->mlength = msg->msg_wanted; ev->offset = msg->msg_offset; } diff --git a/lnet/lnet/lib-ptl.c b/lnet/lnet/lib-ptl.c index 2ccb0cf..1cfc87c 100644 --- a/lnet/lnet/lib-ptl.c +++ b/lnet/lnet/lib-ptl.c @@ -180,7 +180,7 @@ lnet_try_match_md(lnet_libmd_t *md, mlength = md->md_length - offset; } - if (info->mi_rlength <= mlength) { /* fits in allowed space */ + if (info->mi_rlength <= mlength) { /* fits in allowed space */ mlength = info->mi_rlength; } else if ((md->md_options & LNET_MD_TRUNCATE) == 0) { /* this packet _really_ is too big */ diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index e9e3147..bca85f2 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -229,7 +229,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) if (lp != NULL) memset(lp, 0, sizeof(*lp)); else - LIBCFS_ALLOC(lp, sizeof(*lp)); + LIBCFS_CPT_ALLOC(lp, lnet_cpt_table(), cpt2, sizeof(*lp)); if (lp == NULL) { *lpp = NULL; @@ -238,7 +238,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) } CFS_INIT_LIST_HEAD(&lp->lp_txq); - CFS_INIT_LIST_HEAD(&lp->lp_rtrq); + CFS_INIT_LIST_HEAD(&lp->lp_rtrq); CFS_INIT_LIST_HEAD(&lp->lp_routes); lp->lp_notify = 0; @@ -250,7 +250,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) lp->lp_last_alive = cfs_time_current(); /* assumes alive */ lp->lp_last_query = 0; /* haven't asked NI yet */ lp->lp_ping_timestamp = 0; - lp->lp_ping_version = LNET_PROTO_PING_UNKNOWN; + lp->lp_ping_feats = LNET_PING_FEAT_INVAL; lp->lp_nid = nid; lp->lp_cpt = cpt2; lp->lp_refcount = 2; /* 1 for caller; 1 for hash */ diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 49fa60f..81cc9d8 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -130,9 +130,9 @@ lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when) lp->lp_notify = 1; lp->lp_notifylnd |= notifylnd; if (lp->lp_alive) - lp->lp_ping_version = LNET_PROTO_PING_UNKNOWN; /* reset */ + lp->lp_ping_feats = LNET_PING_FEAT_INVAL; /* reset */ - CDEBUG(D_NET, "set %s %d\n", libcfs_nid2str(lp->lp_nid), alive); + CDEBUG(D_NET, "set %s %d\n", libcfs_nid2str(lp->lp_nid), alive); } void @@ -294,8 +294,8 @@ lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route) cfs_list_add(&route->lr_list, e); cfs_list_add(&route->lr_gwlist, &route->lr_gateway->lp_routes); - the_lnet.ln_remote_nets_version++; - lnet_rtr_addref_locked(route->lr_gateway); + the_lnet.ln_remote_nets_version++; + lnet_rtr_addref_locked(route->lr_gateway); } int @@ -351,7 +351,7 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) LIBCFS_FREE(rnet, sizeof(*rnet)); if (rc == -EHOSTUNREACH) { /* gateway is not on a local net */ - return 0; /* ignore the route entry */ + return 0; /* ignore the route entry */ } else { CERROR("Error %d creating route %s %d %s\n", rc, libcfs_net2str(net), hops, @@ -404,10 +404,10 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) if (!add_route) LIBCFS_FREE(route, sizeof(*route)); - if (rnet != rnet2) - LIBCFS_FREE(rnet, sizeof(*rnet)); + if (rnet != rnet2) + LIBCFS_FREE(rnet, sizeof(*rnet)); - return 0; + return 0; } int @@ -460,7 +460,7 @@ lnet_check_routes(void) } int -lnet_del_route (__u32 net, lnet_nid_t gw_nid) +lnet_del_route(__u32 net, lnet_nid_t gw_nid) { struct lnet_peer *gateway; lnet_remotenet_t *rnet; @@ -563,11 +563,11 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, void lnet_swap_pinginfo(lnet_ping_info_t *info) { - int i; - lnet_ni_status_t *stat; + int i; + lnet_ni_status_t *stat; __swab32s(&info->pi_magic); - __swab32s(&info->pi_version); + __swab32s(&info->pi_features); __swab32s(&info->pi_pid); __swab32s(&info->pi_nnis); for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) { @@ -599,21 +599,20 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) if (info->pi_magic != LNET_PROTO_PING_MAGIC) { CDEBUG(D_NET, "%s: Unexpected magic %08x\n", libcfs_nid2str(gw->lp_nid), info->pi_magic); - gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN; + gw->lp_ping_feats = LNET_PING_FEAT_INVAL; return; } - gw->lp_ping_version = info->pi_version; - if (gw->lp_ping_version == LNET_PROTO_PING_VERSION_1) - return; /* v1 doesn't carry NI status info */ - - if (gw->lp_ping_version != LNET_PROTO_PING_VERSION) { - CDEBUG(D_NET, "%s: Unexpected version 0x%x\n", - libcfs_nid2str(gw->lp_nid), gw->lp_ping_version); - gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN; - return; + gw->lp_ping_feats = info->pi_features; + if ((gw->lp_ping_feats & LNET_PING_FEAT_MASK) == 0) { + CDEBUG(D_NET, "%s: Unexpected features 0x%x\n", + libcfs_nid2str(gw->lp_nid), gw->lp_ping_feats); + return; /* nothing I can understand */ } + if ((gw->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) == 0) + return; /* can't carry NI status info */ + cfs_list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) { int ptl_status = LNET_NI_STATUS_INVALID; int down = 0; @@ -627,7 +626,7 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) if (nid == LNET_NID_ANY) { CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n", libcfs_nid2str(gw->lp_nid)); - gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN; + gw->lp_ping_feats = LNET_PING_FEAT_INVAL; return; } @@ -656,7 +655,7 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) CDEBUG(D_NET, "%s: Unexpected status 0x%x\n", libcfs_nid2str(gw->lp_nid), stat->ns_status); - gw->lp_ping_version = LNET_PROTO_PING_UNKNOWN; + gw->lp_ping_feats = LNET_PING_FEAT_INVAL; return; } @@ -679,7 +678,7 @@ lnet_router_checker_event(lnet_event_t *event) if (event->unlinked) { LNetInvalidateHandle(&rcd->rcd_mdh); return; - } + } LASSERT(event->type == LNET_EVENT_SEND || event->type == LNET_EVENT_REPLY); @@ -954,7 +953,7 @@ lnet_ping_router_locked (lnet_peer_t *rtr) mdh = rcd->rcd_mdh; if (rtr->lp_ping_deadline == 0) { - rtr->lp_ping_deadline = \ + rtr->lp_ping_deadline = cfs_time_shift(router_ping_timeout); } @@ -1155,7 +1154,7 @@ lnet_prune_rc_data(int wait_unlink) LNetMDUnlink(rcd->rcd_mdh); lnet_net_lock(LNET_LOCK_EX); - } + } cfs_list_splice_init(&head, &the_lnet.ln_rcd_zombie); @@ -1165,7 +1164,7 @@ lnet_prune_rc_data(int wait_unlink) rcd_list) { if (!LNetHandleIsInvalid(rcd->rcd_mdh)) cfs_list_move(&rcd->rcd_list, &head); - } + } wait_unlink = wait_unlink && !cfs_list_empty(&the_lnet.ln_rcd_zombie); @@ -1256,8 +1255,8 @@ rescan: the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN; cfs_up(&the_lnet.ln_rc_signal); - /* The unlink event callback will signal final completion */ - return 0; + /* The unlink event callback will signal final completion */ + return 0; } void @@ -1383,7 +1382,7 @@ void lnet_rtrpools_free(void) { lnet_rtrbufpool_t *rtrp; - int i; + int i; if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */ return; diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index a91d82b..97585ce 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -348,7 +348,8 @@ int LL_PROC_PROTO(proc_lnet_routers) int down_ni = 0; lnet_route_t *rtr; - if (peer->lp_ping_version == LNET_PROTO_PING_VERSION) { + if ((peer->lp_ping_feats & + LNET_PING_FEAT_NI_STATUS) != 0) { cfs_list_for_each_entry(rtr, &peer->lp_routes, lr_gwlist) { /* downis on any route should be the -- 1.8.3.1