[PATCH v5 08/20] ext2: Avoid unnecessary inode buffer writeback for sync(2)
Jan Kara <[email protected]> Mon, 27 Jul 2026 12:49:26 +0200
| Newsgroups | org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <[email protected]> |
For sync(2) the generic code calls sync_blockdev_nowait() and later sync_blockdev() to persist all metadata buffers. Thus there's no need for ext2_write_inode() to do that which speeds up sync(2) writeback. Signed-off-by: Jan Kara <[email protected]> --- fs/ext2/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 4dbe52e42d82..904e70f3140e 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1560,7 +1560,11 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc) } else for (n = 0; n < EXT2_N_BLOCKS; n++) raw_inode->i_block[n] = ei->i_data[n]; mark_buffer_dirty(bh); - if (wbc->sync_mode == WB_SYNC_ALL) { + /* + * For sync(2) the generic code will call sync_blockdev() to write + * all metadata more efficiently. + */ + if (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync) { sync_dirty_buffer(bh); if (buffer_req(bh) && !buffer_uptodate(bh)) { printk ("IO error syncing ext2 inode [%s:%08lx]\n", -- 2.51.0