Whamcloud - gitweb
LU-946 lprocfs: List open files in filesystem
[fs/lustre-release.git] / lnet / klnds / ptllnd / ptllnd_peer.c
index eacbe19..ae10ef7 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -64,14 +64,14 @@ kptllnd_get_peer_info(int index,
                       int *nsendq, int *nactiveq,
                       int *credits, int *outstanding_credits)
 {
-        cfs_rwlock_t     *g_lock = &kptllnd_data.kptl_peer_rw_lock;
+       rwlock_t     *g_lock = &kptllnd_data.kptl_peer_rw_lock;
         unsigned long     flags;
         cfs_list_t       *ptmp;
         kptl_peer_t      *peer;
         int               i;
         int               rc = -ENOENT;
 
-        cfs_read_lock_irqsave(g_lock, flags);
+       read_lock_irqsave(g_lock, flags);
 
         for (i = 0; i < kptllnd_data.kptl_peer_hash_size; i++) {
                 cfs_list_for_each (ptmp, &kptllnd_data.kptl_peers[i]) {
@@ -86,7 +86,7 @@ kptllnd_get_peer_info(int index,
                         *refcount    = cfs_atomic_read(&peer->peer_refcount);
                         *incarnation = peer->peer_incarnation;
 
-                        cfs_spin_lock(&peer->peer_lock);
+                       spin_lock(&peer->peer_lock);
 
                         *next_matchbits      = peer->peer_next_matchbits;
                         *last_matchbits_seen = peer->peer_last_matchbits_seen;
@@ -96,7 +96,7 @@ kptllnd_get_peer_info(int index,
                         *nsendq   = kptllnd_count_queue(&peer->peer_sendq);
                         *nactiveq = kptllnd_count_queue(&peer->peer_activeq);
 
-                        cfs_spin_unlock(&peer->peer_lock);
+                       spin_unlock(&peer->peer_lock);
 
                         rc = 0;
                         goto out;
@@ -104,7 +104,7 @@ kptllnd_get_peer_info(int index,
         }
 
  out:
-        cfs_read_unlock_irqrestore(g_lock, flags);
+       read_unlock_irqrestore(g_lock, flags);
         return rc;
 }
 
@@ -181,7 +181,7 @@ kptllnd_peer_allocate (kptl_net_t *net, lnet_process_id_t lpid, ptl_process_id_t
         CFS_INIT_LIST_HEAD (&peer->peer_noops);
         CFS_INIT_LIST_HEAD (&peer->peer_sendq);
         CFS_INIT_LIST_HEAD (&peer->peer_activeq);
-        cfs_spin_lock_init (&peer->peer_lock);
+       spin_lock_init(&peer->peer_lock);
 
         peer->peer_state = PEER_STATE_ALLOCATED;
         peer->peer_error = 0;
@@ -196,49 +196,49 @@ kptllnd_peer_allocate (kptl_net_t *net, lnet_process_id_t lpid, ptl_process_id_t
 
         cfs_atomic_set(&peer->peer_refcount, 1);    /* 1 ref for caller */
 
-        cfs_write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         peer->peer_myincarnation = kptllnd_data.kptl_incarnation;
 
         /* Only increase # peers under lock, to guarantee we dont grow it
          * during shutdown */
         if (net->net_shutdown) {
-                cfs_write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock,
+               write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock,
                                             flags);
                 LIBCFS_FREE(peer, sizeof(*peer));
                 return NULL;
         }
 
         kptllnd_data.kptl_npeers++;
-        cfs_write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
         return peer;
 }
 
 void
 kptllnd_peer_destroy (kptl_peer_t *peer)
 {
-        unsigned long flags;
+       unsigned long flags;
 
-        CDEBUG(D_NET, "Peer=%p\n", peer);
+       CDEBUG(D_NET, "Peer=%p\n", peer);
 
-        LASSERT (!cfs_in_interrupt());
-        LASSERT (cfs_atomic_read(&peer->peer_refcount) == 0);
-        LASSERT (peer->peer_state == PEER_STATE_ALLOCATED ||
-                 peer->peer_state == PEER_STATE_ZOMBIE);
-        LASSERT (cfs_list_empty(&peer->peer_noops));
-        LASSERT (cfs_list_empty(&peer->peer_sendq));
-        LASSERT (cfs_list_empty(&peer->peer_activeq));
+       LASSERT (!in_interrupt());
+       LASSERT (cfs_atomic_read(&peer->peer_refcount) == 0);
+       LASSERT (peer->peer_state == PEER_STATE_ALLOCATED ||
+                peer->peer_state == PEER_STATE_ZOMBIE);
+       LASSERT (cfs_list_empty(&peer->peer_noops));
+       LASSERT (cfs_list_empty(&peer->peer_sendq));
+       LASSERT (cfs_list_empty(&peer->peer_activeq));
 
-        cfs_write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
 
-        if (peer->peer_state == PEER_STATE_ZOMBIE)
-                cfs_list_del(&peer->peer_list);
+       if (peer->peer_state == PEER_STATE_ZOMBIE)
+               cfs_list_del(&peer->peer_list);
 
-        kptllnd_data.kptl_npeers--;
+       kptllnd_data.kptl_npeers--;
 
-        cfs_write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
 
-        LIBCFS_FREE (peer, sizeof (*peer));
+       LIBCFS_FREE (peer, sizeof (*peer));
 }
 
 void
@@ -264,21 +264,21 @@ kptllnd_peer_cancel_txs(kptl_peer_t *peer, cfs_list_t *txs)
 {
         unsigned long   flags;
 
-        cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+       spin_lock_irqsave(&peer->peer_lock, flags);
 
         kptllnd_cancel_txlist(&peer->peer_noops, txs);
         kptllnd_cancel_txlist(&peer->peer_sendq, txs);
         kptllnd_cancel_txlist(&peer->peer_activeq, txs);
                 
-        cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+       spin_unlock_irqrestore(&peer->peer_lock, flags);
 }
 
 void
 kptllnd_peer_alive (kptl_peer_t *peer)
 {
-        /* This is racy, but everyone's only writing cfs_time_current() */
-        peer->peer_last_alive = cfs_time_current();
-        cfs_mb();
+       /* This is racy, but everyone's only writing cfs_time_current() */
+       peer->peer_last_alive = cfs_time_current();
+       smp_mb();
 }
 
 void
@@ -292,7 +292,7 @@ kptllnd_peer_notify (kptl_peer_t *peer)
         int           error = 0;
         cfs_time_t    last_alive = 0;
 
-        cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+       spin_lock_irqsave(&peer->peer_lock, flags);
 
         if (peer->peer_error != 0) {
                 error = peer->peer_error;
@@ -300,15 +300,15 @@ kptllnd_peer_notify (kptl_peer_t *peer)
                 last_alive = peer->peer_last_alive;
         }
 
-        cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+       spin_unlock_irqrestore(&peer->peer_lock, flags);
 
         if (error == 0)
                 return;
 
-        cfs_read_lock(&kptllnd_data.kptl_net_rw_lock);
+       read_lock(&kptllnd_data.kptl_net_rw_lock);
         cfs_list_for_each_entry (net, &kptllnd_data.kptl_nets, net_list)
                 nnets++;
-        cfs_read_unlock(&kptllnd_data.kptl_net_rw_lock);
+       read_unlock(&kptllnd_data.kptl_net_rw_lock);
 
         if (nnets == 0) /* shutdown in progress */
                 return;
@@ -320,7 +320,7 @@ kptllnd_peer_notify (kptl_peer_t *peer)
         }
         memset(nets, 0, nnets * sizeof(*nets));
 
-        cfs_read_lock(&kptllnd_data.kptl_net_rw_lock);
+       read_lock(&kptllnd_data.kptl_net_rw_lock);
         i = 0;
         cfs_list_for_each_entry (net, &kptllnd_data.kptl_nets, net_list) {
                 LASSERT (i < nnets);
@@ -328,7 +328,7 @@ kptllnd_peer_notify (kptl_peer_t *peer)
                 kptllnd_net_addref(net);
                 i++;
         }
-        cfs_read_unlock(&kptllnd_data.kptl_net_rw_lock);
+       read_unlock(&kptllnd_data.kptl_net_rw_lock);
 
         for (i = 0; i < nnets; i++) {
                 lnet_nid_t peer_nid;
@@ -362,17 +362,17 @@ kptllnd_handle_closing_peers ()
 
         /* Check with a read lock first to avoid blocking anyone */
 
-        cfs_read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
         idle = cfs_list_empty(&kptllnd_data.kptl_closing_peers) &&
                cfs_list_empty(&kptllnd_data.kptl_zombie_peers);
-        cfs_read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         if (idle)
                 return;
 
         CFS_INIT_LIST_HEAD(&txs);
 
-        cfs_write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         /* Cancel txs on all zombie peers.  NB anyone dropping the last peer
          * ref removes it from this list, so I musn't drop the lock while
@@ -399,17 +399,17 @@ kptllnd_handle_closing_peers ()
                                   &kptllnd_data.kptl_zombie_peers);
                 peer->peer_state = PEER_STATE_ZOMBIE;
 
-                cfs_write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock,
+               write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock,
                                             flags);
 
                 kptllnd_peer_notify(peer);
                 kptllnd_peer_cancel_txs(peer, &txs);
                 kptllnd_peer_decref(peer);
 
-                cfs_write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+               write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
         }
 
-        cfs_write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         /* Drop peer's ref on all cancelled txs.  This will get
          * kptllnd_tx_fini() to abort outstanding comms if necessary. */
@@ -424,37 +424,37 @@ kptllnd_handle_closing_peers ()
 void
 kptllnd_peer_close_locked(kptl_peer_t *peer, int why)
 {
-        switch (peer->peer_state) {
-        default:
-                LBUG();
-
-        case PEER_STATE_WAITING_HELLO:
-        case PEER_STATE_ACTIVE:
-                /* Ensure new peers see a new incarnation of me */
-                LASSERT(peer->peer_myincarnation <= kptllnd_data.kptl_incarnation);
-                if (peer->peer_myincarnation == kptllnd_data.kptl_incarnation)
-                        kptllnd_data.kptl_incarnation++;
-
-                /* Removing from peer table */
-                kptllnd_data.kptl_n_active_peers--;
-                LASSERT (kptllnd_data.kptl_n_active_peers >= 0);
-
-                cfs_list_del(&peer->peer_list);
-                kptllnd_peer_unreserve_buffers();
-
-                peer->peer_error = why; /* stash 'why' only on first close */
-                peer->peer_state = PEER_STATE_CLOSING;
-
-                /* Schedule for immediate attention, taking peer table's ref */
-                cfs_list_add_tail(&peer->peer_list,
-                                 &kptllnd_data.kptl_closing_peers);
-                cfs_waitq_signal(&kptllnd_data.kptl_watchdog_waitq);
-                break;
-
-        case PEER_STATE_ZOMBIE:
-        case PEER_STATE_CLOSING:
-                break;
-        }
+       switch (peer->peer_state) {
+       default:
+               LBUG();
+
+       case PEER_STATE_WAITING_HELLO:
+       case PEER_STATE_ACTIVE:
+               /* Ensure new peers see a new incarnation of me */
+               LASSERT(peer->peer_myincarnation <= kptllnd_data.kptl_incarnation);
+               if (peer->peer_myincarnation == kptllnd_data.kptl_incarnation)
+                       kptllnd_data.kptl_incarnation++;
+
+               /* Removing from peer table */
+               kptllnd_data.kptl_n_active_peers--;
+               LASSERT (kptllnd_data.kptl_n_active_peers >= 0);
+
+               cfs_list_del(&peer->peer_list);
+               kptllnd_peer_unreserve_buffers();
+
+               peer->peer_error = why; /* stash 'why' only on first close */
+               peer->peer_state = PEER_STATE_CLOSING;
+
+               /* Schedule for immediate attention, taking peer table's ref */
+               cfs_list_add_tail(&peer->peer_list,
+                                &kptllnd_data.kptl_closing_peers);
+               wake_up(&kptllnd_data.kptl_watchdog_waitq);
+               break;
+
+       case PEER_STATE_ZOMBIE:
+       case PEER_STATE_CLOSING:
+               break;
+       }
 }
 
 void
@@ -462,9 +462,9 @@ kptllnd_peer_close(kptl_peer_t *peer, int why)
 {
         unsigned long      flags;
 
-        cfs_write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
         kptllnd_peer_close_locked(peer, why);
-        cfs_write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       write_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
 }
 
 int
@@ -496,7 +496,7 @@ kptllnd_peer_del(lnet_process_id_t id)
         }
 
 again:
-        cfs_read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         for (i = lo; i <= hi; i++) {
                 cfs_list_for_each_safe (ptmp, pnxt,
@@ -511,7 +511,7 @@ again:
 
                         kptllnd_peer_addref(peer); /* 1 ref for me... */
 
-                        cfs_read_unlock_irqrestore(&kptllnd_data. \
+                       read_unlock_irqrestore(&kptllnd_data. \
                                                    kptl_peer_rw_lock,
                                                    flags);
 
@@ -525,7 +525,7 @@ again:
                 }
         }
 
-        cfs_read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         return (rc);
 }
@@ -536,7 +536,7 @@ kptllnd_queue_tx(kptl_peer_t *peer, kptl_tx_t *tx)
         /* CAVEAT EMPTOR: I take over caller's ref on 'tx' */
         unsigned long flags;
 
-        cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+       spin_lock_irqsave(&peer->peer_lock, flags);
 
         /* Ensure HELLO is sent first */
         if (tx->tx_msg->ptlm_type == PTLLND_MSG_TYPE_NOOP)
@@ -546,7 +546,7 @@ kptllnd_queue_tx(kptl_peer_t *peer, kptl_tx_t *tx)
         else
                 cfs_list_add_tail(&tx->tx_list, &peer->peer_sendq);
 
-        cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+       spin_unlock_irqrestore(&peer->peer_lock, flags);
 }
 
 
@@ -600,10 +600,10 @@ kptllnd_post_tx(kptl_peer_t *peer, kptl_tx_t *tx, int nfrag)
         }
 
 
-        tx->tx_deadline = jiffies + (*kptllnd_tunables.kptl_timeout * CFS_HZ);
-        tx->tx_active = 1;
-        tx->tx_msg_mdh = msg_mdh;
-        kptllnd_queue_tx(peer, tx);
+       tx->tx_deadline = jiffies + (*kptllnd_tunables.kptl_timeout * HZ);
+       tx->tx_active = 1;
+       tx->tx_msg_mdh = msg_mdh;
+       kptllnd_queue_tx(peer, tx);
 }
 
 /* NB "restarts" comes from peer_sendq of a single peer */
