Hi Senthil,
readv() only updates errno if it returns -1. It is not valid to look at errno when
readv() returns 0.
The read manpage describes this case, and readv manpage says that readv system call works
just like read except that multiple buffers are filled.
-Jim
On 12/14/21, 1:07 AM, "Senthil Kumar Veluswamy"
<Senthil.Kumar.Veluswamy(a)wdc.com> wrote:
Hi Shuhei, James,
I've one more question.
Point #1 :-
As per man page of readv,
RETURN VALUE
On success, readv() and preadv() return the number of bytes read; writev() and
pwritev() return the number of bytes written. On error, -1 is returned, and errno is set
appropriately.
Point #2 :-
In one of our heavy I/O testing with fio, the spdk_sock_recv() returned with "ret
= 0" and "errno = 11 i.e. EAGAIN, Resource temporarily unavailable issue".
Please note ret is ZERO.
Point #3 :-
From the code, I see that, when sock_recv() is returned with "ret = -1"
& "errno =11, EAGAIN”, it is not disconnecting the socket but when it is returned
with “ret = 0” & “errno = 11, EAGAIN”, it disconnects.
Point #4 :-
Also, as per man pages of readv, it didn’t say that “ret = 0” should be treated as
connection was closed.
Questions:-
* Based on the above findings, is it fine to treat “ret = 0” as connection closed
condition? I’m bit confused here.
* The error EAGAIN is treated differently based on “ret = 0” (or) “ret = -1” as
described above. Is this fine? Do ret value takes precedence over errno?
Thanks,
Senthil Kumar V.
On 25/11/21, 2:41 AM, "Harris, James R" <james.r.harris(a)intel.com>
wrote:
CAUTION: This email originated from outside of Western Digital. Do not click on
links or open attachments unless you recognize the sender and know that the content is
safe.
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
_______________________________________________
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