[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230228114306.3328235-8-shikemeng@huaweicloud.com>
Date: Tue, 28 Feb 2023 19:42:53 +0800
From: Kemeng Shi <shikemeng@...weicloud.com>
To: tytso@....edu, adilger.kernel@...ger.ca, jack@...e.cz,
ojaswin@...ux.ibm.com, ritesh.list@...il.com
Cc: linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
shikemeng@...weicloud.com
Subject: [PATCH v2 07/20] ext4: add missed brelse in ext4_free_blocks_simple
Release bitmap buffer_head we got if error occurs.
Besides, this patch remove unused assignment to err.
Signed-off-by: Kemeng Shi <shikemeng@...weicloud.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
---
fs/ext4/mballoc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index aec4a7b7af20..c26421170406 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -5845,13 +5845,12 @@ static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
ext4_get_group_no_and_offset(sb, block, &group, &blkoff);
bitmap_bh = ext4_read_block_bitmap(sb, group);
if (IS_ERR(bitmap_bh)) {
- err = PTR_ERR(bitmap_bh);
pr_warn("Failed to read block bitmap\n");
return;
}
gdp = ext4_get_group_desc(sb, group, &gdp_bh);
if (!gdp)
- return;
+ goto err_out;
for (i = 0; i < count; i++) {
if (!mb_test_bit(blkoff + i, bitmap_bh->b_data))
@@ -5860,7 +5859,7 @@ static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
mb_clear_bits(bitmap_bh->b_data, blkoff, count);
err = ext4_handle_dirty_metadata(NULL, NULL, bitmap_bh);
if (err)
- return;
+ goto err_out;
ext4_free_group_clusters_set(
sb, gdp, ext4_free_group_clusters(sb, gdp) +
count - already_freed);
@@ -5869,6 +5868,8 @@ static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
ext4_handle_dirty_metadata(NULL, NULL, gdp_bh);
sync_dirty_buffer(bitmap_bh);
sync_dirty_buffer(gdp_bh);
+
+err_out:
brelse(bitmap_bh);
}
--
2.30.0
Powered by blists - more mailing lists