[PATCH v2 2/5] ext4: No need to check return value of block_commit_write()

Bean Huo posted 5 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH v2 2/5] ext4: No need to check return value of block_commit_write()
Posted by Bean Huo 2 years, 7 months ago
From: Bean Huo <beanhuo@micron.com>

Remove unnecessary check on the return value of block_commit_write(),
because it always returns 0.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/move_extent.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index b5af2fc03b2f..f4b4861a74ee 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -392,14 +392,11 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
 	for (i = 0; i < block_len_in_page; i++) {
 		*err = ext4_get_block(orig_inode, orig_blk_offset + i, bh, 0);
 		if (*err < 0)
-			break;
+			goto repair_branches;
 		bh = bh->b_this_page;
 	}
-	if (!*err)
-		*err = block_commit_write(&folio[0]->page, from, from + replaced_size);
 
-	if (unlikely(*err < 0))
-		goto repair_branches;
+	block_commit_write(&folio[0]->page, from, from + replaced_size);
 
 	/* Even in case of data=writeback it is reasonable to pin
 	 * inode to transaction, to prevent unexpected data loss */
-- 
2.34.1
Re: [PATCH v2 2/5] ext4: No need to check return value of block_commit_write()
Posted by Christoph Hellwig 2 years, 7 months ago
On Mon, Jun 19, 2023 at 11:18:24PM +0200, Bean Huo wrote:
> From: Bean Huo <beanhuo@micron.com>
> 
> Remove unnecessary check on the return value of block_commit_write(),
> because it always returns 0.

Dropping the error check before the function signature is changes is
really odd.  I'd suggest to merge this and the following patches into
a single one.
Re: [PATCH v2 2/5] ext4: No need to check return value of block_commit_write()
Posted by Bean Huo 2 years, 7 months ago
On Mon, 2023-06-19 at 21:48 -0700, Christoph Hellwig wrote:
> On Mon, Jun 19, 2023 at 11:18:24PM +0200, Bean Huo wrote:
> > From: Bean Huo <beanhuo@micron.com>
> > 
> > Remove unnecessary check on the return value of
> > block_commit_write(),
> > because it always returns 0.
> 
> Dropping the error check before the function signature is changes is
> really odd.  I'd suggest to merge this and the following patches into
> a single one.

No problem, I will merge them together, thanks.

Kind regards,
Bean
Re: [PATCH v2 2/5] ext4: No need to check return value of block_commit_write()
Posted by Theodore Ts'o 2 years, 7 months ago
On Mon, Jun 19, 2023 at 11:18:24PM +0200, Bean Huo wrote:
> From: Bean Huo <beanhuo@micron.com>
> 
> Remove unnecessary check on the return value of block_commit_write(),
> because it always returns 0.
> 
> Signed-off-by: Bean Huo <beanhuo@micron.com>
> Reviewed-by: Jan Kara <jack@suse.cz>

Acked-by: Theodore Ts'o <tytso@mit.edu>