@@ -666,21 +666,21 @@ kptllnd_peer_send_noop (kptl_peer_t *peer)
 void
 kptllnd_peer_check_sends (kptl_peer_t *peer)
 {
-        ptl_handle_me_t  meh;
-        kptl_tx_t       *tx;
-        int              rc;
-        int              msg_type;
-        unsigned long    flags;
+       ptl_handle_me_t  meh;
+       kptl_tx_t       *tx;
+       int              rc;
+       int              msg_type;
+       unsigned long    flags;
 
-        LASSERT(!cfs_in_interrupt());
+       LASSERT(!in_interrupt());
 
-        cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+       spin_lock_irqsave(&peer->peer_lock, flags);
 
-        peer->peer_retry_noop = 0;
+       peer->peer_retry_noop = 0;
 
         if (kptllnd_peer_send_noop(peer)) {
                 /* post a NOOP to return credits */
-                cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+               spin_unlock_irqrestore(&peer->peer_lock, flags);
 
                 tx = kptllnd_get_idle_tx(TX_TYPE_SMALL_MESSAGE);
                 if (tx == NULL) {
@@ -692,7 +692,7 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
                         kptllnd_post_tx(peer, tx, 0);
                 }
 
-                cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+               spin_lock_irqsave(&peer->peer_lock, flags);
                 peer->peer_retry_noop = (tx == NULL);
         }
 
@@ -762,13 +762,13 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
                     !kptllnd_peer_send_noop(peer)) {
                         tx->tx_active = 0;
 
-                        cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+                       spin_unlock_irqrestore(&peer->peer_lock, flags);
 
                         CDEBUG(D_NET, "%s: redundant noop\n", 
                                libcfs_id2str(peer->peer_id));
                         kptllnd_tx_decref(tx);
 
-                        cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+                       spin_lock_irqsave(&peer->peer_lock, flags);
                         continue;
                 }
 
