@@ -116,6 +116,20 @@
return update;
}
+static inline unsigned int
+lnet_ni_get_status_locked(struct lnet_ni *ni)
+__must_hold(&ni->ni_lock)
+{
+ if (ni->ni_nid == LNET_NID_LO_0)
+ return LNET_NI_STATUS_UP;
+ else if (atomic_read(&ni->ni_fatal_error_on))
+ return LNET_NI_STATUS_DOWN;
+ else if (ni->ni_status)
+ return ni->ni_status->ns_status;
+ else
+ return LNET_NI_STATUS_UP;
+}
+
static inline bool
lnet_ni_set_status(struct lnet_ni *ni, u32 status)
{
@@ -1829,9 +1829,7 @@ struct lnet_ping_buffer *
ns->ns_nid = ni->ni_nid;
lnet_ni_lock(ni);
- ns->ns_status = ni->ni_status ?
- ni->ni_status->ns_status :
- LNET_NI_STATUS_UP;
+ ns->ns_status = lnet_ni_get_status_locked(ni);
ni->ni_status = ns;
lnet_ni_unlock(ni);
@@ -2936,10 +2934,7 @@ void lnet_lib_exit(void)
}
cfg_ni->lic_nid = ni->ni_nid;
- if (ni->ni_nid == LNET_NID_LO_0)
- cfg_ni->lic_status = LNET_NI_STATUS_UP;
- else
- cfg_ni->lic_status = ni->ni_status->ns_status;
+ cfg_ni->lic_status = lnet_ni_get_status_locked(ni);
cfg_ni->lic_dev_cpt = ni->ni_dev_cpt;
memcpy(&tun->lt_cmn, &ni->ni_net->net_tunables, sizeof(tun->lt_cmn));
@@ -3022,10 +3017,7 @@ void lnet_lib_exit(void)
config->cfg_config_u.cfg_net.net_peer_rtr_credits =
ni->ni_net->net_tunables.lct_peer_rtr_credits;
- if (ni->ni_nid == LNET_NID_LO_0)
- net_config->ni_status = LNET_NI_STATUS_UP;
- else
- net_config->ni_status = ni->ni_status->ns_status;
+ net_config->ni_status = lnet_ni_get_status_locked(ni);
if (ni->ni_cpts) {
int num_cpts = min(ni->ni_ncpts, LNET_MAX_SHOW_NUM_CPT);
@@ -673,7 +673,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
lnet_ni_lock(ni);
LASSERT(ni->ni_status);
- stat = (ni->ni_status->ns_status ==
+ stat = (lnet_ni_get_status_locked(ni) ==
LNET_NI_STATUS_UP) ? "up" : "down";
lnet_ni_unlock(ni);