]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ext2: Avoid unnecessary inode buffer writeback for sync(2)
authorJan Kara <jack@suse.cz>
Mon, 27 Jul 2026 10:49:26 +0000 (12:49 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 27 Jul 2026 14:25:32 +0000 (16:25 +0200)
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 <jack@suse.cz>
Link: https://patch.msgid.link/20260727104923.3828017-28-jack@suse.cz
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/ext2/inode.c

index 4dbe52e42d827fec2bfe6b5671db398d5c710608..904e70f3140eaca551f52a1e31bb9b4f755b93ca 100644 (file)
@@ -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",