/* -*- 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>
- * E Barton <eeb@bartonsoftware.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_peer.c
+ *
+ * Author: PJ Kirner <pjkirner@clusterfs.com>
+ * Author: E Barton <eeb@bartonsoftware.com>
*/
#include "ptllnd.h"
memset(peer, 0, sizeof(*peer)); /* zero flags etc */
+ INIT_LIST_HEAD (&peer->peer_noops);
INIT_LIST_HEAD (&peer->peer_sendq);
INIT_LIST_HEAD (&peer->peer_activeq);
spin_lock_init (&peer->peer_lock);
peer->peer_state = PEER_STATE_ALLOCATED;
peer->peer_error = 0;
- peer->peer_last_alive = cfs_time_current();
+ peer->peer_last_alive = 0;
peer->peer_id = lpid;
peer->peer_ptlid = ppid;
peer->peer_credits = 1; /* enough for HELLO */
LASSERT (atomic_read(&peer->peer_refcount) == 0);
LASSERT (peer->peer_state == PEER_STATE_ALLOCATED ||
peer->peer_state == PEER_STATE_ZOMBIE);
+ LASSERT (list_empty(&peer->peer_noops));
LASSERT (list_empty(&peer->peer_sendq));
LASSERT (list_empty(&peer->peer_activeq));
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);
kptllnd_tx_decref(tx);
return;
}
-
+
spin_lock_irqsave(&peer->peer_lock, flags);
tx->tx_deadline = jiffies + (*kptllnd_tunables.kptl_timeout * HZ);
tx->tx_msg_mdh = msg_mdh;
/* Ensure HELLO is sent first */
- if (tx->tx_msg->ptlm_type == PTLLND_MSG_TYPE_HELLO)
+ if (tx->tx_msg->ptlm_type == PTLLND_MSG_TYPE_NOOP)
+ list_add(&tx->tx_list, &peer->peer_noops);
+ else if (tx->tx_msg->ptlm_type == PTLLND_MSG_TYPE_HELLO)
list_add(&tx->tx_list, &peer->peer_sendq);
else
list_add_tail(&tx->tx_list, &peer->peer_sendq);
spin_unlock_irqrestore(&peer->peer_lock, flags);
}
+static inline int
+kptllnd_peer_send_noop (kptl_peer_t *peer)
+{
+ if (!peer->peer_sent_hello ||
+ peer->peer_credits == 0 ||
+ !list_empty(&peer->peer_noops) ||
+ peer->peer_outstanding_credits < PTLLND_CREDIT_HIGHWATER)
+ return 0;
+
+ /* No tx to piggyback NOOP onto or no credit to send a tx */
+ return (list_empty(&peer->peer_sendq) || peer->peer_credits == 1);
+}
+
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;
LASSERT(!in_interrupt());
peer->peer_retry_noop = 0;
- if (list_empty(&peer->peer_sendq) &&
- peer->peer_outstanding_credits >= PTLLND_CREDIT_HIGHWATER &&
- peer->peer_credits != 0) {
-
+ if (kptllnd_peer_send_noop(peer)) {
/* post a NOOP to return credits */
spin_unlock_irqrestore(&peer->peer_lock, flags);
peer->peer_retry_noop = (tx == NULL);
}
- while (!list_empty(&peer->peer_sendq)) {
- tx = list_entry (peer->peer_sendq.next, kptl_tx_t, tx_list);
+ for (;;) {
+ if (!list_empty(&peer->peer_noops)) {
+ LASSERT (peer->peer_sent_hello);
+ tx = list_entry(peer->peer_noops.next,
+ kptl_tx_t, tx_list);
+ } else if (!list_empty(&peer->peer_sendq)) {
+ tx = list_entry(peer->peer_sendq.next,
+ kptl_tx_t, tx_list);
+ } else {
+ /* nothing to send right now */
+ break;
+ }
LASSERT (tx->tx_active);
LASSERT (!PtlHandleIsEqual(tx->tx_msg_mdh, PTL_INVALID_HANDLE));
*kptllnd_tunables.kptl_peercredits);
LASSERT (peer->peer_credits >= 0);
- /* Ensure HELLO is sent first */
- if (!peer->peer_sent_hello) {
- if (tx->tx_msg->ptlm_type != PTLLND_MSG_TYPE_HELLO)
- break;
- peer->peer_sent_hello = 1;
- }
+ msg_type = tx->tx_msg->ptlm_type;
+
+ /* Ensure HELLO is sent first */
+ if (!peer->peer_sent_hello) {
+ LASSERT (list_empty(&peer->peer_noops));
+ if (msg_type != PTLLND_MSG_TYPE_HELLO)
+ break;
+ peer->peer_sent_hello = 1;
+ }
if (peer->peer_credits == 0) {
- CDEBUG(D_NETTRACE, "%s[%d/%d+%d]: no credits for %p\n",
+ CDEBUG(D_NETTRACE, "%s[%d/%d+%d]: no credits for %s[%p]\n",
libcfs_id2str(peer->peer_id),
peer->peer_credits,
peer->peer_outstanding_credits,
- peer->peer_sent_credits, tx);
+ peer->peer_sent_credits,
+ kptllnd_msgtype2str(msg_type), tx);
break;
}
- /* Don't use the last credit unless I've got credits to
- * return */
+ /* Last/Initial credit reserved for NOOP/HELLO */
if (peer->peer_credits == 1 &&
- peer->peer_outstanding_credits == 0) {
+ msg_type != PTLLND_MSG_TYPE_HELLO &&
+ msg_type != PTLLND_MSG_TYPE_NOOP) {
CDEBUG(D_NETTRACE, "%s[%d/%d+%d]: "
- "not using last credit for %p\n",
+ "not using last credit for %s[%p]\n",
libcfs_id2str(peer->peer_id),
peer->peer_credits,
peer->peer_outstanding_credits,
- peer->peer_sent_credits, tx);
+ peer->peer_sent_credits,
+ kptllnd_msgtype2str(msg_type), tx);
break;
}
/* Discard any NOOP I queued if I'm not at the high-water mark
* any more or more messages have been queued */
- if (tx->tx_msg->ptlm_type == PTLLND_MSG_TYPE_NOOP &&
- (!list_empty(&peer->peer_sendq) ||
- peer->peer_outstanding_credits < PTLLND_CREDIT_HIGHWATER)) {
-
+ if (msg_type == PTLLND_MSG_TYPE_NOOP &&
+ !kptllnd_peer_send_noop(peer)) {
tx->tx_active = 0;
spin_unlock_irqrestore(&peer->peer_lock, flags);
tx->tx_msg->ptlm_u.rdma.kptlrm_matchbits =
peer->peer_next_matchbits++;
}
-
+
peer->peer_sent_credits += peer->peer_outstanding_credits;
peer->peer_outstanding_credits = 0;
peer->peer_credits--;
CDEBUG(D_NETTRACE, "%s[%d/%d+%d]: %s tx=%p nob=%d cred=%d\n",
libcfs_id2str(peer->peer_id), peer->peer_credits,
peer->peer_outstanding_credits, peer->peer_sent_credits,
- kptllnd_msgtype2str(tx->tx_msg->ptlm_type),
- tx, tx->tx_msg->ptlm_nob,
+ kptllnd_msgtype2str(msg_type), tx, tx->tx_msg->ptlm_nob,
tx->tx_msg->ptlm_credits);
list_add_tail(&tx->tx_list, &peer->peer_activeq);
/* Nuke everything (including tx we were trying) */
kptllnd_peer_close(peer, -EIO);
kptllnd_tx_decref(tx);
+ kptllnd_schedule_ptltrace_dump();
}
kptl_tx_t *
(tx->tx_tposted == 0) ? 0UL : (jiffies - tx->tx_tposted),
*kptllnd_tunables.kptl_timeout);
- kptllnd_dump_ptltrace();
+#ifdef CRAY_XT3
+ if (*kptllnd_tunables.kptl_ptltrace_on_timeout)
+ kptllnd_dump_ptltrace();
+#endif
kptllnd_tx_decref(tx);