Commit 6d138ced authored by Eric Sandeen's avatar Eric Sandeen Committed by Theodore Ts'o

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: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent b72f78cb
...@@ -4310,8 +4310,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4310,8 +4310,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
repeat: repeat:
/* allocate space in core */ /* allocate space in core */
*errp = ext4_mb_regular_allocator(ac); *errp = ext4_mb_regular_allocator(ac);
if (*errp) if (*errp) {
ext4_discard_allocated_blocks(ac);
goto errout; goto errout;
}
/* as we've just preallocated more space than /* as we've just preallocated more space than
* user requested orinally, we store allocated * user requested orinally, we store allocated
...@@ -4333,10 +4335,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4333,10 +4335,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
ac->ac_b_ex.fe_len = 0; ac->ac_b_ex.fe_len = 0;
ac->ac_status = AC_STATUS_CONTINUE; ac->ac_status = AC_STATUS_CONTINUE;
goto repeat; goto repeat;
} else if (*errp) } else if (*errp) {
errout:
ext4_discard_allocated_blocks(ac); ext4_discard_allocated_blocks(ac);
else { goto errout;
} else {
block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex);
ar->len = ac->ac_b_ex.fe_len; ar->len = ac->ac_b_ex.fe_len;
} }
...@@ -4347,6 +4349,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4347,6 +4349,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
*errp = -ENOSPC; *errp = -ENOSPC;
} }
errout:
if (*errp) { if (*errp) {
ac->ac_b_ex.fe_len = 0; ac->ac_b_ex.fe_len = 0;
ar->len = 0; ar->len = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment