On Thu, Aug 12, 2021 at 02:16:03PM +0100, Christoph Hellwig wrote: > On Wed, Aug 11, 2021 at 03:46:47AM +0100, Matthew Wilcox (Oracle) wrote: > > For O_SYNC writes, if the filesystem has already allocated blocks for > > the range, we can avoid marking the page as dirty and skip straight to > > marking the page as writeback. > > So this just optimizes O_SYNC overwrites. How common are those for > bufered I/O? I know databases use them a lot with direct I/O, but for > buffere I/O this seems like an odd I/O pattern. As the comment says: + /* Can't allocate blocks here because we don't have ->prepare_ioend */ Give me a way to allocate blocks and it can do better! I didn't realise this was going to be a problem when I embarked on this, but attempting to do IO to wild addresses made me realise that most appending O_SYNC writes are IOMAP_DELALLOC and so don't have allocated blocks. And it's not just overwrites. If you open(O_SYNC|O_TRUNC) and then write ten bytes at a time, the first write to each block will cause us to fall back to writeback pages, but subsequent writes to a block will writethrough.