linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Async direct IO write vs buffered read race
@ 2017-06-22 15:57 Lukas Czerner
  2017-06-22 16:55 ` Jeff Moyer
  0 siblings, 1 reply; 8+ messages in thread
From: Lukas Czerner @ 2017-06-22 15:57 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: viro, esandeen

Hello,

I am dealing with a problem where in case that buffered read happens to
land between direct IO submission and completion page cache will contain
the stale data, while the new data will be on disk.

We are trying to avoid such problems by calling
invalidate_inode_pages2_range() before and after direct_IO() in
generic_file_direct_write() however that does not seem to be enough,
because nothing prevents buffered reads to come in afterwards populating
page cache.

Aside from the fact that mixing direct and buffered IO is not such a
good idea, we end up with page cache showing different content than
what's on disk even after aio dio completes which seems very strange
to me.

I can reproduce this on ext4 as well as xfs and kernel version going
back at least to v3.10 which leads me to believe that this might
actually be known behaviour ?

I was trying to avoid that by moving invalidate_inode_pages2_range() to
after the aio dio completion into dio_complete (or file system ->end_io
callback) but it has it's own problems - sometimes this appears to be
called from atomic context and I do not really see why...

Do you have any comments on this ? Is it actually expected behaviour ?

Thanks!
-Lukas

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-06-30 11:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22 15:57 Async direct IO write vs buffered read race Lukas Czerner
2017-06-22 16:55 ` Jeff Moyer
2017-06-23  7:59   ` Jan Kara
2017-06-23 10:16     ` Lukas Czerner
2017-06-26 15:11       ` Jeff Moyer
2017-06-28 16:57         ` Rik van Riel
2017-06-30 11:16           ` Lukas Czerner
2017-06-23 18:04     ` Eric Sandeen

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).