Whamcloud - gitweb
LU-3195 tests: Interop 2.3.0<->2.3.63 sanity-quota test_6
[fs/lustre-release.git] / lnet / klnds / ptllnd / ptllnd_cb.c
index 9d22e2d..e815607 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/
@@ -257,7 +257,7 @@ kptllnd_active_rdma(kptl_rx_t *rx, lnet_msg_t *lntmsg, int type,
                 return -EIO;
         }
 
-        cfs_spin_lock_irqsave(&peer->peer_lock, flags);
+       spin_lock_irqsave(&peer->peer_lock, flags);
 
         tx->tx_lnet_msg = lntmsg;
         /* lnet_finalize() will be called when tx is torn down, so I must
@@ -270,7 +270,7 @@ kptllnd_active_rdma(kptl_rx_t *rx, lnet_msg_t *lntmsg, int type,
 
         /* peer has now got my ref on 'tx' */
 
-        cfs_spin_unlock_irqrestore(&peer->peer_lock, flags);
+       spin_unlock_irqrestore(&peer->peer_lock, flags);
 
         tx->tx_tposted = jiffies;
 
@@ -301,7 +301,6 @@ kptllnd_active_rdma(kptl_rx_t *rx, lnet_msg_t *lntmsg, int type,
                 kptllnd_peer_close(peer, -EIO);
                 /* Everything (including this RDMA) queued on the peer will
                  * be completed with failure */
-                kptllnd_schedule_ptltrace_dump();
         }
 
         return 0;
@@ -321,7 +320,8 @@ kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
         unsigned int      payload_offset = lntmsg->msg_offset;
         unsigned int      payload_nob = lntmsg->msg_len;
         kptl_net_t       *net = ni->ni_data;
-        kptl_peer_t      *peer;
+        kptl_peer_t      *peer = NULL;
+        int               mpflag = 0;
         kptl_tx_t        *tx;
         int               nob;
         int               nfrag;
@@ -335,10 +335,13 @@ kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
         LASSERT (!(payload_kiov != NULL && payload_iov != NULL));
         LASSERT (!cfs_in_interrupt());
 
+        if (lntmsg->msg_vmflush)
+                mpflag = cfs_memory_pressure_get_and_set();
+
         rc = kptllnd_find_target(net, target, &peer);
         if (rc != 0)
-                return rc;
-        
+                goto out;
+
         /* NB peer->peer_id does NOT always equal target, be careful with
          * which one to use */
         switch (type) {
@@ -416,7 +419,7 @@ kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                         kptllnd_init_rdma_md(tx, lntmsg->msg_md->md_niov,
                                              NULL, lntmsg->msg_md->md_iov.kiov,
                                              0, lntmsg->msg_md->md_length);
-                
+
                 tx->tx_lnet_msg = lntmsg;
                 tx->tx_msg->ptlm_u.rdma.kptlrm_hdr = *hdr;
                 kptllnd_init_msg (tx->tx_msg, PTLLND_MSG_TYPE_GET,
@@ -470,7 +473,7 @@ kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                                                 payload_offset, payload_nob);
 #endif
         }
-        
+
         nob = offsetof(kptl_immediate_msg_t, kptlim_payload[payload_nob]);
         kptllnd_init_msg(tx->tx_msg, PTLLND_MSG_TYPE_IMMEDIATE, target, nob);
 
@@ -486,7 +489,10 @@ kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
         kptllnd_tx_launch(peer, tx, nfrag);
 
  out:
-        kptllnd_peer_decref(peer);
+        if (lntmsg->msg_vmflush)
+                cfs_memory_pressure_restore(mpflag);
+        if (peer)
+                kptllnd_peer_decref(peer);
         return rc;
 }
 
@@ -540,17 +546,6 @@ kptllnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
         LASSERT (!(kiov != NULL && iov != NULL)); /* never both */
         LASSERT (niov <= PTL_MD_MAX_IOV);       /* !!! */
 
-#ifdef CRAY_XT3
-        if (lntmsg != NULL &&
-            rx->rx_uid != 0) {
-                /* Set the UID if the sender's uid isn't 0; i.e. non-root
-                 * running in userspace (e.g. a catamount node; linux kernel
-                 * senders, including routers have uid 0).  If this is a lustre
-                 * RPC request, this tells lustre not to trust the creds in the
-                 * RPC message body. */
-                lnet_set_msg_uid(ni, lntmsg, rx->rx_uid);
-        }
-#endif
         switch(rxmsg->ptlm_type)
         {
         default:
@@ -662,11 +657,11 @@ kptllnd_thread_start (int (*fn)(void *arg), void *arg)
 
         cfs_atomic_inc(&kptllnd_data.kptl_nthreads);
 
-        pid = cfs_kernel_thread (fn, arg, 0);
+        pid = cfs_create_thread (fn, arg, 0);
         if (pid >= 0)
                 return 0;
 
-        CERROR("Failed to start cfs_kernel_thread: error %d\n", (int)pid);
+        CERROR("Failed to start thread: error %d\n", (int)pid);
         kptllnd_thread_fini();
         return (int)pid;
 }
