axboe / fio

Flexible I/O Tester
GNU General Public License v2.0
5.27k stars 1.26k forks source link

Would any FIO configuration ever issue reads to a block number when a write is outstanding for the same? #1149

Closed user8555 closed 3 years ago

user8555 commented 3 years ago

If yes, would the linux kernel block automatically correctly order the read after the write to maintain the expected ordering?

axboe commented 3 years ago

There's no "would the kernel correctly order " - the kernel just does what it's told. For fio, the answer is possibly yes, if the job file is written as such that you could have reads and writes for the same block.

user8555 commented 3 years ago

There's no "would the kernel correctly order " - the kernel just does what it's told

  1. Isn't it true that the kernel block layer's I/O scheduler might do re-ordering, merging of requests before issuing them to disk? http://byteliu.com/2019/05/10/Linux-The-block-I-O-layer/
  2. Is the I/O scheduler involved in re-ordering merging etc. if O_DIRECT and O_SYNC is set?
  3. If a single io_uring call has 2 SQE entries before they were submitted -- entry 1 is a write, entry 2 is a read. Both are same block offsets. Is it possible for the disk to receive request in the reverse order -- i.e. read then the write?
axboe commented 3 years ago

The kernel may indeed reorder, it's totally free to do so. The flawed concept here is that there's such a thing as right or wrong ordering, the kernel doesn't make any judgement on that. So yes, it's possible that you submit entry1 and entry2, and the kernel ends up issuing entry2 first. Or you can get entry1 issued first, then entry2, but entry2 will complete first.

sitsofe commented 3 years ago

@ajgopala :

To answer the question in the title

Would any FIO configuration ever issue reads to a block number when a write is outstanding for the same?

Yes I can construct a configuration that does. However can you reply if the serialize_overlap option mentioned in the documentation addresses your issue?

user8555 commented 3 years ago

I think so @sitsofe

There it says ...

When two or more I/Os are submitted simultaneously

Does it mean 2 io_submit calls or does it even include 1 io_submit call have 2 entries in it?

sitsofe commented 3 years ago

@ajgopala that question is looking a bit too narrowly at the problem... serialize_overlap works irrespective of ioengine since operates at a higher level than syscalls. You can read 997b5680d139ce82c2034ba3a0d602cfd778b89b to see how it was initially implemented.

If this answers your question can you close this issue? Thanks!

user8555 commented 3 years ago

Makes sense. Thanks.