nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites
Subsystems (2)
Sagi Grimberg
maintainerPATCH 1/1 nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites
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.
--- drivers/nvme/target/tcp.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/nvme/target/tcp.c +18 -15
@@ -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 );
Signature · 7 lines
2.25.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 3 lines · Sagi Grimberg
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.
Quoted 5 lines
drivers/nvme/target/tcp.c +0
-0
drivers/nvme/target/tcp.c static int nvmet_tcp_try_send(struct nvmet_tcp_queue *queue, · line 731
Quoted 9 lines
drivers/nvme/target/tcp.c +6
-0@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme