public inbox for [email protected]
 help / color / mirror / Atom feed
From: Xiaoguang Wang <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, Christoph Hellwig <[email protected]>,
	Pavel Begunkov <[email protected]>,
	[email protected]
Subject: RWF_NOWAIT does not work on socket
Date: Fri, 27 May 2022 11:49:01 +0800	[thread overview]
Message-ID: <[email protected]> (raw)

hi,

Now we're using io_uring's multi-shot feature,  multi-shot is similar
to epoll's edge-triggered mode, that means once one pure poll
request returns one event(cqe), we'll need to read or write continually
until EAGAIN is returned, which needs to set file to be non-blocking.

But since commit "io_uring: allow retry for O_NONBLOCK if async is
supported", seems that the non-blocking behavior has been changed.
In io_prep_rw:
+       /*
+        * If the file is marked O_NONBLOCK, still allow retry for it if it
+        * supports async. Otherwise it's impossible to use O_NONBLOCK files
+        * reliably. If not, or it IOCB_NOWAIT is set, don't retry.
+        */
+       if ((kiocb->ki_flags & IOCB_NOWAIT) ||
+           ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req, rw)))
                req->flags |= REQ_F_NOWAIT;

Then I tried to use RWF_NOWAIT, seems that it also does not work. In
kiocb_set_rw_flags():
    if (flags & RWF_NOWAIT) {
                if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
                        return -EOPNOTSUPP;
                kiocb_flags |= IOCB_NOIO;
        }

Seems that socket file doesn't have FMODE_NOWAIT set, so user apps
will get EOPNOTSUPP when using RWF_NOWAIT on socket. Also in
above codes, seems IOCB_NOWAIT isn't flagged too.

Any special reasons about above codes? Thanks.

Regards,
Xiaoguang Wang

                 reply	other threads:[~2022-05-27  3:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03e4e3aa-7f5f-4051-a06b-62e9f5a082f3@linux.alibaba.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox