summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
307d877)
To make the code more readable we make the ni_state an
enumerated type, and create a separate bit filed to track
the recovery state. Both of these are protected by the
lnet_ni_lock()
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: I5acfccecffd5dbb07c9ad3b1c7651cf291b85cb8
Reviewed-on: https://review.whamcloud.com/33361
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Sonia Sharma <sharmaso@whamcloud.com>
Reviewed-by: Doug Oucharek <dougso@me.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
LNET_NET_STATE_DELETING
};
LNET_NET_STATE_DELETING
};
-#define LNET_NI_STATE_INIT (1 << 0)
-#define LNET_NI_STATE_ACTIVE (1 << 1)
-#define LNET_NI_STATE_FAILED (1 << 2)
-#define LNET_NI_STATE_RECOVERY_PENDING (1 << 3)
-#define LNET_NI_STATE_RECOVERY_FAILED (1 << 4)
-#define LNET_NI_STATE_DELETING (1 << 5)
+enum lnet_ni_state {
+ /* initial state when NI is created */
+ LNET_NI_STATE_INIT = 0,
+ /* set when NI is brought up */
+ LNET_NI_STATE_ACTIVE,
+ /* set when NI is being shutdown */
+ LNET_NI_STATE_DELETING,
+};
+
+#define LNET_NI_RECOVERY_PENDING BIT(0)
+#define LNET_NI_RECOVERY_FAILED BIT(1)
enum lnet_stats_type {
LNET_STATS_TYPE_SEND = 0,
enum lnet_stats_type {
LNET_STATS_TYPE_SEND = 0,
/* my health status */
struct lnet_ni_status *ni_status;
/* my health status */
struct lnet_ni_status *ni_status;
- /* NI FSM */
- __u32 ni_state;
+ /* NI FSM. Protected by lnet_ni_lock() */
+ enum lnet_ni_state ni_state;
+
+ /* Recovery state. Protected by lnet_ni_lock() */
+ __u32 ni_recovery_state;
/* per NI LND tunables */
struct lnet_lnd_tunables ni_lnd_tunables;
/* per NI LND tunables */
struct lnet_lnd_tunables ni_lnd_tunables;
list_del_init(&ni->ni_netlist);
/* the ni should be in deleting state. If it's not it's
* a bug */
list_del_init(&ni->ni_netlist);
/* the ni should be in deleting state. If it's not it's
* a bug */
- LASSERT(ni->ni_state & LNET_NI_STATE_DELETING);
+ LASSERT(ni->ni_state == LNET_NI_STATE_DELETING);
cfs_percpt_for_each(ref, j, ni->ni_refs) {
if (*ref == 0)
continue;
cfs_percpt_for_each(ref, j, ni->ni_refs) {
if (*ref == 0)
continue;
lnet_net_lock(LNET_LOCK_EX);
lnet_ni_lock(ni);
lnet_net_lock(LNET_LOCK_EX);
lnet_ni_lock(ni);
- ni->ni_state |= LNET_NI_STATE_DELETING;
- ni->ni_state &= ~LNET_NI_STATE_ACTIVE;
+ ni->ni_state = LNET_NI_STATE_DELETING;
lnet_ni_unlock(ni);
lnet_ni_unlink_locked(ni);
lnet_incr_dlc_seq();
lnet_ni_unlock(ni);
lnet_ni_unlink_locked(ni);
lnet_incr_dlc_seq();
- ni->ni_state |= LNET_NI_STATE_ACTIVE;
- ni->ni_state &= ~LNET_NI_STATE_INIT;
+ ni->ni_state = LNET_NI_STATE_ACTIVE;
lnet_ni_unlock(ni);
/* We keep a reference on the loopback net through the loopback NI */
lnet_ni_unlock(ni);
/* We keep a reference on the loopback net through the loopback NI */
ni->ni_net_ns = NULL;
ni->ni_last_alive = ktime_get_real_seconds();
ni->ni_net_ns = NULL;
ni->ni_last_alive = ktime_get_real_seconds();
- ni->ni_state |= LNET_NI_STATE_INIT;
+ ni->ni_state = LNET_NI_STATE_INIT;
list_add_tail(&ni->ni_netlist, &net->net_ni_added);
/*
list_add_tail(&ni->ni_netlist, &net->net_ni_added);
/*
LNetInvalidateMDHandle(&recovery_mdh);
LNetInvalidateMDHandle(&recovery_mdh);
- if (ni->ni_state & LNET_NI_STATE_RECOVERY_PENDING || force) {
+ if (ni->ni_recovery_state & LNET_NI_RECOVERY_PENDING ||
+ force) {
recovery_mdh = ni->ni_ping_mdh;
LNetInvalidateMDHandle(&ni->ni_ping_mdh);
}
recovery_mdh = ni->ni_ping_mdh;
LNetInvalidateMDHandle(&ni->ni_ping_mdh);
}
lnet_net_lock(0);
lnet_ni_lock(ni);
lnet_net_lock(0);
lnet_ni_lock(ni);
- if (!(ni->ni_state & LNET_NI_STATE_ACTIVE) ||
+ if (ni->ni_state != LNET_NI_STATE_ACTIVE ||
healthv == LNET_MAX_HEALTH_VALUE) {
list_del_init(&ni->ni_recovery);
lnet_unlink_ni_recovery_mdh_locked(ni, 0, false);
healthv == LNET_MAX_HEALTH_VALUE) {
list_del_init(&ni->ni_recovery);
lnet_unlink_ni_recovery_mdh_locked(ni, 0, false);
* But we want to keep the local_ni on the recovery queue
* so we can continue the attempts to recover it.
*/
* But we want to keep the local_ni on the recovery queue
* so we can continue the attempts to recover it.
*/
- if (ni->ni_state & LNET_NI_STATE_RECOVERY_FAILED) {
+ if (ni->ni_recovery_state & LNET_NI_RECOVERY_FAILED) {
lnet_unlink_ni_recovery_mdh_locked(ni, 0, true);
lnet_unlink_ni_recovery_mdh_locked(ni, 0, true);
- ni->ni_state &= ~LNET_NI_STATE_RECOVERY_FAILED;
+ ni->ni_recovery_state &= ~LNET_NI_RECOVERY_FAILED;
libcfs_nid2str(ni->ni_nid));
lnet_ni_lock(ni);
libcfs_nid2str(ni->ni_nid));
lnet_ni_lock(ni);
- if (!(ni->ni_state & LNET_NI_STATE_RECOVERY_PENDING)) {
- ni->ni_state |= LNET_NI_STATE_RECOVERY_PENDING;
+ if (!(ni->ni_recovery_state & LNET_NI_RECOVERY_PENDING)) {
+ ni->ni_recovery_state |= LNET_NI_RECOVERY_PENDING;
lnet_ni_unlock(ni);
LIBCFS_ALLOC(ev_info, sizeof(*ev_info));
lnet_ni_unlock(ni);
LIBCFS_ALLOC(ev_info, sizeof(*ev_info));
CERROR("out of memory. Can't recover %s\n",
libcfs_nid2str(ni->ni_nid));
lnet_ni_lock(ni);
CERROR("out of memory. Can't recover %s\n",
libcfs_nid2str(ni->ni_nid));
lnet_ni_lock(ni);
- ni->ni_state &= ~LNET_NI_STATE_RECOVERY_PENDING;
+ ni->ni_recovery_state &=
+ ~LNET_NI_RECOVERY_PENDING;
lnet_ni_unlock(ni);
continue;
}
lnet_ni_unlock(ni);
continue;
}
lnet_ni_lock(ni);
if (rc)
lnet_ni_lock(ni);
if (rc)
- ni->ni_state &= ~LNET_NI_STATE_RECOVERY_PENDING;
+ ni->ni_recovery_state &= ~LNET_NI_RECOVERY_PENDING;
return;
}
lnet_ni_lock(ni);
return;
}
lnet_ni_lock(ni);
- ni->ni_state &= ~LNET_NI_STATE_RECOVERY_PENDING;
+ ni->ni_recovery_state &= ~LNET_NI_RECOVERY_PENDING;
- ni->ni_state |= LNET_NI_STATE_RECOVERY_FAILED;
+ ni->ni_recovery_state |= LNET_NI_RECOVERY_FAILED;
lnet_ni_unlock(ni);
lnet_net_unlock(0);
lnet_ni_unlock(ni);
lnet_net_unlock(0);