All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites
@ 2020-05-17 11:15 Sagi Grimberg
  2020-05-18 15:07 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Sagi Grimberg @ 2020-05-17 11:15 UTC (permalink / raw)
  To: linux-nvme, Christoph Hellwig; +Cc: Keith Busch, Chaitanya Kulkarni

Have routines handle errors and just bail out of the poll loop. This simplifies
the code and will help as we may enhance the poll loop logic and these are somewhat
in the way.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/target/tcp.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index f8dd69f3b657..9527cdc19611 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -723,6 +723,13 @@ static int nvmet_tcp_try_send(struct nvmet_tcp_queue *queue,
 		(*sends)++;
 	}
 
+	if (ret < 0) {
+		if (ret == -EPIPE || ret == -ECONNRESET)
+			kernel_sock_shutdown(queue->sock, SHUT_RDWR);
+		else
+			nvmet_tcp_fatal_error(queue);
+	}
+
 	return ret;
 }
 
@@ -1164,6 +1171,13 @@ static int nvmet_tcp_try_recv(struct nvmet_tcp_queue *queue,
 		(*recvs)++;
 	}
 
+	if (ret < 0) {
+		if (ret == -EPIPE || ret == -ECONNRESET)
+			kernel_sock_shutdown(queue->sock, SHUT_RDWR);
+		else
+			nvmet_tcp_fatal_error(queue);
+	}
+
 	return ret;
 }
 
@@ -1188,27 +1202,16 @@ static void nvmet_tcp_io_work(struct work_struct *w)
 		pending = false;
 
 		ret = nvmet_tcp_try_recv(queue, NVMET_TCP_RECV_BUDGET, &ops);
-		if (ret > 0) {
+		if (ret > 0)
 			pending = true;
-		} else if (ret < 0) {
-			if (ret == -EPIPE || ret == -ECONNRESET)
-				kernel_sock_shutdown(queue->sock, SHUT_RDWR);
-			else
-				nvmet_tcp_fatal_error(queue);
+		else if (ret < 0)
 			return;
-		}
 
 		ret = nvmet_tcp_try_send(queue, NVMET_TCP_SEND_BUDGET, &ops);
-		if (ret > 0) {
-			/* transmitted message/data */
+		if (ret > 0)
 			pending = true;
-		} else if (ret < 0) {
-			if (ret == -EPIPE || ret == -ECONNRESET)
-				kernel_sock_shutdown(queue->sock, SHUT_RDWR);
-			else
-				nvmet_tcp_fatal_error(queue);
+		else if (ret < 0)
 			return;
-		}
 
 	} while (pending && ops < NVMET_TCP_IO_WORK_BUDGET);
 
-- 
2.25.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites
  2020-05-17 11:15 [PATCH] nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites Sagi Grimberg
@ 2020-05-18 15:07 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2020-05-18 15:07 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: Chaitanya Kulkarni, Keith Busch, Christoph Hellwig, linux-nvme

On Sun, May 17, 2020 at 04:15:22AM -0700, Sagi Grimberg wrote:
> Have routines handle errors and just bail out of the poll loop. This simplifies
> the code and will help as we may enhance the poll loop logic and these are somewhat
> in the way.

Way too long lines in the commit message.

> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
> index f8dd69f3b657..9527cdc19611 100644
> --- a/drivers/nvme/target/tcp.c
> +++ b/drivers/nvme/target/tcp.c
> @@ -723,6 +723,13 @@ static int nvmet_tcp_try_send(struct nvmet_tcp_queue *queue,
>  		(*sends)++;
>  	}
>  
> +	if (ret < 0) {
> +		if (ret == -EPIPE || ret == -ECONNRESET)
> +			kernel_sock_shutdown(queue->sock, SHUT_RDWR);
> +		else
> +			nvmet_tcp_fatal_error(queue);
> +	}

Not really important, but how about a nvmet_tcp_handle_error helper
to consolidate this duplicated code snipplet?

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-18 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 11:15 [PATCH] nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites Sagi Grimberg
2020-05-18 15:07 ` Christoph Hellwig

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.