All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dilger, Andreas" <andreas.dilger@intel.com>
To: Nilesh Kokane <nilesh.kokane05@gmail.com>,
	"Drokin, Oleg" <oleg.drokin@intel.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"suneel.raikar@gmail.com" <suneel.raikar@gmail.com>
Subject: Re: [PATCH 2/2] Staging: lustre: lnet: lib-move return of an errno should typically be negative (ie: return -EAGAIN)
Date: Fri, 23 Oct 2015 11:40:26 +0000	[thread overview]
Message-ID: <D24F76B5.11353B%andreas.dilger@intel.com> (raw)
In-Reply-To: <1445574603-4023-1-git-send-email-Nilesh.Kokane05@gmail.com>

On 2015/10/22, 22:30, "Nilesh Kokane" <nilesh.kokane05@gmail.com> wrote:
>Fixed- Return of an errno should typically be negative (ie: return
>-EAGAIN)

Nak. Please do not change these function return values.  They are
converted as necessary by the callers before returning to userspace, but
allow the code to distinguish between errors generated internally or from
lower networking layers.

As you will note, many of them are explicitly annotated with comments that
they are returning positive values.  The patch as it stands would totally
break the code.

Cheers, Andreas

>Signed-off-by: Nilesh Kokane <Nilesh.Kokane05@gmail.com>
>---
> drivers/staging/lustre/lnet/lnet/lib-move.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c
>b/drivers/staging/lustre/lnet/lnet/lib-move.c
>index 433faae..10f886f 100644
>--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
>+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
>@@ -808,7 +808,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
> 			lnet_finalize(ni, msg, -EHOSTUNREACH);
> 
> 		lnet_net_lock(cpt);
>-		return EHOSTUNREACH;
>+		return -EHOSTUNREACH;
> 	}
> 
> 	if (msg->msg_md != NULL &&
>@@ -821,7 +821,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
> 			lnet_finalize(ni, msg, -ECANCELED);
> 
> 		lnet_net_lock(cpt);
>-		return ECANCELED;
>+		return -ECANCELED;
> 	}
> 
> 	if (!msg->msg_peertxcredit) {
>@@ -838,7 +838,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 -EAGAIN;
> 		}
> 	}
> 
>@@ -855,7 +855,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 -EAGAIN;
> 		}
> 	}
> 
>@@ -922,7 +922,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 -EAGAIN;
> 		}
> 	}
> 
>@@ -942,7 +942,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 -EAGAIN;
> 		}
> 	}
> 
>@@ -1426,7 +1426,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
> 			libcfs_id2str(info.mi_id), info.mi_portal,
> 			info.mi_mbits, info.mi_roffset, info.mi_rlength, rc);
> 
>-		return ENOENT;	/* +ve: OK but no match */
>+		return -ENOENT;	/* +ve: OK but no match */
> 	}
> }
> 
>@@ -1457,7 +1457,7 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int
>rdma_get)
> 		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 */
>+		return -ENOENT;	/* +ve: OK but no match */
> 	}
> 
> 	LASSERT(rc == LNET_MATCHMD_OK);
>@@ -1524,7 +1524,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
> 			       md->md_me->me_portal);
> 
> 		lnet_res_unlock(cpt);
>-		return ENOENT;		  /* +ve: OK but no match */
>+		return -ENOENT;		  /* +ve: OK but no match */
> 	}
> 
> 	LASSERT(md->md_offset == 0);
>@@ -1539,7 +1539,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
> 			rlength, hdr->msg.reply.dst_wmd.wh_object_cookie,
> 			mlength);
> 		lnet_res_unlock(cpt);
>-		return ENOENT;	  /* +ve: OK but no match */
>+		return -ENOENT;	  /* +ve: OK but no match */
> 	}
> 
> 	CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md %#llx\n",
>@@ -1592,7 +1592,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
> 			       md->md_me->me_portal);
> 
> 		lnet_res_unlock(cpt);
>-		return ENOENT;		  /* +ve! */
>+		return -ENOENT;		  /* +ve! */
> 	}
> 
> 	CDEBUG(D_NET, "%s: ACK from %s into md %#llx\n",
>-- 
>1.9.1
>
>


Cheers, Andreas
-- 
Andreas Dilger

Lustre Software Architect
Intel High Performance Data Division



  parent reply	other threads:[~2015-10-23 11:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23  4:30 [PATCH 2/2] Staging: lustre: lnet: lib-move return of an errno should typically be negative (ie: return -EAGAIN) Nilesh Kokane
2015-10-23  5:00 ` Dan Carpenter
2015-10-23  6:45   ` Dan Carpenter
2015-10-23 11:40 ` Dilger, Andreas [this message]
2015-10-23 12:09   ` Nilesh Kokane
2015-10-23 15:05 ` Simmons, James A.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D24F76B5.11353B%andreas.dilger@intel.com \
    --to=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nilesh.kokane05@gmail.com \
    --cc=oleg.drokin@intel.com \
    --cc=suneel.raikar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.