Lines Matching refs:nn
282 static u8 o2net_num_from_nn(struct o2net_node *nn) in o2net_num_from_nn() argument
284 BUG_ON(nn == NULL); in o2net_num_from_nn()
285 return nn - o2net_nodes; in o2net_num_from_nn()
290 static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw) in o2net_prep_nsw() argument
294 spin_lock(&nn->nn_lock); in o2net_prep_nsw()
295 ret = idr_alloc(&nn->nn_status_idr, nsw, 0, 0, GFP_ATOMIC); in o2net_prep_nsw()
298 list_add_tail(&nsw->ns_node_item, &nn->nn_status_list); in o2net_prep_nsw()
300 spin_unlock(&nn->nn_lock); in o2net_prep_nsw()
310 static void o2net_complete_nsw_locked(struct o2net_node *nn, in o2net_complete_nsw_locked() argument
315 assert_spin_locked(&nn->nn_lock); in o2net_complete_nsw_locked()
321 idr_remove(&nn->nn_status_idr, nsw->ns_id); in o2net_complete_nsw_locked()
326 static void o2net_complete_nsw(struct o2net_node *nn, in o2net_complete_nsw() argument
331 spin_lock(&nn->nn_lock); in o2net_complete_nsw()
336 nsw = idr_find(&nn->nn_status_idr, id); in o2net_complete_nsw()
341 o2net_complete_nsw_locked(nn, nsw, sys_status, status); in o2net_complete_nsw()
344 spin_unlock(&nn->nn_lock); in o2net_complete_nsw()
348 static void o2net_complete_nodes_nsw(struct o2net_node *nn) in o2net_complete_nodes_nsw() argument
353 assert_spin_locked(&nn->nn_lock); in o2net_complete_nodes_nsw()
355 list_for_each_entry_safe(nsw, tmp, &nn->nn_status_list, ns_node_item) { in o2net_complete_nodes_nsw()
356 o2net_complete_nsw_locked(nn, nsw, O2NET_ERR_DIED, 0); in o2net_complete_nodes_nsw()
361 o2net_num_from_nn(nn)); in o2net_complete_nodes_nsw()
364 static int o2net_nsw_completed(struct o2net_node *nn, in o2net_nsw_completed() argument
368 spin_lock(&nn->nn_lock); in o2net_nsw_completed()
370 spin_unlock(&nn->nn_lock); in o2net_nsw_completed()
486 static void o2net_set_nn_state(struct o2net_node *nn, in o2net_set_nn_state() argument
490 int was_valid = nn->nn_sc_valid; in o2net_set_nn_state()
491 int was_err = nn->nn_persistent_error; in o2net_set_nn_state()
492 struct o2net_sock_container *old_sc = nn->nn_sc; in o2net_set_nn_state()
494 assert_spin_locked(&nn->nn_lock); in o2net_set_nn_state()
503 BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc); in o2net_set_nn_state()
511 o2net_num_from_nn(nn), nn->nn_sc, sc, nn->nn_sc_valid, valid, in o2net_set_nn_state()
512 nn->nn_persistent_error, err); in o2net_set_nn_state()
514 nn->nn_sc = sc; in o2net_set_nn_state()
515 nn->nn_sc_valid = valid ? 1 : 0; in o2net_set_nn_state()
516 nn->nn_persistent_error = err; in o2net_set_nn_state()
519 if (nn->nn_persistent_error || nn->nn_sc_valid) in o2net_set_nn_state()
520 wake_up(&nn->nn_sc_wq); in o2net_set_nn_state()
522 if (was_valid && !was_err && nn->nn_persistent_error) { in o2net_set_nn_state()
523 o2quo_conn_err(o2net_num_from_nn(nn)); in o2net_set_nn_state()
524 queue_delayed_work(o2net_wq, &nn->nn_still_up, in o2net_set_nn_state()
532 o2net_complete_nodes_nsw(nn); in o2net_set_nn_state()
536 o2quo_conn_up(o2net_num_from_nn(nn)); in o2net_set_nn_state()
537 cancel_delayed_work(&nn->nn_connect_expired); in o2net_set_nn_state()
552 delay = (nn->nn_last_connect_attempt + in o2net_set_nn_state()
558 queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay); in o2net_set_nn_state()
570 queue_delayed_work(o2net_wq, &nn->nn_connect_expired, delay); in o2net_set_nn_state()
693 static void o2net_ensure_shutdown(struct o2net_node *nn, in o2net_ensure_shutdown() argument
697 spin_lock(&nn->nn_lock); in o2net_ensure_shutdown()
698 if (nn->nn_sc == sc) in o2net_ensure_shutdown()
699 o2net_set_nn_state(nn, NULL, 0, err); in o2net_ensure_shutdown()
700 spin_unlock(&nn->nn_lock); in o2net_ensure_shutdown()
716 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_shutdown_sc() local
732 o2net_ensure_shutdown(nn, sc, 0); in o2net_shutdown_sc()
933 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_sendpage() local
953 o2net_ensure_shutdown(nn, sc, 0); in o2net_sendpage()
969 static int o2net_tx_can_proceed(struct o2net_node *nn, in o2net_tx_can_proceed() argument
975 spin_lock(&nn->nn_lock); in o2net_tx_can_proceed()
976 if (nn->nn_persistent_error) { in o2net_tx_can_proceed()
979 *error = nn->nn_persistent_error; in o2net_tx_can_proceed()
980 } else if (nn->nn_sc_valid) { in o2net_tx_can_proceed()
981 kref_get(&nn->nn_sc->sc_kref); in o2net_tx_can_proceed()
984 *sc_ret = nn->nn_sc; in o2net_tx_can_proceed()
987 spin_unlock(&nn->nn_lock); in o2net_tx_can_proceed()
1020 struct o2net_node *nn = o2net_nn_from_num(target_node); in o2net_send_message_vec() local
1056 wait_event(nn->nn_sc_wq, o2net_tx_can_proceed(nn, &sc, &ret)); in o2net_send_message_vec()
1083 ret = o2net_prep_nsw(nn, &nsw); in o2net_send_message_vec()
1106 wait_event(nsw.ns_wq, o2net_nsw_completed(nn, &nsw)); in o2net_send_message_vec()
1125 o2net_complete_nsw(nn, &nsw, 0, 0, 0); in o2net_send_message_vec()
1169 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_process_message() local
1182 o2net_complete_nsw(nn, NULL, in o2net_process_message()
1256 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_check_handshake() local
1266 o2net_ensure_shutdown(nn, sc, -ENOTCONN); in o2net_check_handshake()
1282 o2net_ensure_shutdown(nn, sc, -ENOTCONN); in o2net_check_handshake()
1293 o2net_ensure_shutdown(nn, sc, -ENOTCONN); in o2net_check_handshake()
1304 o2net_ensure_shutdown(nn, sc, -ENOTCONN); in o2net_check_handshake()
1310 spin_lock(&nn->nn_lock); in o2net_check_handshake()
1313 if (nn->nn_sc == sc) { in o2net_check_handshake()
1315 atomic_set(&nn->nn_timeout, 0); in o2net_check_handshake()
1316 o2net_set_nn_state(nn, sc, 1, 0); in o2net_check_handshake()
1318 spin_unlock(&nn->nn_lock); in o2net_check_handshake()
1432 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_rx_until_empty() local
1435 o2net_ensure_shutdown(nn, sc, 0); in o2net_rx_until_empty()
1488 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_idle_timer() local
1504 atomic_set(&nn->nn_timeout, 1); in o2net_idle_timer()
1505 o2quo_conn_err(o2net_num_from_nn(nn)); in o2net_idle_timer()
1506 queue_delayed_work(o2net_wq, &nn->nn_still_up, in o2net_idle_timer()
1525 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); in o2net_sc_postpone_idle() local
1528 if (atomic_read(&nn->nn_timeout)) { in o2net_sc_postpone_idle()
1529 o2quo_conn_up(o2net_num_from_nn(nn)); in o2net_sc_postpone_idle()
1530 cancel_delayed_work(&nn->nn_still_up); in o2net_sc_postpone_idle()
1531 atomic_set(&nn->nn_timeout, 0); in o2net_sc_postpone_idle()
1546 struct o2net_node *nn = in o2net_start_connect() local
1562 if (o2nm_this_node() <= o2net_num_from_nn(nn)) in o2net_start_connect()
1566 node = o2nm_get_node_by_num(o2net_num_from_nn(nn)); in o2net_start_connect()
1574 spin_lock(&nn->nn_lock); in o2net_start_connect()
1582 timeout = atomic_read(&nn->nn_timeout); in o2net_start_connect()
1583 stop = (nn->nn_sc || in o2net_start_connect()
1584 (nn->nn_persistent_error && in o2net_start_connect()
1585 (nn->nn_persistent_error != -ENOTCONN || timeout == 0))); in o2net_start_connect()
1586 spin_unlock(&nn->nn_lock); in o2net_start_connect()
1590 nn->nn_last_connect_attempt = jiffies; in o2net_start_connect()
1625 spin_lock(&nn->nn_lock); in o2net_start_connect()
1627 o2net_set_nn_state(nn, sc, 0, 0); in o2net_start_connect()
1628 spin_unlock(&nn->nn_lock); in o2net_start_connect()
1647 o2net_ensure_shutdown(nn, sc, 0); in o2net_start_connect()
1662 struct o2net_node *nn = in o2net_connect_expired() local
1665 spin_lock(&nn->nn_lock); in o2net_connect_expired()
1666 if (!nn->nn_sc_valid) { in o2net_connect_expired()
1670 o2net_num_from_nn(nn), in o2net_connect_expired()
1674 o2net_set_nn_state(nn, NULL, 0, 0); in o2net_connect_expired()
1676 spin_unlock(&nn->nn_lock); in o2net_connect_expired()
1681 struct o2net_node *nn = in o2net_still_up() local
1684 o2quo_hb_still_up(o2net_num_from_nn(nn)); in o2net_still_up()
1691 struct o2net_node *nn = o2net_nn_from_num(node->nd_num); in o2net_disconnect_node() local
1694 spin_lock(&nn->nn_lock); in o2net_disconnect_node()
1695 atomic_set(&nn->nn_timeout, 0); in o2net_disconnect_node()
1696 o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); in o2net_disconnect_node()
1697 spin_unlock(&nn->nn_lock); in o2net_disconnect_node()
1700 cancel_delayed_work(&nn->nn_connect_expired); in o2net_disconnect_node()
1701 cancel_delayed_work(&nn->nn_connect_work); in o2net_disconnect_node()
1702 cancel_delayed_work(&nn->nn_still_up); in o2net_disconnect_node()
1724 struct o2net_node *nn = o2net_nn_from_num(node_num); in o2net_hb_node_up_cb() local
1731 nn->nn_last_connect_attempt = jiffies - in o2net_hb_node_up_cb()
1739 spin_lock(&nn->nn_lock); in o2net_hb_node_up_cb()
1740 atomic_set(&nn->nn_timeout, 0); in o2net_hb_node_up_cb()
1741 if (nn->nn_persistent_error) in o2net_hb_node_up_cb()
1742 o2net_set_nn_state(nn, NULL, 0, 0); in o2net_hb_node_up_cb()
1743 spin_unlock(&nn->nn_lock); in o2net_hb_node_up_cb()
1782 struct o2net_node *nn; in o2net_accept_one() local
1850 nn = o2net_nn_from_num(node->nd_num); in o2net_accept_one()
1852 spin_lock(&nn->nn_lock); in o2net_accept_one()
1853 if (nn->nn_sc) in o2net_accept_one()
1857 spin_unlock(&nn->nn_lock); in o2net_accept_one()
1875 spin_lock(&nn->nn_lock); in o2net_accept_one()
1876 atomic_set(&nn->nn_timeout, 0); in o2net_accept_one()
1877 o2net_set_nn_state(nn, sc, 0, 0); in o2net_accept_one()
1878 spin_unlock(&nn->nn_lock); in o2net_accept_one()
2105 struct o2net_node *nn = o2net_nn_from_num(i); in o2net_init() local
2107 atomic_set(&nn->nn_timeout, 0); in o2net_init()
2108 spin_lock_init(&nn->nn_lock); in o2net_init()
2109 INIT_DELAYED_WORK(&nn->nn_connect_work, o2net_start_connect); in o2net_init()
2110 INIT_DELAYED_WORK(&nn->nn_connect_expired, in o2net_init()
2112 INIT_DELAYED_WORK(&nn->nn_still_up, o2net_still_up); in o2net_init()
2114 nn->nn_persistent_error = -ENOTCONN; in o2net_init()
2115 init_waitqueue_head(&nn->nn_sc_wq); in o2net_init()
2116 idr_init(&nn->nn_status_idr); in o2net_init()
2117 INIT_LIST_HEAD(&nn->nn_status_list); in o2net_init()