linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate
@ 2020-07-01  8:30 zhengliang
  2020-07-05  5:50 ` Andreas Dilger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zhengliang @ 2020-07-01  8:30 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4

It should call trace exit in all return path for ext4_truncate.

v2:
It shoule call trace exit in all return path, and add "out_trace" label to avoid the
multiple copies of the cleanup code in each error case.
 
Signed-off-by: zhengliang <zhengliang6@huawei.com>
---
 fs/ext4/inode.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 10dd470876b3..6187c8880c02 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4163,7 +4163,7 @@ int ext4_truncate(struct inode *inode)
 	trace_ext4_truncate_enter(inode);
 
 	if (!ext4_can_truncate(inode))
-		return 0;
+		goto out_trace;
 
 	if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
 		ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
@@ -4172,16 +4172,14 @@ int ext4_truncate(struct inode *inode)
 		int has_inline = 1;
 
 		err = ext4_inline_data_truncate(inode, &has_inline);
-		if (err)
-			return err;
-		if (has_inline)
-			return 0;
+		if (err || has_inline)
+			goto out_trace;
 	}
 
 	/* If we zero-out tail of the page, we have to create jinode for jbd2 */
 	if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
 		if (ext4_inode_attach_jinode(inode) < 0)
-			return 0;
+			goto out_trace;
 	}
 
 	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
@@ -4190,8 +4188,10 @@ int ext4_truncate(struct inode *inode)
 		credits = ext4_blocks_for_truncate(inode);
 
 	handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
-	if (IS_ERR(handle))
-		return PTR_ERR(handle);
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
+		goto out_trace;
+	}
 
 	if (inode->i_size & (inode->i_sb->s_blocksize - 1))
 		ext4_block_truncate_page(handle, mapping, inode->i_size);
@@ -4242,6 +4242,7 @@ int ext4_truncate(struct inode *inode)
 		err = err2;
 	ext4_journal_stop(handle);
 
+out_trace:
 	trace_ext4_truncate_exit(inode);
 	return err;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate
  2020-07-01  8:30 [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate zhengliang
@ 2020-07-05  5:50 ` Andreas Dilger
  2020-07-08 10:03 ` Ritesh Harjani
  2020-08-06  4:53 ` tytso
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Dilger @ 2020-07-05  5:50 UTC (permalink / raw)
  To: zhengliang; +Cc: Theodore Y. Ts'o, Ext4 Developers List

[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]

On Jul 1, 2020, at 2:30 AM, zhengliang <zhengliang6@huawei.com> wrote:
> 
> It should call trace exit in all return path for ext4_truncate.
> 
> v2:
> It shoule call trace exit in all return path, and add "out_trace" label to avoid the
> multiple copies of the cleanup code in each error case.
> 
> Signed-off-by: zhengliang <zhengliang6@huawei.com>

