diff mbox series

[RFC,v2,1/7] jbd2: remove the out label in __jbd2_journal_remove_checkpoint()

Message ID 20210414134737.2366971-2-yi.zhang@huawei.com (mailing list archive)
State New, archived
Headers show
Series ext4, jbd2: fix 3 issues about bdev_try_to_free_page() | expand

Commit Message

Zhang Yi April 14, 2021, 1:47 p.m. UTC
The 'out' lable just return the 'ret' value and seems not required, so
remove this label and switch to return appropriate value immediately.
This patch also do some minor cleanup, no logical change.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
 fs/jbd2/checkpoint.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Jan Kara April 21, 2021, 10:01 a.m. UTC | #1
On Wed 14-04-21 21:47:31, Zhang Yi wrote:
> The 'out' lable just return the 'ret' value and seems not required, so
> remove this label and switch to return appropriate value immediately.
> This patch also do some minor cleanup, no logical change.
> 
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jbd2/checkpoint.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
> index 63b526d44886..bf5511d19ac5 100644
> --- a/fs/jbd2/checkpoint.c
> +++ b/fs/jbd2/checkpoint.c
> @@ -564,13 +564,13 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
>  	struct transaction_chp_stats_s *stats;
>  	transaction_t *transaction;
>  	journal_t *journal;
> -	int ret = 0;
>  
>  	JBUFFER_TRACE(jh, "entry");
>  
> -	if ((transaction = jh->b_cp_transaction) == NULL) {
> +	transaction = jh->b_cp_transaction;
> +	if (!transaction) {
>  		JBUFFER_TRACE(jh, "not on transaction");
> -		goto out;
> +		return 0;
>  	}
>  	journal = transaction->t_journal;
>  
> @@ -579,9 +579,9 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
>  	jh->b_cp_transaction = NULL;
>  	jbd2_journal_put_journal_head(jh);
>  
> -	if (transaction->t_checkpoint_list != NULL ||
> -	    transaction->t_checkpoint_io_list != NULL)
> -		goto out;
> +	/* Is this transaction empty? */
> +	if (transaction->t_checkpoint_list || transaction->t_checkpoint_io_list)
> +		return 0;
>  
>  	/*
>  	 * There is one special case to worry about: if we have just pulled the
> @@ -593,10 +593,12 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
>  	 * See the comment at the end of jbd2_journal_commit_transaction().
>  	 */
>  	if (transaction->t_state != T_FINISHED)
> -		goto out;
> +		return 0;
>  
> -	/* OK, that was the last buffer for the transaction: we can now
> -	   safely remove this transaction from the log */
> +	/*
> +	 * OK, that was the last buffer for the transaction, we can now
> +	 * safely remove this transaction from the log.
> +	 */
>  	stats = &transaction->t_chp_stats;
>  	if (stats->cs_chp_time)
>  		stats->cs_chp_time = jbd2_time_diff(stats->cs_chp_time,
> @@ -606,9 +608,7 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
>  
>  	__jbd2_journal_drop_transaction(journal, transaction);
>  	jbd2_journal_free_transaction(transaction);
> -	ret = 1;
> -out:
> -	return ret;
> +	return 1;
>  }
>  
>  /*
> -- 
> 2.25.4
>
diff mbox series

Patch

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 63b526d44886..bf5511d19ac5 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -564,13 +564,13 @@  int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
 	struct transaction_chp_stats_s *stats;
 	transaction_t *transaction;
 	journal_t *journal;
-	int ret = 0;
 
 	JBUFFER_TRACE(jh, "entry");
 
-	if ((transaction = jh->b_cp_transaction) == NULL) {
+	transaction = jh->b_cp_transaction;
+	if (!transaction) {
 		JBUFFER_TRACE(jh, "not on transaction");
-		goto out;
+		return 0;
 	}
 	journal = transaction->t_journal;
 
@@ -579,9 +579,9 @@  int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
 	jh->b_cp_transaction = NULL;
 	jbd2_journal_put_journal_head(jh);
 
-	if (transaction->t_checkpoint_list != NULL ||
-	    transaction->t_checkpoint_io_list != NULL)
-		goto out;
+	/* Is this transaction empty? */
+	if (transaction->t_checkpoint_list || transaction->t_checkpoint_io_list)
+		return 0;
 
 	/*
 	 * There is one special case to worry about: if we have just pulled the
@@ -593,10 +593,12 @@  int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
 	 * See the comment at the end of jbd2_journal_commit_transaction().
 	 */
 	if (transaction->t_state != T_FINISHED)
-		goto out;
+		return 0;
 
-	/* OK, that was the last buffer for the transaction: we can now
-	   safely remove this transaction from the log */
+	/*
+	 * OK, that was the last buffer for the transaction, we can now
+	 * safely remove this transaction from the log.
+	 */
 	stats = &transaction->t_chp_stats;
 	if (stats->cs_chp_time)
 		stats->cs_chp_time = jbd2_time_diff(stats->cs_chp_time,
@@ -606,9 +608,7 @@  int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
 
 	__jbd2_journal_drop_transaction(journal, transaction);
 	jbd2_journal_free_transaction(transaction);
-	ret = 1;
-out:
-	return ret;
+	return 1;
 }
 
 /*