diff options
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 90a30ce822fc..faf5bd056a93 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -4191,9 +4191,17 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) | |||
4191 | return; | 4191 | return; |
4192 | 4192 | ||
4193 | size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len; | 4193 | size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len; |
4194 | isize = i_size_read(ac->ac_inode) >> bsbits; | 4194 | isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1) |
4195 | >> bsbits; | ||
4195 | size = max(size, isize); | 4196 | size = max(size, isize); |
4196 | 4197 | ||
4198 | if ((size == isize) && | ||
4199 | !ext4_fs_is_busy(sbi) && | ||
4200 | (atomic_read(&ac->ac_inode->i_writecount) == 0)) { | ||
4201 | ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC; | ||
4202 | return; | ||
4203 | } | ||
4204 | |||
4197 | /* don't use group allocation for large files */ | 4205 | /* don't use group allocation for large files */ |
4198 | if (size >= sbi->s_mb_stream_request) { | 4206 | if (size >= sbi->s_mb_stream_request) { |
4199 | ac->ac_flags |= EXT4_MB_STREAM_ALLOC; | 4207 | ac->ac_flags |= EXT4_MB_STREAM_ALLOC; |