- LASSERT (!the_lnet.ln_shutdown);
- LASSERT (the_lnet.ln_refcount == 0);
- LASSERT (list_empty(&the_lnet.ln_zombie_nis));
- LASSERT (the_lnet.ln_nzombie_nis == 0);
- LASSERT (list_empty(&the_lnet.ln_remote_nets));
-
- LNET_LOCK();
- the_lnet.ln_shutdown = 1; /* flag shutdown */
-
- /* Unlink NIs from the global table */
- while (!list_empty(&the_lnet.ln_nis)) {
- ni = list_entry(the_lnet.ln_nis.next,
- lnet_ni_t, ni_list);
- list_del (&ni->ni_list);
-
- the_lnet.ln_nzombie_nis++;
- lnet_ni_decref_locked(ni); /* drop apini's ref */
- }
-
- /* Drop the cached eqwait NI. */
- if (the_lnet.ln_eqwaitni != NULL) {
- lnet_ni_decref_locked(the_lnet.ln_eqwaitni);
- the_lnet.ln_eqwaitni = NULL;
- }
-
- /* Drop the cached loopback NI. */
- if (the_lnet.ln_loni != NULL) {
- lnet_ni_decref_locked(the_lnet.ln_loni);
- the_lnet.ln_loni = NULL;
- }
-
- LNET_UNLOCK();
+ LASSERT(!the_lnet.ln_shutdown);
+ LASSERT(the_lnet.ln_refcount == 0);
+ LASSERT(cfs_list_empty(&the_lnet.ln_nis_zombie));
+ LASSERT(cfs_list_empty(&the_lnet.ln_remote_nets));
+
+ lnet_net_lock(LNET_LOCK_EX);
+ the_lnet.ln_shutdown = 1; /* flag shutdown */
+
+ /* Unlink NIs from the global table */
+ while (!cfs_list_empty(&the_lnet.ln_nis)) {
+ ni = cfs_list_entry(the_lnet.ln_nis.next,
+ lnet_ni_t, ni_list);
+ /* move it to zombie list and nobody can find it anymore */
+ cfs_list_move(&ni->ni_list, &the_lnet.ln_nis_zombie);
+ lnet_ni_decref_locked(ni, 0); /* drop ln_nis' ref */
+
+ if (!cfs_list_empty(&ni->ni_cptlist)) {
+ cfs_list_del_init(&ni->ni_cptlist);
+ lnet_ni_decref_locked(ni, 0);
+ }
+ }
+
+ /* Drop the cached eqwait NI. */
+ if (the_lnet.ln_eq_waitni != NULL) {
+ lnet_ni_decref_locked(the_lnet.ln_eq_waitni, 0);
+ the_lnet.ln_eq_waitni = NULL;
+ }
+
+ /* Drop the cached loopback NI. */
+ if (the_lnet.ln_loni != NULL) {
+ lnet_ni_decref_locked(the_lnet.ln_loni, 0);
+ the_lnet.ln_loni = NULL;
+ }
+
+ lnet_net_unlock(LNET_LOCK_EX);