staging: lustre: remove LPX64 define
[deliverable/linux.git] / drivers / staging / lustre / lnet / lnet / lib-move.c
index bbf43ae04ed0268f0fa6019c8a8e323b803e4661..4b9567d67f33a8e1ae22242b7af2f7362eb26fcb 100644 (file)
@@ -40,7 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <linux/lnet/lib-lnet.h>
+#include "../../include/linux/lnet/lib-lnet.h"
 
 static int local_nid_dist_zero = 1;
 module_param(local_nid_dist_zero, int, 0444);
@@ -682,7 +682,7 @@ lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
 void
 lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
 {
-       cfs_time_t last_alive = 0;
+       unsigned long last_alive = 0;
 
        LASSERT(lnet_peer_aliveness_enabled(lp));
        LASSERT(ni->ni_lnd->lnd_query != NULL);
@@ -699,10 +699,10 @@ lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
 
 /* NB: always called with lnet_net_lock held */
 static inline int
-lnet_peer_is_alive(lnet_peer_t *lp, cfs_time_t now)
+lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now)
 {
        int     alive;
-       cfs_time_t deadline;
+       unsigned long deadline;
 
        LASSERT(lnet_peer_aliveness_enabled(lp));
 
@@ -734,7 +734,7 @@ lnet_peer_is_alive(lnet_peer_t *lp, cfs_time_t now)
 int
 lnet_peer_alive_locked(lnet_peer_t *lp)
 {
-       cfs_time_t now = cfs_time_current();
+       unsigned long now = cfs_time_current();
 
        if (!lnet_peer_aliveness_enabled(lp))
                return -ENODEV;
@@ -747,11 +747,11 @@ lnet_peer_alive_locked(lnet_peer_t *lp)
        if (lp->lp_last_query != 0) {
                static const int lnet_queryinterval = 1;
 
-               cfs_time_t next_query =
+               unsigned long next_query =
                           cfs_time_add(lp->lp_last_query,
                                        cfs_time_seconds(lnet_queryinterval));
 
-               if (cfs_time_before(now, next_query)) {
+               if (time_before(now, next_query)) {
                        if (lp->lp_alive)
                                CWARN("Unexpected aliveness of peer %s: "
                                      "%d < %d (%d/%d)\n",
@@ -773,26 +773,30 @@ lnet_peer_alive_locked(lnet_peer_t *lp)
        return 0;
 }
 
-int
+/**
+ * \param msg The message to be sent.
+ * \param do_send True if lnet_ni_send() should be called in this function.
+ *       lnet_send() is going to lnet_net_unlock immediately after this, so
+ *       it sets do_send FALSE and I don't do the unlock/send/lock bit.
+ *
+ * \retval 0 If \a msg sent or OK to send.
+ * \retval EAGAIN If \a msg blocked for credit.
+ * \retval EHOSTUNREACH If the next hop of the message appears dead.
+ * \retval ECANCELED If the MD of the message has been unlinked.
+ */
+static int
 lnet_post_send_locked(lnet_msg_t *msg, int do_send)
 {
-       /* lnet_send is going to lnet_net_unlock immediately after this,
-        * so it sets do_send FALSE and I don't do the unlock/send/lock bit.
-        * I return EAGAIN if msg blocked, EHOSTUNREACH if msg_txpeer
-        * appears dead, and 0 if sent or OK to send */
-       struct lnet_peer        *lp = msg->msg_txpeer;
-       struct lnet_ni          *ni = lp->lp_ni;
-       struct lnet_tx_queue    *tq;
-       int                     cpt;
+       lnet_peer_t             *lp = msg->msg_txpeer;
+       lnet_ni_t               *ni = lp->lp_ni;
+       int                     cpt = msg->msg_tx_cpt;
+       struct lnet_tx_queue    *tq = ni->ni_tx_queues[cpt];
 
        /* non-lnet_send() callers have checked before */
        LASSERT(!do_send || msg->msg_tx_delayed);
        LASSERT(!msg->msg_receiving);
        LASSERT(msg->msg_tx_committed);
 
-       cpt = msg->msg_tx_cpt;
-       tq = ni->ni_tx_queues[cpt];
-
        /* NB 'lp' is always the next hop */
        if ((msg->msg_target.pid & LNET_PID_USERFLAG) == 0 &&
            lnet_peer_alive_locked(lp) == 0) {
@@ -809,6 +813,20 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
                return EHOSTUNREACH;
        }
 
+       if (msg->msg_md != NULL &&
+           (msg->msg_md->md_flags & LNET_MD_FLAG_ABORTED) != 0) {
+               lnet_net_unlock(cpt);
+
+               CNETERR("Aborting message for %s: LNetM[DE]Unlink() already "
+                       "called on the MD/ME.\n",
+                       libcfs_id2str(msg->msg_target));
+               if (do_send)
+                       lnet_finalize(ni, msg, -ECANCELED);
+
+               lnet_net_lock(cpt);
+               return ECANCELED;
+       }
+
        if (!msg->msg_peertxcredit) {
                LASSERT((lp->lp_txcredits < 0) ==
                         !list_empty(&lp->lp_txq));
@@ -1327,13 +1345,13 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid)
        rc = lnet_post_send_locked(msg, 0);
        lnet_net_unlock(cpt);
 
-       if (rc == EHOSTUNREACH)
-               return -EHOSTUNREACH;
+       if (rc == EHOSTUNREACH || rc == ECANCELED)
+               return -rc;
 
        if (rc == 0)
                lnet_ni_send(src_ni, msg);
 
-       return 0;
+       return 0; /* rc == 0 or EAGAIN */
 }
 
 static void
@@ -1408,8 +1426,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
                /* fall through */
 
        case LNET_MATCHMD_DROP:
-               CNETERR("Dropping PUT from %s portal %d match "LPU64
-                       " offset %d length %d: %d\n",
+               CNETERR("Dropping PUT from %s portal %d match %llu offset %d length %d: %d\n",
                        libcfs_id2str(info.mi_id), info.mi_portal,
                        info.mi_mbits, info.mi_roffset, info.mi_rlength, rc);
 
@@ -1441,8 +1458,7 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
 
        rc = lnet_ptl_match_md(&info, msg);
        if (rc == LNET_MATCHMD_DROP) {
-               CNETERR("Dropping GET from %s portal %d match "LPU64
-                       " offset %d length %d\n",
+               CNETERR("Dropping GET from %s portal %d match %llu offset %d length %d\n",
                        libcfs_id2str(info.mi_id), info.mi_portal,
                        info.mi_mbits, info.mi_roffset, info.mi_rlength);
                return ENOENT;  /* +ve: OK but no match */
@@ -1502,8 +1518,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
        /* NB handles only looked up by creator (no flips) */
        md = lnet_wire_handle2md(&hdr->msg.reply.dst_wmd);
        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
-               CNETERR("%s: Dropping REPLY from %s for %s "
-                       "MD "LPX64"."LPX64"\n",
+               CNETERR("%s: Dropping REPLY from %s for %s MD %#llx.%#llx\n",
                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                        (md == NULL) ? "invalid" : "inactive",
                        hdr->msg.reply.dst_wmd.wh_interface_cookie,
@@ -1523,8 +1538,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
 
        if (mlength < rlength &&
            (md->md_options & LNET_MD_TRUNCATE) == 0) {
-               CNETERR("%s: Dropping REPLY from %s length %d "
-                       "for MD "LPX64" would overflow (%d)\n",
+               CNETERR("%s: Dropping REPLY from %s length %d for MD %#llx would overflow (%d)\n",
                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                        rlength, hdr->msg.reply.dst_wmd.wh_object_cookie,
                        mlength);
@@ -1532,7 +1546,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
                return ENOENT;    /* +ve: OK but no match */
        }
 
-       CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md "LPX64"\n",
+       CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md %#llx\n",
               libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
               mlength, rlength, hdr->msg.reply.dst_wmd.wh_object_cookie);
 
@@ -1572,7 +1586,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
                /* Don't moan; this is expected */
                CDEBUG(D_NET,
-                      "%s: Dropping ACK from %s to %s MD "LPX64"."LPX64"\n",
+                      "%s: Dropping ACK from %s to %s MD %#llx.%#llx\n",
                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                       (md == NULL) ? "invalid" : "inactive",
                       hdr->msg.ack.dst_wmd.wh_interface_cookie,
@@ -1585,7 +1599,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
                return ENOENT;            /* +ve! */
        }
 
-       CDEBUG(D_NET, "%s: ACK from %s into md "LPX64"\n",
+       CDEBUG(D_NET, "%s: ACK from %s into md %#llx\n",
               libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
               hdr->msg.ack.dst_wmd.wh_object_cookie);
 
@@ -1662,20 +1676,20 @@ lnet_print_hdr(lnet_hdr_t *hdr)
                break;
 
        case LNET_MSG_PUT:
-               CWARN("    Ptl index %d, ack md "LPX64"."LPX64", "
-                     "match bits "LPU64"\n",
+               CWARN("    Ptl index %d, ack md %#llx.%#llx, "
+                     "match bits %llu\n",
                      hdr->msg.put.ptl_index,
                      hdr->msg.put.ack_wmd.wh_interface_cookie,
                      hdr->msg.put.ack_wmd.wh_object_cookie,
                      hdr->msg.put.match_bits);
-               CWARN("    Length %d, offset %d, hdr data "LPX64"\n",
+               CWARN("    Length %d, offset %d, hdr data %#llx\n",
                      hdr->payload_length, hdr->msg.put.offset,
                      hdr->msg.put.hdr_data);
                break;
 
        case LNET_MSG_GET:
-               CWARN("    Ptl index %d, return md "LPX64"."LPX64", "
-                     "match bits "LPU64"\n", hdr->msg.get.ptl_index,
+               CWARN("    Ptl index %d, return md %#llx.%#llx, "
+                     "match bits %llu\n", hdr->msg.get.ptl_index,
                      hdr->msg.get.return_wmd.wh_interface_cookie,
                      hdr->msg.get.return_wmd.wh_object_cookie,
                      hdr->msg.get.match_bits);
@@ -1685,7 +1699,7 @@ lnet_print_hdr(lnet_hdr_t *hdr)
                break;
 
        case LNET_MSG_ACK:
-               CWARN("    dst md "LPX64"."LPX64", "
+               CWARN("    dst md %#llx.%#llx, "
                      "manipulated length %d\n",
                      hdr->msg.ack.dst_wmd.wh_interface_cookie,
                      hdr->msg.ack.dst_wmd.wh_object_cookie,
@@ -1693,7 +1707,7 @@ lnet_print_hdr(lnet_hdr_t *hdr)
                break;
 
        case LNET_MSG_REPLY:
-               CWARN("    dst md "LPX64"."LPX64", "
+               CWARN("    dst md %#llx.%#llx, "
                      "length %d\n",
                      hdr->msg.reply.dst_wmd.wh_interface_cookie,
                      hdr->msg.reply.dst_wmd.wh_object_cookie,
@@ -1762,11 +1776,11 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
        }
 
        if (the_lnet.ln_routing &&
-           ni->ni_last_alive != cfs_time_current_sec()) {
+           ni->ni_last_alive != get_seconds()) {
                lnet_ni_lock(ni);
 
                /* NB: so far here is the only place to set NI status to "up */
-               ni->ni_last_alive = cfs_time_current_sec();
+               ni->ni_last_alive = get_seconds();
                if (ni->ni_status != NULL &&
                    ni->ni_status->ns_status == LNET_NI_STATUS_DOWN)
                        ni->ni_status->ns_status = LNET_NI_STATUS_UP;
@@ -1945,8 +1959,7 @@ lnet_drop_delayed_msg_list(struct list_head *head, char *reason)
                LASSERT(msg->msg_rxpeer != NULL);
                LASSERT(msg->msg_hdr.type == LNET_MSG_PUT);
 
-               CWARN("Dropping delayed PUT from %s portal %d match "LPU64
-                     " offset %d length %d: %s\n",
+               CWARN("Dropping delayed PUT from %s portal %d match %llu offset %d length %d: %s\n",
                      libcfs_id2str(id),
                      msg->msg_hdr.msg.put.ptl_index,
                      msg->msg_hdr.msg.put.match_bits,
@@ -1991,7 +2004,7 @@ lnet_recv_delayed_msg_list(struct list_head *head)
                LASSERT(msg->msg_hdr.type == LNET_MSG_PUT);
 
                CDEBUG(D_NET, "Resuming delayed PUT from %s portal %d "
-                      "match "LPU64" offset %d length %d.\n",
+                      "match %llu offset %d length %d.\n",
                        libcfs_id2str(id), msg->msg_hdr.msg.put.ptl_index,
                        msg->msg_hdr.msg.put.match_bits,
                        msg->msg_hdr.msg.put.offset,
@@ -2079,7 +2092,7 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack,
 
        md = lnet_handle2md(&mdh);
        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
-               CERROR("Dropping PUT ("LPU64":%d:%s): MD (%d) invalid\n",
+               CERROR("Dropping PUT (%llu:%d:%s): MD (%d) invalid\n",
                       match_bits, portal, libcfs_id2str(target),
                       md == NULL ? -1 : md->md_threshold);
                if (md != NULL && md->md_me != NULL)
@@ -2278,7 +2291,7 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
 
        md = lnet_handle2md(&mdh);
        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
-               CERROR("Dropping GET ("LPU64":%d:%s): MD (%d) invalid\n",
+               CERROR("Dropping GET (%llu:%d:%s): MD (%d) invalid\n",
                       match_bits, portal, libcfs_id2str(target),
                       md == NULL ? -1 : md->md_threshold);
                if (md != NULL && md->md_me != NULL)
@@ -2288,7 +2301,6 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
                lnet_res_unlock(cpt);
 
                lnet_msg_free(msg);
-
                return -ENOENT;
        }
 
This page took 0.031974 seconds and 5 git commands to generate.