Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

loop: only write back pagecache when starting to to use direct I/O

There is no point in doing an fdatasync to write out pages when switching
away from direct I/O, as there won't be any. The writeback is only
needed when switching to direct I/O, which would have to invalidate the
pagecache less efficiently from the I/O path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250110073750.1582447-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
09ccf554 781fc49a

+3 -2
+3 -2
drivers/block/loop.c
··· 203 203 if (lo->use_dio == use_dio) 204 204 return; 205 205 206 - /* flush dirty pages before changing direct IO */ 207 - vfs_fsync(lo->lo_backing_file, 0); 206 + /* flush dirty pages before starting to use direct I/O */ 207 + if (use_dio) 208 + vfs_fsync(lo->lo_backing_file, 0); 208 209 209 210 /* 210 211 * The flag of LO_FLAGS_DIRECT_IO is handled similarly with