Thanks for the patch.  It looks good.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> fs/ext4/inode.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 10dd470876b3..6187c8880c02 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4163,7 +4163,7 @@ int ext4_truncate(struct inode *inode)
> 	trace_ext4_truncate_enter(inode);
> 
> 	if (!ext4_can_truncate(inode))
> -		return 0;
> +		goto out_trace;
> 
> 	if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
> 		ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
> @@ -4172,16 +4172,14 @@ int ext4_truncate(struct inode *inode)
> 		int has_inline = 1;
> 
> 		err = ext4_inline_data_truncate(inode, &has_inline);
> -		if (err)
> -			return err;
> -		if (has_inline)
> -			return 0;
> +		if (err || has_inline)
> +			goto out_trace;
> 	}
> 
> 	/* If we zero-out tail of the page, we have to create jinode for jbd2 */
> 	if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
> 		if (ext4_inode_attach_jinode(inode) < 0)
> -			return 0;
> +			goto out_trace;
> 	}
> 
> 	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> @@ -4190,8 +4188,10 @@ int ext4_truncate(struct inode *inode)
> 		credits = ext4_blocks_for_truncate(inode);
> 
> 	handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
> -	if (IS_ERR(handle))
> -		return PTR_ERR(handle);
> +	if (IS_ERR(handle)) {
> +		err = PTR_ERR(handle);
> +		goto out_trace;
> +	}
> 
> 	if (inode->i_size & (inode->i_sb->s_blocksize - 1))
> 		ext4_block_truncate_page(handle, mapping, inode->i_size);
> @@ -4242,6 +4242,7 @@ int ext4_truncate(struct inode *inode)
> 		err = err2;
> 	ext4_journal_stop(handle);
> 
> +out_trace:
> 	trace_ext4_truncate_exit(inode);
> 	return err;
> }
> --
> 2.17.1
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate
  2020-07-01  8:30 [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate zhengliang
  2020-07-05  5:50 ` Andreas Dilger
@ 2020-07-08 10:03 ` Ritesh Harjani
  2020-08-06  4:53 ` tytso
  2 siblings, 0 replies; 4+ messages in thread
From: Ritesh Harjani @ 2020-07-08 10:03 UTC (permalink / raw)
  To: zhengliang, tytso, adilger.kernel; +Cc: linux-ext4



On 7/1/20 2:00 PM, zhengliang wrote:
> It should call trace exit in all return path for ext4_truncate.
> 
> v2:
> It shoule call trace exit in all return path, and add "out_trace" label to avoid the
> multiple copies of the cleanup code in each error case.

v2 description should generally go below three dashed line so that
it need not become part of commit msg.


> 
> Signed-off-by: zhengliang <zhengliang6@huawei.com>

LGTM, feel free to add
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>


> ---
>   fs/ext4/inode.c | 17 +++++++++--------
>   1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 10dd470876b3..6187c8880c02 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4163,7 +4163,7 @@ int ext4_truncate(struct inode *inode)
>   	trace_ext4_truncate_enter(inode);
> 
>   	if (!ext4_can_truncate(inode))
> -		return 0;
> +		goto out_trace;
> 
>   	if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
>   		ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
> @@ -4172,16 +4172,14 @@ int ext4_truncate(struct inode *inode)
>   		int has_inline = 1;
> 
>   		err = ext4_inline_data_truncate(inode, &has_inline);
> -		if (err)
> -			return err;
> -		if (has_inline)
> -			return 0;
> +		if (err || has_inline)
> +			goto out_trace;
>   	}
> 
>   	/* If we zero-out tail of the page, we have to create jinode for jbd2 */
>   	if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
>   		if (ext4_inode_attach_jinode(inode) < 0)
> -			return 0;
> +			goto out_trace;
>   	}
> 
>   	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> @@ -4190,8 +4188,10 @@ int ext4_truncate(struct inode *inode)
>   		credits = ext4_blocks_for_truncate(inode);
> 
>   	handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
> -	if (IS_ERR(handle))
> -		return PTR_ERR(handle);
> +	if (IS_ERR(handle)) {
> +		err = PTR_ERR(handle);
> +		goto out_trace;
> +	}
> 
>   	if (inode->i_size & (inode->i_sb->s_blocksize - 1))
>   		ext4_block_truncate_page(handle, mapping, inode->i_size);
> @@ -4242,6 +4242,7 @@ int ext4_truncate(struct inode *inode)
>   		err = err2;
>   	ext4_journal_stop(handle);
> 
> +out_trace:
>   	trace_ext4_truncate_exit(inode);
>   	return err;
>   }
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate
  2020-07-01  8:30 [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate zhengliang
  2020-07-05  5:50 ` Andreas Dilger
  2020-07-08 10:03 ` Ritesh Harjani
@ 2020-08-06  4:53 ` tytso
  2 siblings, 0 replies; 4+ messages in thread
From: tytso @ 2020-08-06  4:53 UTC (permalink / raw)
  To: zhengliang; +Cc: adilger.kernel, linux-ext4

On Wed, Jul 01, 2020 at 04:30:27PM +0800, zhengliang wrote:
> It should call trace exit in all return path for ext4_truncate.
> 
> v2:
> It shoule call trace exit in all return path, and add "out_trace" label to avoid the
> multiple copies of the cleanup code in each error case.
>  
> Signed-off-by: zhengliang <zhengliang6@huawei.com>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-06 11:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01  8:30 [PATCH v2] ext4: lost matching-pair of trace in ext4_truncate zhengliang
2020-07-05  5:50 ` Andreas Dilger
2020-07-08 10:03 ` Ritesh Harjani
2020-08-06  4:53 ` tytso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).