Attention is currently required from: daniel, fixeria, jolly, laforge, osmith, pespin.

pespin uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Code-Review+1 by laforge, Verified-1 by Jenkins Builder

io_uring: RECVMSG_SENDMSG: Reset fd to blocking after osmo_fd_register() workaround

When IOFD_FLAG_NOTIFY_CONNECTED is requested by the user through
osmo_iofd_notify_connected(), a write_cb(0, NULL) callback is done
towards the user to notify the socket is connected.

In mode RECVMSG_SENDMSG, at least for SCTP sockets, according to comment
in iofd_uring_register() (see also OS#5751) we cannot do the write(0)
trick to get notifications, so instead we need to workaround by using a
temporary osmo_fd to poll() for write status.
To do so, we call osmo_fd_register(), which internally sets the fd as
non-blocking (O_NONBLOCK). However, this is becomes an undesired
behavior later on when connect happens and io_uring is used to
recvmsg/sendmsg, since that could cause sqes to be answered with -EAGAIN
cqes at the kernel isntead of keeping (blocking) them internally until
the transaction can be resolved. This seems was a "desired" or
"expected" behavior in older kernels according to public
discussions/tickets, but it seeems it changed over time (see eg. GH#364
below).

In summary, the conclusion seems to be: try to avoid as much as possible mixing
O_NONBLOCK with io_uring, as you may get totally unexpected/changing
behavior.

Hence, avoid keeping O_NONBLOCK for those sockets when moving back from
osmo_fd to io_uring.

See regarding related discussion on the expected behavior with io_uring and O_NONBLOCK:
https://www.spinics.net/lists/io-uring/msg04058.html
https://github.com/axboe/liburing/issues/364

Change-Id: Idba623730230bc049b827e51b058cd64d23b730f
---
M src/core/osmo_io_uring.c
1 file changed, 22 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/71/41671/2

To view, visit change 41671. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idba623730230bc049b827e51b058cd64d23b730f
Gerrit-Change-Number: 41671
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: jolly <andreas@eversberg.eu>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Attention: osmith <osmith@sysmocom.de>
Gerrit-Attention: jolly <andreas@eversberg.eu>
Gerrit-Attention: laforge <laforge@osmocom.org>
Gerrit-Attention: pespin <pespin@sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Attention: daniel <dwillmann@sysmocom.de>