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 --- 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 dc7003e21b12..48862e73610c 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1563,7 +1563,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