aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorCurt Wohlgemuth <curtw@google.com>2009-12-08 22:18:25 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-12-08 22:18:25 -0500
commitb844167edc7fcafda9623955c05e4c1b3c32ebc7 (patch)
tree60b204901afb6393ace94bd5c8d39246d0a87383 /fs/ext4/mballoc.c
parentd4edac314e9ad0b21ba20ba8bc61b61f186f79e1 (diff)
ext4: remove blocks from inode prealloc list on failure
This fixes a leak of blocks in an inode prealloc list if device failures cause ext4_mb_mark_diskspace_used() to fail. Signed-off-by: Curt Wohlgemuth <curtw@google.com> Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c19
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 */
3019static 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 */
3016static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac, 3034static 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);