From: Jan Kara Date: Mon, 27 Jul 2026 10:49:26 +0000 (+0200) Subject: ext2: Avoid unnecessary inode buffer writeback for sync(2) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74d4faaa76b829dc439be61f10d48b8e905e39a1;p=thirdparty%2Fkernel%2Flinux.git ext2: Avoid unnecessary inode buffer writeback for sync(2) 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 Link: https://patch.msgid.link/20260727104923.3828017-28-jack@suse.cz Signed-off-by: Christian Brauner (Amutable) --- 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",