Whamcloud - gitweb
LU-5151 lnet: return +ve for blocked lnet messsage 25/10625/6
authorLiang Zhen <liang.zhen@intel.com>
Fri, 6 Jun 2014 09:28:07 +0000 (17:28 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 11 Jun 2014 02:41:28 +0000 (02:41 +0000)
returned value of lnet_post_send_locked and
lnet_post_routed_recv_locked are changed to -ve by:
http://review.whamcloud.com/#/c/9369/

this is wrong because callers rely on +ve to identify blocked
message which is not a failure.

To respect linux kernel coding style and not use positive error
code, this patch adds two macros as non-error returned values of
these functions:
  LNET_CREDIT_OK has credit for message
  LNET_CREDIT_WAIT no credit and message is blocked

both these functions will return these two values instead of 0
and EAGAIN

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Id809e4fa6e22780a0bd9ad9c0f0ef96b2c9aa879
Reviewed-on: http://review.whamcloud.com/10625
Tested-by: Jenkins
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/lnet/lib-move.c

index 6097ae0..2cd3dad 100644 (file)
 
 #include <lnet/lib-lnet.h>
 
+/** lnet message has credit and can be submitted to lnd for send/receive */
+#define LNET_CREDIT_OK         0
+/** lnet message is waiting for credit */
+#define LNET_CREDIT_WAIT       1
+
 static int local_nid_dist_zero = 1;
 CFS_MODULE_PARM(local_nid_dist_zero, "i", int, 0444,
                 "Reserved");
@@ -821,8 +826,8 @@ lnet_peer_alive_locked (lnet_peer_t *lp)
  *       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 LNET_CREDIT_OK If \a msg sent or OK to send.
+ * \retval LNET_CREDIT_WAIT 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.
  */
@@ -883,7 +888,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
                if (lp->lp_txcredits < 0) {
                        msg->msg_tx_delayed = 1;
                        list_add_tail(&msg->msg_list, &lp->lp_txq);
-                       return -EAGAIN;
+                       return LNET_CREDIT_WAIT;
                }
        }
 
@@ -900,7 +905,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
                if (tq->tq_credits < 0) {
                        msg->msg_tx_delayed = 1;
                        list_add_tail(&msg->msg_list, &tq->tq_delayed);
-                       return -EAGAIN;
+                       return LNET_CREDIT_WAIT;
                }
        }
 
@@ -909,7 +914,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
                lnet_ni_send(ni, msg);
                lnet_net_lock(cpt);
        }
-       return 0;
+       return LNET_CREDIT_OK;
 }
 
 #ifdef __KERNEL__
@@ -938,8 +943,9 @@ int
 lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
 {
        /* lnet_parse is going to lnet_net_unlock immediately after this, so it
-        * sets do_recv FALSE and I don't do the unlock/send/lock bit.  I
-        * return EAGAIN if msg blocked and 0 if received or OK to receive */
+        * sets do_recv FALSE and I don't do the unlock/send/lock bit.
+        * I return LNET_CREDIT_WAIT if msg blocked and LNET_CREDIT_OK if
+        * received or OK to receive */
         lnet_peer_t         *lp = msg->msg_rxpeer;
         lnet_rtrbufpool_t   *rbp;
         lnet_rtrbuf_t       *rb;
@@ -968,7 +974,7 @@ lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
                        LASSERT(msg->msg_rx_ready_delay);
                        msg->msg_rx_delayed = 1;
                        list_add_tail(&msg->msg_list, &lp->lp_rtrq);
-                       return -EAGAIN;
+                       return LNET_CREDIT_WAIT;
                }
        }
 
@@ -988,7 +994,7 @@ lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
                        LASSERT(msg->msg_rx_ready_delay);
                        msg->msg_rx_delayed = 1;
                        list_add_tail(&msg->msg_list, &rbp->rbp_msgs);
-                       return -EAGAIN;
+                       return LNET_CREDIT_WAIT;
                }
        }
 
@@ -1007,7 +1013,7 @@ lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
                             0, msg->msg_len, msg->msg_len);
                lnet_net_lock(cpt);
        }
-       return 0;
+       return LNET_CREDIT_OK;
 }
 #endif
 
@@ -1405,13 +1411,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 || rc == -ECANCELED)
+       if (rc < 0)
                return rc;
 
-       if (rc == 0)
+       if (rc == LNET_CREDIT_OK)
                 lnet_ni_send(src_ni, msg);
 
-       return 0; /* rc == 0 or -EAGAIN */
+       return 0; /* rc == LNET_CREDIT_OK or LNET_CREDIT_WAIT */
 }
 
 static void
@@ -1677,6 +1683,11 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
        return 0;
 }
 
+/**
+ * \retval LNET_CREDIT_OK      If \a msg is forwarded
+ * \retval LNET_CREDIT_WAIT    If \a msg is blocked because w/o buffer
+ * \retval -ve                 error code
+ */
 static int
 lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg)
 {
@@ -1963,7 +1974,8 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
 
                if (rc < 0)
                        goto free_drop;
-               if (rc == 0) {
+
+               if (rc == LNET_CREDIT_OK) {
                        lnet_ni_recv(ni, msg->msg_private, msg, 0,
                                     0, payload_length, payload_length);
                }