diff options
-rw-r--r-- | fs/ext4/inode.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5324a38d848d..ab3e8357929d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4455,7 +4455,12 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
4455 | return -EIO; | 4455 | return -EIO; |
4456 | } | 4456 | } |
4457 | 4457 | ||
4458 | if (wbc->sync_mode != WB_SYNC_ALL) | 4458 | /* |
4459 | * No need to force transaction in WB_SYNC_NONE mode. Also | ||
4460 | * ext4_sync_fs() will force the commit after everything is | ||
4461 | * written. | ||
4462 | */ | ||
4463 | if (wbc->sync_mode != WB_SYNC_ALL || wbc->for_sync) | ||
4459 | return 0; | 4464 | return 0; |
4460 | 4465 | ||
4461 | err = ext4_force_commit(inode->i_sb); | 4466 | err = ext4_force_commit(inode->i_sb); |
@@ -4465,7 +4470,11 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
4465 | err = __ext4_get_inode_loc(inode, &iloc, 0); | 4470 | err = __ext4_get_inode_loc(inode, &iloc, 0); |
4466 | if (err) | 4471 | if (err) |
4467 | return err; | 4472 | return err; |
4468 | if (wbc->sync_mode == WB_SYNC_ALL) | 4473 | /* |
4474 | * sync(2) will flush the whole buffer cache. No need to do | ||
4475 | * it here separately for each inode. | ||
4476 | */ | ||
4477 | if (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync) | ||
4469 | sync_dirty_buffer(iloc.bh); | 4478 | sync_dirty_buffer(iloc.bh); |
4470 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { | 4479 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { |
4471 | EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr, | 4480 | EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr, |