Commit b640b2c5 authored by Miao Xie's avatar Miao Xie Committed by Theodore Ts'o

ext4: cleanup ext4_expand_extra_isize_ea()

Clean up some goto statement, make ext4_expand_extra_isize_ea() clearer.
Signed-off-by: default avatarMiao Xie <miaoxie@huawei.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reviewed-by: default avatarWang Shilong <wshilong@ddn.com>
parent cf0a5e81
...@@ -2637,7 +2637,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, ...@@ -2637,7 +2637,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
struct ext4_inode *raw_inode, handle_t *handle) struct ext4_inode *raw_inode, handle_t *handle)
{ {
struct ext4_xattr_ibody_header *header; struct ext4_xattr_ibody_header *header;
struct buffer_head *bh = NULL; struct buffer_head *bh;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
static unsigned int mnt_count; static unsigned int mnt_count;
size_t min_offs; size_t min_offs;
...@@ -2651,7 +2651,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, ...@@ -2651,7 +2651,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
retry: retry:
isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize; isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize;
if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) if (EXT4_I(inode)->i_extra_isize >= new_extra_isize)
goto out; return 0;
header = IHDR(inode, raw_inode); header = IHDR(inode, raw_inode);
...@@ -2686,6 +2686,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, ...@@ -2686,6 +2686,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
EXT4_ERROR_INODE(inode, "bad block %llu", EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl); EXT4_I(inode)->i_file_acl);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
brelse(bh);
goto cleanup; goto cleanup;
} }
base = BHDR(bh); base = BHDR(bh);
...@@ -2693,11 +2694,11 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, ...@@ -2693,11 +2694,11 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
min_offs = end - base; min_offs = end - base;
bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base, bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base,
NULL); NULL);
brelse(bh);
if (bfree + ifree < isize_diff) { if (bfree + ifree < isize_diff) {
if (!tried_min_extra_isize && s_min_extra_isize) { if (!tried_min_extra_isize && s_min_extra_isize) {
tried_min_extra_isize++; tried_min_extra_isize++;
new_extra_isize = s_min_extra_isize; new_extra_isize = s_min_extra_isize;
brelse(bh);
goto retry; goto retry;
} }
error = -ENOSPC; error = -ENOSPC;
...@@ -2715,7 +2716,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, ...@@ -2715,7 +2716,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
s_min_extra_isize) { s_min_extra_isize) {
tried_min_extra_isize++; tried_min_extra_isize++;
new_extra_isize = s_min_extra_isize; new_extra_isize = s_min_extra_isize;
brelse(bh);
goto retry; goto retry;
} }
goto cleanup; goto cleanup;
...@@ -2727,13 +2727,9 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, ...@@ -2727,13 +2727,9 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize, EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
(void *)header, total_ino); (void *)header, total_ino);
EXT4_I(inode)->i_extra_isize = new_extra_isize; EXT4_I(inode)->i_extra_isize = new_extra_isize;
brelse(bh);
out:
return 0;
cleanup: cleanup:
brelse(bh); if (error && (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count))) {
if (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count)) {
ext4_warning(inode->i_sb, "Unable to expand inode %lu. Delete some EAs or run e2fsck.", ext4_warning(inode->i_sb, "Unable to expand inode %lu. Delete some EAs or run e2fsck.",
inode->i_ino); inode->i_ino);
mnt_count = le16_to_cpu(sbi->s_es->s_mnt_count); mnt_count = le16_to_cpu(sbi->s_es->s_mnt_count);
......
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