@@ -799,7 +799,7 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
 
                 kptllnd_tx_addref(tx);          /* 1 ref for me... */
 
-                cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+               spin_unlock_irqrestore(&peer->peer_lock, flags);
 
                 if (tx->tx_type == TX_TYPE_PUT_REQUEST ||
                     tx->tx_type == TX_TYPE_GET_REQUEST) {
@@ -855,17 +855,16 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
 
                 kptllnd_tx_decref(tx);          /* drop my ref */
 
-                cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+               spin_lock_irqsave(&peer->peer_lock, flags);
         }
 
-        cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+       spin_unlock_irqrestore(&peer->peer_lock, flags);
         return;
 
  failed:
         /* Nuke everything (including tx we were trying) */
         kptllnd_peer_close(peer, -EIO);
         kptllnd_tx_decref(tx);
-        kptllnd_schedule_ptltrace_dump();
 }
 
 kptl_tx_t *
@@ -907,7 +906,7 @@ kptllnd_peer_check_bucket (int idx, int stamp)
 
  again:
         /* NB. Shared lock while I just look */
-        cfs_read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
+       read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
 
         cfs_list_for_each_entry (peer, peers, peer_list) {
                 kptl_tx_t *tx;
@@ -920,11 +919,11 @@ kptllnd_peer_check_bucket (int idx, int stamp)
                        libcfs_id2str(peer->peer_id), peer->peer_credits, 
                        peer->peer_outstanding_credits, peer->peer_sent_credits);
 
