Skip to contentSkip to conversation

__io_file_supports_nowait for regular files

DISCUSSION Christoph Hellwig 2 participants 5 messages Jul 21, 2022 – Jul 22, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

Hi Jens,

is there any good reason __io_file_supports_nowait checks the blk_queue_nowait flag for regular files? The FMODE_NOWAIT is set for regular files that support nowait I/O, and should be all that is needed. Even with a block device that does not nonblocking I/O some thing like reading from the page cache can be done non-blocking.

maintainer
#1 lore raw
Quoted 8 lines · Christoph Hellwig

Hi Jens,

is there any good reason __io_file_supports_nowait checks the blk_queue_nowait flag for regular files? The FMODE_NOWAIT is set for regular files that support nowait I/O, and should be all that is needed. Even with a block device that does not nonblocking I/O some thing like reading from the page cache can be done non-blocking.

Nope, we can probably kill that check then. Want to send a patch?

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 11 lines · Jens Axboe
Quoted 8 lines · Christoph Hellwig

Hi Jens,

is there any good reason __io_file_supports_nowait checks the blk_queue_nowait flag for regular files? The FMODE_NOWAIT is set for regular files that support nowait I/O, and should be all that is needed. Even with a block device that does not nonblocking I/O some thing like reading from the page cache can be done non-blocking.

Nope, we can probably kill that check then. Want to send a patch?

What would be a good way to verify it doesn't break any strange assumptions? I kinda don't fell too comfortable touching io_uring guts.

Quoted 3 lines
Signature · 2 lines
-- 
Jens Axboe

---end quoted text---

maintainer
#3 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Jens Axboe
Quoted 8 lines · Christoph Hellwig

Hi Jens,

is there any good reason __io_file_supports_nowait checks the blk_queue_nowait flag for regular files? The FMODE_NOWAIT is set for regular files that support nowait I/O, and should be all that is needed. Even with a block device that does not nonblocking I/O some thing like reading from the page cache can be done non-blocking.

Quoted 5 lines
Quoted 1 line

Nope, we can probably kill that check then. Want to send a patch?

What would be a good way to verify it doesn't break any strange assumptions? I kinda don't fell too comfortable touching io_uring guts.

Looking a bit deeper at this, FMODE_NOWAIT is about the file. The nowait check for the bdev is about whether the driver honors NOWAIT submissions. Any blk-mq driver will be fine, bio based ones probably not. You could very well end up blocking off the submit path in that case.

I'm not convinced we don't still need that check.

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 1 line · Jens Axboe

Looking a bit deeper at this, FMODE_NOWAIT is about the file.

Yes.

Quoted 5 lines

The nowait
check for the bdev is about whether the driver honors NOWAIT submissions. Any blk-mq driver will be fine, bio based ones probably not. You could very well end up blocking off the submit path in that case.

But do these submissions even matter for the high level interface? We'd get -EAGAIN way more often without them (or all the time for direct I/O), but does that strictly matter for the interface?

Note that for mny file systems (at least btrfs, f2fs and xfs) just checking s_bdev is not enough any way as they can use multiple block devices.

I'm also a little confused now that I'm looking more into this, as iomap only uses REQ_NOWAIT for polled direct I/O to start with. The legacy direct I/O code uses it for all writes as long as IOCB_NOWAIT is set, so it seems like only the block device code really makes extensive and most likely correct use of the REQ_NOWAIT flag anyway.