From: Miao Xie <miaoxie@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <miaoxie@huawei.com>, <tytso@mit.edu>, <lixi@ddn.com>,
<yi.zhang@huawei.com>, <adilger@dilger.ca>, <wshilong@ddn.com>,
<sihara@ddn.com>
Subject: [PATCH 3/4] ext4: cleanup ext4_expand_extra_isize_ea()
Date: Fri, 7 Jul 2017 01:09:52 +0800 [thread overview]
Message-ID: <1499360993-17130-3-git-send-email-miaoxie@huawei.com> (raw)
In-Reply-To: <1499360993-17130-1-git-send-email-miaoxie@huawei.com>
Clean up some goto statement, make ext4_expand_extra_isize_ea() clearer.
Signed-off-by: Miao Xie <miaoxie@huawei.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
---
fs/ext4/xattr.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 3c6c225..73fbe4a 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1464,7 +1464,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
struct ext4_inode *raw_inode, handle_t *handle)
{
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);
static unsigned int mnt_count;
size_t min_offs;
@@ -1478,7 +1478,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
retry:
isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize;
if (EXT4_I(inode)->i_extra_isize >= new_extra_isize)
- goto out;
+ return 0;
header = IHDR(inode, raw_inode);
@@ -1513,6 +1513,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
error = -EFSCORRUPTED;
+ brelse(bh);
goto cleanup;
}
base = BHDR(bh);
@@ -1520,11 +1521,11 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
min_offs = end - base;
bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base,
NULL);
+ brelse(bh);
if (bfree + ifree < isize_diff) {
if (!tried_min_extra_isize && s_min_extra_isize) {
tried_min_extra_isize++;
new_extra_isize = s_min_extra_isize;
- brelse(bh);
goto retry;
}
error = -ENOSPC;
@@ -1542,7 +1543,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
s_min_extra_isize) {
tried_min_extra_isize++;
new_extra_isize = s_min_extra_isize;
- brelse(bh);
goto retry;
}
goto cleanup;
@@ -1554,14 +1554,9 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
(void *)header, total_ino);
EXT4_I(inode)->i_extra_isize = new_extra_isize;
- brelse(bh);
-out:
- return 0;
cleanup:
- brelse(bh);
next prev parent reply other threads:[~2017-07-06 8:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 17:09 [PATCH 1/4] ext4: fix forgetten xattr lock protection in ext4_expand_extra_isize Miao Xie
2017-07-06 17:09 ` [PATCH 2/4] ext4: restructure ext4_expand_extra_isize Miao Xie
2017-08-06 4:47 ` Theodore Ts'o
2017-07-06 17:09 ` Miao Xie [this message]
2017-08-06 4:56 ` [PATCH 3/4] ext4: cleanup ext4_expand_extra_isize_ea() Theodore Ts'o
2017-07-06 17:09 ` [PATCH 4/4] ext4, project: expand inode extra size if possible Miao Xie
2017-08-06 5:05 ` Theodore Ts'o
2017-07-13 12:55 ` [PATCH 1/4] ext4: fix forgetten xattr lock protection in ext4_expand_extra_isize Miao Xie
2017-07-13 13:04 ` Wang Shilong
2017-07-13 16:47 ` Theodore Ts'o
2017-08-06 4:28 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499360993-17130-3-git-send-email-miaoxie@huawei.com \
--to=miaoxie@huawei.com \
--cc=adilger@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=lixi@ddn.com \
--cc=sihara@ddn.com \
--cc=tytso@mit.edu \
--cc=wshilong@ddn.com \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox