Skip to content

Commit b640b2c

Browse files
miaoxietytso
authored andcommitted
ext4: cleanup ext4_expand_extra_isize_ea()
Clean up some goto statement, make ext4_expand_extra_isize_ea() clearer. Signed-off-by: Miao Xie <miaoxie@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Wang Shilong <wshilong@ddn.com>
1 parent cf0a5e8 commit b640b2c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

fs/ext4/xattr.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,7 +2637,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
26372637
struct ext4_inode *raw_inode, handle_t *handle)
26382638
{
26392639
struct ext4_xattr_ibody_header *header;
2640-
struct buffer_head *bh = NULL;
2640+
struct buffer_head *bh;
26412641
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
26422642
static unsigned int mnt_count;
26432643
size_t min_offs;
@@ -2651,7 +2651,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
26512651
retry:
26522652
isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize;
26532653
if (EXT4_I(inode)->i_extra_isize >= new_extra_isize)
2654-
goto out;
2654+
return 0;
26552655

26562656
header = IHDR(inode, raw_inode);
26572657

@@ -2686,18 +2686,19 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
26862686
EXT4_ERROR_INODE(inode, "bad block %llu",
26872687
EXT4_I(inode)->i_file_acl);
26882688
error = -EFSCORRUPTED;
2689+
brelse(bh);
26892690
goto cleanup;
26902691
}
26912692
base = BHDR(bh);
26922693
end = bh->b_data + bh->b_size;
26932694
min_offs = end - base;
26942695
bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base,
26952696
NULL);
2697+
brelse(bh);
26962698
if (bfree + ifree < isize_diff) {
26972699
if (!tried_min_extra_isize && s_min_extra_isize) {
26982700
tried_min_extra_isize++;
26992701
new_extra_isize = s_min_extra_isize;
2700-
brelse(bh);
27012702
goto retry;
27022703
}
27032704
error = -ENOSPC;
@@ -2715,7 +2716,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
27152716
s_min_extra_isize) {
27162717
tried_min_extra_isize++;
27172718
new_extra_isize = s_min_extra_isize;
2718-
brelse(bh);
27192719
goto retry;
27202720
}
27212721
goto cleanup;
@@ -2727,13 +2727,9 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
27272727
EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
27282728
(void *)header, total_ino);
27292729
EXT4_I(inode)->i_extra_isize = new_extra_isize;
2730-
brelse(bh);
2731-
out:
2732-
return 0;
27332730

27342731
cleanup:
2735-
brelse(bh);
2736-
if (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count)) {
2732+
if (error && (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count))) {
27372733
ext4_warning(inode->i_sb, "Unable to expand inode %lu. Delete some EAs or run e2fsck.",
27382734
inode->i_ino);
27392735
mnt_count = le16_to_cpu(sbi->s_es->s_mnt_count);

0 commit comments

Comments
 (0)