@@ -692,24 +687,7 @@ kptllnd_watchdog(void *arg)
         /* threads shut down in phase 2 after all peers have been destroyed */
         while (kptllnd_data.kptl_shutdown < 2) {
 
-                /* add a check for needs ptltrace
-                 * yes, this is blatant hijacking of this thread
-                 * we can't dump directly from tx or rx _callbacks as it
-                 * deadlocks portals and takes out the node
-                */
-
-                if (cfs_atomic_read(&kptllnd_data.kptl_needs_ptltrace)) {
-#ifdef CRAY_XT3
-                        kptllnd_dump_ptltrace();
-                        /* we only dump once, no matter how many pending */
-                        cfs_atomic_set(&kptllnd_data.kptl_needs_ptltrace, 0);
-#else
-                        LBUG();
-#endif
-                }
-
                 timeout = (int)(deadline - jiffies);
-
                 if (timeout <= 0) {
                         const int n = 4;
                         const int p = 1;
@@ -777,7 +755,7 @@ kptllnd_scheduler (void *arg)
 
         cfs_waitlink_init(&waitlink);
 
-        cfs_spin_lock_irqsave(&kptllnd_data.kptl_sched_lock, flags);
+       spin_lock_irqsave(&kptllnd_data.kptl_sched_lock, flags);
 
         /* threads shut down in phase 2 after all peers have been destroyed */
         while (kptllnd_data.kptl_shutdown < 2) {
@@ -789,14 +767,14 @@ kptllnd_scheduler (void *arg)
                                              kptl_rx_t, rx_list);
                         cfs_list_del(&rx->rx_list);
 
-                        cfs_spin_unlock_irqrestore(&kptllnd_data. \
+                       spin_unlock_irqrestore(&kptllnd_data. \
                                                    kptl_sched_lock,
                                                    flags);
 
                         kptllnd_rx_parse(rx);
                         did_something = 1;
 
-                        cfs_spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
+                       spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
                                               flags);
                 }
 
@@ -806,14 +784,14 @@ kptllnd_scheduler (void *arg)
                                               rxb_repost_list);
                         cfs_list_del(&rxb->rxb_repost_list);
 
-                        cfs_spin_unlock_irqrestore(&kptllnd_data. \
+                       spin_unlock_irqrestore(&kptllnd_data. \
                                                    kptl_sched_lock,
                                                    flags);
 
                         kptllnd_rx_buffer_post(rxb);
                         did_something = 1;
 
-                        cfs_spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
+                       spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
                                               flags);
                 }
 
@@ -822,13 +800,13 @@ kptllnd_scheduler (void *arg)
                                              kptl_tx_t, tx_list);
                         cfs_list_del_init(&tx->tx_list);
 
-                        cfs_spin_unlock_irqrestore(&kptllnd_data. \
+                       spin_unlock_irqrestore(&kptllnd_data. \
                                                    kptl_sched_lock, flags);
 
                         kptllnd_tx_fini(tx);
                         did_something = 1;
 
-                        cfs_spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
+                       spin_lock_irqsave(&kptllnd_data.kptl_sched_lock,
                                               flags);
                 }
 
@@ -840,7 +818,7 @@ kptllnd_scheduler (void *arg)
                 cfs_set_current_state(CFS_TASK_INTERRUPTIBLE);
                 cfs_waitq_add_exclusive(&kptllnd_data.kptl_sched_waitq,
                                         &waitlink);
-                cfs_spin_unlock_irqrestore(&kptllnd_data.kptl_sched_lock,
+               spin_unlock_irqrestore(&kptllnd_data.kptl_sched_lock,
                                            flags);
 
                 if (!did_something)
@@ -851,12 +829,12 @@ kptllnd_scheduler (void *arg)
                 cfs_set_current_state(CFS_TASK_RUNNING);
                 cfs_waitq_del(&kptllnd_data.kptl_sched_waitq, &waitlink);
 
-                cfs_spin_lock_irqsave(&kptllnd_data.kptl_sched_lock, flags);
+               spin_lock_irqsave(&kptllnd_data.kptl_sched_lock, flags);
 
                 counter = 0;
         }
 
-        cfs_spin_unlock_irqrestore(&kptllnd_data.kptl_sched_lock, flags);
+       spin_unlock_irqrestore(&kptllnd_data.kptl_sched_lock, flags);
 
         kptllnd_thread_fini();
         return 0;