diff mbox series

[3/9] jbd2: remove unnedded "need_copy_out" in jbd2_journal_write_metadata_buffer

Message ID 20240506141801.1165315-4-shikemeng@huaweicloud.com
State Superseded
Headers show
Series A fix and some cleanups to jbd2 | expand

Commit Message

Kemeng Shi May 6, 2024, 2:17 p.m. UTC
As we only need to copy out when we should do escape, need_copy_out
could be simply replaced by "do_escape".

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/jbd2/journal.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Zhang Yi May 7, 2024, 12:28 p.m. UTC | #1
On 2024/5/6 22:17, Kemeng Shi wrote:
> As we only need to copy out when we should do escape, need_copy_out
> could be simply replaced by "do_escape".
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Make sense, looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
>  fs/jbd2/journal.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 068031f35aea..9a35d0c5b38c 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -327,7 +327,6 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
>  				  struct buffer_head **bh_out,
>  				  sector_t blocknr)
>  {
> -	int need_copy_out = 0;
>  	int done_copy_out = 0;
>  	int do_escape = 0;
>  	char *mapped_data;
> @@ -382,16 +381,14 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
>  	/*
>  	 * Check for escaping
>  	 */
> -	if (*((__be32 *)mapped_data) == cpu_to_be32(JBD2_MAGIC_NUMBER)) {
> -		need_copy_out = 1;
> +	if (*((__be32 *)mapped_data) == cpu_to_be32(JBD2_MAGIC_NUMBER))
>  		do_escape = 1;
> -	}
>  	kunmap_local(mapped_data);
>  
>  	/*
>  	 * Do we need to do a data copy?
>  	 */
> -	if (need_copy_out && !done_copy_out) {
> +	if (do_escape && !done_copy_out) {
>  		char *tmp;
>  
>  		spin_unlock(&jh_in->b_state_lock);
>
Jan Kara May 12, 2024, 11:06 a.m. UTC | #2
On Mon 06-05-24 22:17:55, Kemeng Shi wrote:
> As we only need to copy out when we should do escape, need_copy_out
> could be simply replaced by "do_escape".
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Looks good to me. Feel free to add:

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

								Honza

> ---
>  fs/jbd2/journal.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 068031f35aea..9a35d0c5b38c 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -327,7 +327,6 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
>  				  struct buffer_head **bh_out,
>  				  sector_t blocknr)
>  {
> -	int need_copy_out = 0;
>  	int done_copy_out = 0;
>  	int do_escape = 0;
>  	char *mapped_data;
> @@ -382,16 +381,14 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
>  	/*
>  	 * Check for escaping
>  	 */
> -	if (*((__be32 *)mapped_data) == cpu_to_be32(JBD2_MAGIC_NUMBER)) {
> -		need_copy_out = 1;
> +	if (*((__be32 *)mapped_data) == cpu_to_be32(JBD2_MAGIC_NUMBER))
>  		do_escape = 1;
> -	}
>  	kunmap_local(mapped_data);
>  
>  	/*
>  	 * Do we need to do a data copy?
>  	 */
> -	if (need_copy_out && !done_copy_out) {
> +	if (do_escape && !done_copy_out) {
>  		char *tmp;
>  
>  		spin_unlock(&jh_in->b_state_lock);
> -- 
> 2.30.0
>
diff mbox series

Patch

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 068031f35aea..9a35d0c5b38c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -327,7 +327,6 @@  int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
 				  struct buffer_head **bh_out,
 				  sector_t blocknr)
 {
-	int need_copy_out = 0;
 	int done_copy_out = 0;
 	int do_escape = 0;
 	char *mapped_data;
@@ -382,16 +381,14 @@  int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
 	/*
 	 * Check for escaping
 	 */
-	if (*((__be32 *)mapped_data) == cpu_to_be32(JBD2_MAGIC_NUMBER)) {
-		need_copy_out = 1;
+	if (*((__be32 *)mapped_data) == cpu_to_be32(JBD2_MAGIC_NUMBER))
 		do_escape = 1;
-	}
 	kunmap_local(mapped_data);
 
 	/*
 	 * Do we need to do a data copy?
 	 */
-	if (need_copy_out && !done_copy_out) {
+	if (do_escape && !done_copy_out) {
 		char *tmp;
 
 		spin_unlock(&jh_in->b_state_lock);