-                cfs_spin_lock(&peer->peer_lock);
+               spin_lock(&peer->peer_lock);
 
                 if (peer->peer_check_stamp == stamp) {
                         /* checked already this pass */
-                        cfs_spin_unlock(&peer->peer_lock);
+                       spin_unlock(&peer->peer_lock);
                         continue;
                 }
 
@@ -942,14 +941,14 @@ kptllnd_peer_check_bucket (int idx, int stamp)
                         nactive = kptllnd_count_queue(&peer->peer_activeq);
                 }
 
-                cfs_spin_unlock(&peer->peer_lock);
+               spin_unlock(&peer->peer_lock);
 
                 if (tx == NULL && !check_sends)
                         continue;
 
                 kptllnd_peer_addref(peer); /* 1 ref for me... */
 
-                cfs_read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock,
+               read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock,
                                            flags);
 
                 if (tx == NULL) { /* nothing timed out */
@@ -1001,11 +1000,6 @@ kptllnd_peer_check_bucket (int idx, int stamp)
                        (tx->tx_tposted == 0) ? 0UL : (jiffies - tx->tx_tposted),
                        *kptllnd_tunables.kptl_timeout);
 
-#ifdef CRAY_XT3
-                if (*kptllnd_tunables.kptl_ptltrace_on_timeout)
-                        kptllnd_dump_ptltrace();
-#endif
-
                 kptllnd_tx_decref(tx);
 
                 kptllnd_peer_close(peer, -ETIMEDOUT);
