Whamcloud - gitweb
- back out peer_buffer_credits changes, as requested by rread.
[fs/lustre-release.git] / lnet / klnds / ptllnd / ptllnd.c
index f020fac..b148fe5 100755 (executable)
@@ -1,19 +1,41 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Copyright (C) 2005 Cluster File Systems, Inc. All rights reserved.
- *   Author: PJ Kirner <pjkirner@clusterfs.com>
+ * GPL HEADER START
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is confidential source code owned by Cluster File Systems.
- *   No viewing, modification, compilation, redistribution, or any other
- *   form of use is permitted except through a signed license agreement.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   If you have not signed such an agreement, then you have no rights to
- *   this file.  Please destroy it immediately and contact CFS.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/klnds/ptllnd/ptllnd.c
+ *
+ * Author: PJ Kirner <pjkirner@clusterfs.com>
  */
 
 #include "ptllnd.h"
@@ -23,6 +45,7 @@ lnd_t kptllnd_lnd = {
         .lnd_startup    = kptllnd_startup,
         .lnd_shutdown   = kptllnd_shutdown,
         .lnd_ctl        = kptllnd_ctl,
+        .lnd_query      = kptllnd_query,
         .lnd_send       = kptllnd_send,
         .lnd_recv       = kptllnd_recv,
         .lnd_eager_recv = kptllnd_eager_recv,
@@ -454,6 +477,27 @@ kptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
         return rc;
 }
 
+void
+kptllnd_query (lnet_ni_t *ni, lnet_nid_t nid, time_t *when)
+{
+        kptl_peer_t       *peer = NULL;
+        lnet_process_id_t  id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
+        unsigned long      flags;
+
+        /* NB: kptllnd_find_target connects to peer if necessary */
+        if (kptllnd_find_target(&peer, id) != 0)
+                return;
+
+        spin_lock_irqsave(&peer->peer_lock, flags);
+        if (peer->peer_last_alive != 0)
+                *when = cfs_time_current_sec() -
+                        cfs_duration_sec(cfs_time_current() -
+                                         peer->peer_last_alive);
+        spin_unlock_irqrestore(&peer->peer_lock, flags);
+        kptllnd_peer_decref(peer);
+        return;
+}
+
 int
 kptllnd_startup (lnet_ni_t *ni)
 {
@@ -475,6 +519,11 @@ kptllnd_startup (lnet_ni_t *ni)
                 return -EINVAL;
         }
 
+        if (*kptllnd_tunables.kptl_peercredits > PTLLND_MSG_MAX_CREDITS) {
+                CERROR("peercredits must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
+                return -EINVAL;
+        }
+
         *kptllnd_tunables.kptl_max_msg_size &= ~7;
         if (*kptllnd_tunables.kptl_max_msg_size < PTLLND_MIN_BUFFER_SIZE)
                 *kptllnd_tunables.kptl_max_msg_size = PTLLND_MIN_BUFFER_SIZE;
@@ -609,6 +658,7 @@ kptllnd_startup (lnet_ni_t *ni)
          */
         rwlock_init(&kptllnd_data.kptl_peer_rw_lock);
         init_waitqueue_head(&kptllnd_data.kptl_watchdog_waitq);
+        atomic_set(&kptllnd_data.kptl_needs_ptltrace, 0);
         INIT_LIST_HEAD(&kptllnd_data.kptl_closing_peers);
         INIT_LIST_HEAD(&kptllnd_data.kptl_zombie_peers);
 
@@ -881,7 +931,7 @@ kptllnd_module_fini (void)
         kptllnd_tunables_fini();
 }
 
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Kernel Portals LND v1.00");
 MODULE_LICENSE("GPL");