Skip to content

Commit 6d138ce

Browse files
Eric Sandeentytso
authored andcommitted
ext4: fix awful goto in ext4_mb_new_blocks()
I think the whole function could be made prettier, but that goto really took the cake for too-clever-by-half. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent b72f78c commit 6d138ce

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎fs/ext4/mballoc.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4310,8 +4310,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
43104310
repeat:
43114311
/* allocate space in core */
43124312
*errp = ext4_mb_regular_allocator(ac);
4313-
if (*errp)
4313+
if (*errp) {
4314+
ext4_discard_allocated_blocks(ac);
43144315
goto errout;
4316+
}
43154317

43164318
/* as we've just preallocated more space than
43174319
* user requested orinally, we store allocated
@@ -4333,10 +4335,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
43334335
ac->ac_b_ex.fe_len = 0;
43344336
ac->ac_status = AC_STATUS_CONTINUE;
43354337
goto repeat;
4336-
} else if (*errp)
4337-
errout:
4338+
} else if (*errp) {
43384339
ext4_discard_allocated_blocks(ac);
4339-
else {
4340+
goto errout;
4341+
} else {
43404342
block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex);
43414343
ar->len = ac->ac_b_ex.fe_len;
43424344
}
@@ -4347,6 +4349,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
43474349
*errp = -ENOSPC;
43484350
}
43494351

4352+
errout:
43504353
if (*errp) {
43514354
ac->ac_b_ex.fe_len = 0;
43524355
ar->len = 0;

0 commit comments

Comments
 (0)