@@ -1015,7 +1009,7 @@ kptllnd_peer_check_bucket (int idx, int stamp)
                 goto again;
         }
 
-        cfs_read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
+       read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
 }
 
 kptl_peer_t *
@@ -1101,7 +1095,7 @@ kptl_peer_t *
 kptllnd_peer_handle_hello (kptl_net_t *net,
                            ptl_process_id_t initiator, kptl_msg_t *msg)
 {
-        cfs_rwlock_t       *g_lock = &kptllnd_data.kptl_peer_rw_lock;
+       rwlock_t                *g_lock = &kptllnd_data.kptl_peer_rw_lock;
         kptl_peer_t        *peer;
         kptl_peer_t        *new_peer;
         lnet_process_id_t   lpid;
@@ -1152,7 +1146,7 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
                 return NULL;
         }
         
-        cfs_write_lock_irqsave(g_lock, flags);
+       write_lock_irqsave(g_lock, flags);
 
         peer = kptllnd_id2peer_locked(lpid);
         if (peer != NULL) {
@@ -1162,7 +1156,7 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
 
                         if (msg->ptlm_dststamp != 0 &&
                             msg->ptlm_dststamp != peer->peer_myincarnation) {
-                                cfs_write_unlock_irqrestore(g_lock, flags);
+                               write_unlock_irqrestore(g_lock, flags);
 
                                 CERROR("Ignoring HELLO from %s: unexpected "
                                        "dststamp "LPX64" ("LPX64" wanted)\n",
@@ -1180,13 +1174,13 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
                         peer->peer_max_msg_size =
                                 msg->ptlm_u.hello.kptlhm_max_msg_size;
                         
-                        cfs_write_unlock_irqrestore(g_lock, flags);
+                       write_unlock_irqrestore(g_lock, flags);
                         return peer;
                 }
 
                 if (msg->ptlm_dststamp != 0 &&
                     msg->ptlm_dststamp <= peer->peer_myincarnation) {
-                        cfs_write_unlock_irqrestore(g_lock, flags);
+                       write_unlock_irqrestore(g_lock, flags);
 
                         CERROR("Ignoring stale HELLO from %s: "
                                "dststamp "LPX64" (current "LPX64")\n",
@@ -1203,7 +1197,7 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
 
         kptllnd_cull_peertable_locked(lpid);
 
-        cfs_write_unlock_irqrestore(g_lock, flags);
+       write_unlock_irqrestore(g_lock, flags);
 
         if (peer != NULL) {
                 CDEBUG(D_NET, "Peer %s (%s) reconnecting:"
@@ -1241,11 +1235,11 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
                 return NULL;
         }
 
-        cfs_write_lock_irqsave(g_lock, flags);
+       write_lock_irqsave(g_lock, flags);
 
  again:
         if (net->net_shutdown) {
-                cfs_write_unlock_irqrestore(g_lock, flags);
+               write_unlock_irqrestore(g_lock, flags);
 
                 CERROR ("Shutdown started, refusing connection from %s\n",
                         libcfs_id2str(lpid));
@@ -1267,14 +1261,14 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
                         peer->peer_max_msg_size =
                                 msg->ptlm_u.hello.kptlhm_max_msg_size;
 
-                        cfs_write_unlock_irqrestore(g_lock, flags);
+                       write_unlock_irqrestore(g_lock, flags);
 
                         CWARN("Outgoing instantiated peer %s\n",
                               libcfs_id2str(lpid));
                } else {
                        LASSERT (peer->peer_state == PEER_STATE_ACTIVE);
 
-                        cfs_write_unlock_irqrestore(g_lock, flags);
+                       write_unlock_irqrestore(g_lock, flags);
 
                        /* WOW!  Somehow this peer completed the HELLO
                         * handshake while I slept.  I guess I could have slept
@@ -1294,7 +1288,7 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
         if (kptllnd_data.kptl_n_active_peers ==
             kptllnd_data.kptl_expected_peers) {
                 /* peer table full */
-                cfs_write_unlock_irqrestore(g_lock, flags);
+               write_unlock_irqrestore(g_lock, flags);
 
                 kptllnd_peertable_overflow_msg("Connection from ", lpid);
 
@@ -1308,7 +1302,7 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
                         return NULL;
                 }
                 
-                cfs_write_lock_irqsave(g_lock, flags);
+               write_lock_irqsave(g_lock, flags);
                 kptllnd_data.kptl_expected_peers++;
                 goto again;
         }
@@ -1328,7 +1322,7 @@ kptllnd_peer_handle_hello (kptl_net_t *net,
         LASSERT (!net->net_shutdown);
         kptllnd_peer_add_peertable_locked(new_peer);
 
-        cfs_write_unlock_irqrestore(g_lock, flags);
+       write_unlock_irqrestore(g_lock, flags);
 
        /* NB someone else could get in now and post a message before I post
         * the HELLO, but post_tx/check_sends take care of that! */
@@ -1353,7 +1347,7 @@ int
 kptllnd_find_target(kptl_net_t *net, lnet_process_id_t target,
                     kptl_peer_t **peerp)
 {
-        cfs_rwlock_t     *g_lock = &kptllnd_data.kptl_peer_rw_lock;
+       rwlock_t     *g_lock = &kptllnd_data.kptl_peer_rw_lock;
         ptl_process_id_t  ptl_id;
         kptl_peer_t      *new_peer;
         kptl_tx_t        *hello_tx;
@@ -1362,9 +1356,9 @@ kptllnd_find_target(kptl_net_t *net, lnet_process_id_t target,
         __u64             last_matchbits_seen;
 
         /* I expect to find the peer, so I only take a read lock... */
-        cfs_read_lock_irqsave(g_lock, flags);
+       read_lock_irqsave(g_lock, flags);
         *peerp = kptllnd_id2peer_locked(target);
-        cfs_read_unlock_irqrestore(g_lock, flags);
+       read_unlock_irqrestore(g_lock, flags);
 
         if (*peerp != NULL)
                 return 0;
@@ -1401,14 +1395,14 @@ kptllnd_find_target(kptl_net_t *net, lnet_process_id_t target,
         if (rc != 0)
                 goto unwind_1;
 
-        cfs_write_lock_irqsave(g_lock, flags);
+       write_lock_irqsave(g_lock, flags);
  again:
         /* Called only in lnd_send which can't happen after lnd_shutdown */
         LASSERT (!net->net_shutdown);
 
         *peerp = kptllnd_id2peer_locked(target);
         if (*peerp != NULL) {
-                cfs_write_unlock_irqrestore(g_lock, flags);
+               write_unlock_irqrestore(g_lock, flags);
                 goto unwind_2;
         }
 
@@ -1417,7 +1411,7 @@ kptllnd_find_target(kptl_net_t *net, lnet_process_id_t target,
         if (kptllnd_data.kptl_n_active_peers ==
             kptllnd_data.kptl_expected_peers) {
                 /* peer table full */
-                cfs_write_unlock_irqrestore(g_lock, flags);
+               write_unlock_irqrestore(g_lock, flags);
 
                 kptllnd_peertable_overflow_msg("Connection to ", target);
 
@@ -1428,7 +1422,7 @@ kptllnd_find_target(kptl_net_t *net, lnet_process_id_t target,
                         rc = -ENOMEM;
                         goto unwind_2;
                 }
-                cfs_write_lock_irqsave(g_lock, flags);
+               write_lock_irqsave(g_lock, flags);
                 kptllnd_data.kptl_expected_peers++;
                 goto again;
         }
@@ -1438,26 +1432,26 @@ kptllnd_find_target(kptl_net_t *net, lnet_process_id_t target,
         hello_tx->tx_msg->ptlm_u.hello.kptlhm_matchbits = last_matchbits_seen;
         hello_tx->tx_msg->ptlm_u.hello.kptlhm_max_msg_size =
                 *kptllnd_tunables.kptl_max_msg_size;
-                
+
         new_peer->peer_state = PEER_STATE_WAITING_HELLO;
         new_peer->peer_last_matchbits_seen = last_matchbits_seen;
-        
+
         kptllnd_peer_add_peertable_locked(new_peer);
 
-        cfs_write_unlock_irqrestore(g_lock, flags);
+       write_unlock_irqrestore(g_lock, flags);
 
-       /* NB someone else could get in now and post a message before I post
-        * the HELLO, but post_tx/check_sends take care of that! */
+        /* NB someone else could get in now and post a message before I post
+         * the HELLO, but post_tx/check_sends take care of that! */
 
         CDEBUG(D_NETTRACE, "%s: post initial hello %p\n",
                libcfs_id2str(new_peer->peer_id), hello_tx);
 
         kptllnd_post_tx(new_peer, hello_tx, 0);
         kptllnd_peer_check_sends(new_peer);
-       
+
         *peerp = new_peer;
         return 0;
-        
+
  unwind_2:
         kptllnd_peer_unreserve_buffers();
  unwind_1: