diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/mballoc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index ab2dad1dfb7e..19635c341994 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -3011,6 +3011,24 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac) | |||
3011 | } | 3011 | } |
3012 | 3012 | ||
3013 | /* | 3013 | /* |
3014 | * Called on failure; free up any blocks from the inode PA for this | ||
3015 | * context. We don't need this for MB_GROUP_PA because we only change | ||
3016 | * pa_free in ext4_mb_release_context(), but on failure, we've already | ||
3017 | * zeroed out ac->ac_b_ex.fe_len, so group_pa->pa_free is not changed. | ||
3018 | */ | ||
3019 | static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac) | ||
3020 | { | ||
3021 | struct ext4_prealloc_space *pa = ac->ac_pa; | ||
3022 | int len; | ||
3023 | |||
3024 | if (pa && pa->pa_type == MB_INODE_PA) { | ||
3025 | len = ac->ac_b_ex.fe_len; | ||
3026 | pa->pa_free += len; | ||
3027 | } | ||
3028 | |||
3029 | } | ||
3030 | |||
3031 | /* | ||
3014 | * use blocks preallocated to inode | 3032 | * use blocks preallocated to inode |
3015 | */ | 3033 | */ |
3016 | static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac, | 3034 | static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac, |
@@ -4295,6 +4313,7 @@ repeat: | |||
4295 | ac->ac_status = AC_STATUS_CONTINUE; | 4313 | ac->ac_status = AC_STATUS_CONTINUE; |
4296 | goto repeat; | 4314 | goto repeat; |
4297 | } else if (*errp) { | 4315 | } else if (*errp) { |
4316 | ext4_discard_allocated_blocks(ac); | ||
4298 | ac->ac_b_ex.fe_len = 0; | 4317 | ac->ac_b_ex.fe_len = 0; |
4299 | ar->len = 0; | 4318 | ar->len = 0; |
4300 | ext4_mb_show_ac(ac); | 4319 | ext4_mb_show_ac(ac); |