[SPDK] Re: Query regarding nvme_tcp_read_data() API.

Harris, James R <james.r.harris at intel.com> Wed, 24 Nov 2021 21:10:50 +0000
Newsgroups dev.linux.lists.spdk
Message-ID <[email protected]>
spdk_sock_readv() has same semantics as POSIX readv(). So the existing code is correct. If it returns 0, it means the connection was closed, not that it returned 0 bytes. 

Sent from my iPhone

> On Nov 24, 2021, at 2:06 PM, 松本周平 / MATSUMOTO,SHUUHEI <shuhei.matsumoto.xt(a)hitachi.com> wrote:
> 
> Hi Senthil,
> 
> Return value zero indicates the other peer closed the connection or requested zero byte read. It is not likely to request zero byte read. So this may not be fatal error but closing the connection is correct.
> 
> Others will correct me if I am wrong.
> So you may be better to wait for more replies :)
> 
> Thanks,
> Shuhei
> ________________________________
> From: Senthil Kumar Veluswamy <Senthil.Kumar.Veluswamy(a)wdc.com>
> Sent: Thursday, November 25, 2021 12:38:40 AM
> To: Storage Performance Development Kit <spdk(a)lists.01.org>
> Subject: [SPDK] Query regarding nvme_tcp_read_data() API.
> 
> Hi,
>   In the SPDKv20.07, I’ve query on the below code.
> 
> In this nvme_tcp_read_data(), if spdk_sock_recv() return “0” i.e. ret = 0, then it treats that condition as FATAL and the caller of  nvme_tcp_read_data() i.e. nvmf_tcp_sock_process(), disconnects the connection.
> So, would like to know why this condition is treated as FATAL condition and disconnect is issued [as readv() can return ZERO bytes]?
> 
> 
> static int
> 
> nvme_tcp_read_data(struct spdk_sock *sock, int bytes,
> 
>                   void *buf)
> 
> {
> 
>        int ret;
> 
> 
> 
>        ret = spdk_sock_recv(sock, buf, bytes);
> 
> 
> 
>        if (ret > 0) {
> 
>                return ret;
> 
>        }
> 
> 
> 
>        if (ret < 0) {
> 
>                if (errno == EAGAIN || errno == EWOULDBLOCK) {
> 
>                        return 0;
> 
>                }
> 
> 
> 
>                /* For connect reset issue, do not output error log */
> 
>                if (errno != ECONNRESET) {
> 
>                        SPDK_ERRLOG("spdk_sock_recv() failed, errno %d: %s\n",
> 
>                                    errno, spdk_strerror(errno));
> 
>                }
> 
>        }
> 
> 
> 
>        /* connection closed */
> 
>        return NVME_TCP_CONNECTION_FATAL;
> 
> }
> 
> Thanks,
> Senthil Kumar V.
> _______________________________________________
> SPDK mailing list -- spdk(a)lists.01.org
> To unsubscribe send an email to spdk-leave(a)lists.01.org
> _______________________________________________
> SPDK mailing list -- spdk(a)lists.01.org
> To unsubscribe send an email to spdk-leave(a)lists.01.org