diff options
-rw-r--r-- | fs/ext4/inode.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 118e16ca91d7..22fb1a3a045c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4991,8 +4991,7 @@ static int ext4_inode_blocks_set(handle_t *handle, | |||
4991 | */ | 4991 | */ |
4992 | static int ext4_do_update_inode(handle_t *handle, | 4992 | static int ext4_do_update_inode(handle_t *handle, |
4993 | struct inode *inode, | 4993 | struct inode *inode, |
4994 | struct ext4_iloc *iloc, | 4994 | struct ext4_iloc *iloc) |
4995 | int do_sync) | ||
4996 | { | 4995 | { |
4997 | struct ext4_inode *raw_inode = ext4_raw_inode(iloc); | 4996 | struct ext4_inode *raw_inode = ext4_raw_inode(iloc); |
4998 | struct ext4_inode_info *ei = EXT4_I(inode); | 4997 | struct ext4_inode_info *ei = EXT4_I(inode); |
@@ -5093,22 +5092,10 @@ static int ext4_do_update_inode(handle_t *handle, | |||
5093 | raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize); | 5092 | raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize); |
5094 | } | 5093 | } |
5095 | 5094 | ||
5096 | /* | 5095 | BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); |
5097 | * If we're not using a journal and we were called from | 5096 | rc = ext4_handle_dirty_metadata(handle, inode, bh); |
5098 | * ext4_write_inode() to sync the inode (making do_sync true), | 5097 | if (!err) |
5099 | * we can just use sync_dirty_buffer() directly to do our dirty | 5098 | err = rc; |
5100 | * work. Testing s_journal here is a bit redundant but it's | ||
5101 | * worth it to avoid potential future trouble. | ||
5102 | */ | ||
5103 | if (EXT4_SB(inode->i_sb)->s_journal == NULL && do_sync) { | ||
5104 | BUFFER_TRACE(bh, "call sync_dirty_buffer"); | ||
5105 | sync_dirty_buffer(bh); | ||
5106 | } else { | ||
5107 | BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); | ||
5108 | rc = ext4_handle_dirty_metadata(handle, inode, bh); | ||
5109 | if (!err) | ||
5110 | err = rc; | ||
5111 | } | ||
5112 | ei->i_state &= ~EXT4_STATE_NEW; | 5099 | ei->i_state &= ~EXT4_STATE_NEW; |
5113 | 5100 | ||
5114 | out_brelse: | 5101 | out_brelse: |
@@ -5176,8 +5163,16 @@ int ext4_write_inode(struct inode *inode, int wait) | |||
5176 | err = ext4_get_inode_loc(inode, &iloc); | 5163 | err = ext4_get_inode_loc(inode, &iloc); |
5177 | if (err) | 5164 | if (err) |
5178 | return err; | 5165 | return err; |
5179 | err = ext4_do_update_inode(EXT4_NOJOURNAL_HANDLE, | 5166 | if (wait) |
5180 | inode, &iloc, wait); | 5167 | sync_dirty_buffer(iloc.bh); |
5168 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { | ||
5169 | ext4_error(inode->i_sb, __func__, | ||
5170 | "IO error syncing inode, " | ||
5171 | "inode=%lu, block=%llu", | ||
5172 | inode->i_ino, | ||
5173 | (unsigned long long)iloc.bh->b_blocknr); | ||
5174 | err = -EIO; | ||
5175 | } | ||
5181 | } | 5176 | } |
5182 | return err; | 5177 | return err; |
5183 | } | 5178 | } |
@@ -5473,7 +5468,7 @@ int ext4_mark_iloc_dirty(handle_t *handle, | |||
5473 | get_bh(iloc->bh); | 5468 | get_bh(iloc->bh); |
5474 | 5469 | ||
5475 | /* ext4_do_update_inode() does jbd2_journal_dirty_metadata */ | 5470 | /* ext4_do_update_inode() does jbd2_journal_dirty_metadata */ |
5476 | err = ext4_do_update_inode(handle, inode, iloc, 0); | 5471 | err = ext4_do_update_inode(handle, inode, iloc); |
5477 | put_bh(iloc->bh); | 5472 | put_bh(iloc->bh); |
5478 | return err; | 5473 | return err; |
5479 | } | 5474 | } |