Skip to content

Commit 09ccf55

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent 781fc49 commit 09ccf55

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/block/loop.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
203203
if (lo->use_dio == use_dio)
204204
return;
205205

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);
208209

209210
/*
210211
* The flag of LO_FLAGS_DIRECT_IO is handled similarly with

0 commit comments

Comments
 (0)