diff options
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 0e9466f9e767..956027711faf 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -3217,8 +3217,27 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac) | |||
3217 | static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac) | 3217 | static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac) |
3218 | { | 3218 | { |
3219 | struct ext4_prealloc_space *pa = ac->ac_pa; | 3219 | struct ext4_prealloc_space *pa = ac->ac_pa; |
3220 | struct ext4_buddy e4b; | ||
3221 | int err; | ||
3220 | 3222 | ||
3221 | if (pa && pa->pa_type == MB_INODE_PA) | 3223 | if (pa == NULL) { |
3224 | err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b); | ||
3225 | if (err) { | ||
3226 | /* | ||
3227 | * This should never happen since we pin the | ||
3228 | * pages in the ext4_allocation_context so | ||
3229 | * ext4_mb_load_buddy() should never fail. | ||
3230 | */ | ||
3231 | WARN(1, "mb_load_buddy failed (%d)", err); | ||
3232 | return; | ||
3233 | } | ||
3234 | ext4_lock_group(ac->ac_sb, ac->ac_f_ex.fe_group); | ||
3235 | mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start, | ||
3236 | ac->ac_f_ex.fe_len); | ||
3237 | ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group); | ||
3238 | return; | ||
3239 | } | ||
3240 | if (pa->pa_type == MB_INODE_PA) | ||
3222 | pa->pa_free += ac->ac_b_ex.fe_len; | 3241 | pa->pa_free += ac->ac_b_ex.fe_len; |
3223 | } | 3242 | } |
3224 | 3243 | ||