linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stefan Bühler" <source@stbuehler.de>
To: Jens Axboe <axboe@kernel.dk>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: io_uring: O_NONBLOCK/IOCB_NOWAIT/RWF_NOWAIT mess
Date: Sun, 28 Apr 2019 17:54:58 +0200	[thread overview]
Message-ID: <a60b2461-1db0-32cf-6eb2-35f7751a04ec@stbuehler.de> (raw)
In-Reply-To: <37071226-375a-07a6-d3d3-21323145de71@kernel.dk>

Hi,

On 23.04.19 22:31, Jens Axboe wrote:
> On 4/23/19 1:06 PM, Stefan Bühler wrote:
>> 2. {read,write}_iter and FMODE_NOWAIT / IOCB_NOWAIT is broken at the vfs
>> layer: vfs_{read,write} should set IOCB_NOWAIT if O_NONBLOCK is set when
>> they call {read,write}_iter (i.e. init_sync_kiocb/iocb_flags needs to
>> convert the flag).
>>
>> And all {read,write}_iter should check IOCB_NOWAIT instead of O_NONBLOCK
>> (hi there pipe.c!), and set FMODE_NOWAIT if they support IOCB_NOWAIT.
>>
>> {read,write}_iter should only queue the IOCB though if is_sync_kiocb()
>> returns false (i.e. if ki_callback is set).
> 
> That's a trivial fix. I agree that it should be done.

Doesn't look trivial to me.

Various functions take rwf_t flags, e.g. do_readv, which is called with
0 from readv and with flags from userspace in preadv2.

Now is preadv2() supposed to be non-blocking if the file has O_NONBLOCK,
or only if RWF_NOWAIT was passed?

Other places seem (at least to me) explicitly mean "please block" if
they don't pass RWF_NOWAIT, e.g. ovl_read_iter from fs/overlayfs, which
uses ovl_iocb_to_rwf to convert iocb flags back to rwf.

Imho the clean way is to ignore O_NONBLOCK when there are rwf_t flags;
e.g. kiocb_set_rw_flags should unset IOCB_NOWAIT if RWF_NOWAIT was not set.

But then various functions (like readv) will need to create rwf_t
"default" flags from a file (similar to iocb_flags) instead of using 0.
And ovl_iocb_to_rwf should probably be used in more places as well.

There is also generic_file_splice_read, which should use
SPLICE_F_NONBLOCK to trigger IOCB_NOWAIT; again it is unclear whether
O_NONBLOCK should trigger IOCB_NOWAIT too (do_sendfile explicitly does
NOT with a "need to debate" comment).


I don't think I'm the right person to do this - I think it requires a
deeper understanding of all the code involved.

I do have patches for pipe.c and and socket.c to ignore O_NONBLOCK, use
IOCB_NOWAIT and set FMODE_NOAWAIT after the fs part is ready.

cheers,
Stefan

  parent reply	other threads:[~2019-04-28 15:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 19:06 io_uring: not good enough for release Stefan Bühler
2019-04-23 20:31 ` Jens Axboe
2019-04-23 22:07   ` Jens Axboe
2019-04-24 16:09     ` Jens Axboe
2019-04-27 16:05       ` io_uring: RWF_NOWAIT support Stefan Bühler
2019-04-27 18:34         ` [PATCH v1 1/1] [io_uring] fix handling SQEs requesting NOWAIT Stefan Bühler
2019-04-30 15:40           ` Jens Axboe
2019-04-27 15:50     ` io_uring: submission error handling Stefan Bühler
2019-04-30 16:02       ` Jens Axboe
2019-04-30 16:15         ` Jens Axboe
2019-04-30 18:15           ` Stefan Bühler
2019-04-30 18:42             ` Jens Axboe
2019-05-01 11:49               ` [PATCH v1 1/1] [io_uring] don't stall on submission errors Stefan Bühler
2019-05-01 12:43                 ` Jens Axboe
2019-04-27 21:07   ` io_uring: closing / release Stefan Bühler
2019-05-11 16:26     ` Stefan Bühler
2019-04-28 15:54   ` Stefan Bühler [this message]
2019-05-11 16:34     ` io_uring: O_NONBLOCK/IOCB_NOWAIT/RWF_NOWAIT mess Stefan Bühler
2019-05-11 16:57       ` [PATCH 1/5] fs: RWF flags override default IOCB flags from file flags Stefan Bühler
2019-05-11 16:57         ` [PATCH 2/5] tcp: handle SPLICE_F_NONBLOCK in tcp_splice_read Stefan Bühler
2019-05-11 16:57         ` [PATCH 3/5] pipe: use IOCB_NOWAIT instead of O_NONBLOCK Stefan Bühler
2019-05-11 16:57         ` [PATCH 4/5] socket: " Stefan Bühler
2019-05-11 16:57         ` [PATCH 5/5] io_uring: use FMODE_NOWAIT to detect files supporting IOCB_NOWAIT Stefan Bühler
2019-05-03  9:47   ` [PATCH 1/2] io_uring: restructure io_{read,write} control flow Stefan Bühler
2019-05-03  9:47     ` [PATCH 2/2] io_uring: punt to workers if file doesn't support async Stefan Bühler

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=a60b2461-1db0-32cf-6eb2-35f7751a04ec@stbuehler.de \
    --to=source@stbuehler.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).