[PATCH] bcachefs: Fix error path of bch2_link_trans()

Youling Tang posted 1 patch 1 year, 7 months ago
fs/bcachefs/fs-common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] bcachefs: Fix error path of bch2_link_trans()
Posted by Youling Tang 1 year, 7 months ago
From: Youling Tang <tangyouling@kylinos.cn>

In bch2_link_trans(), if bch2_inode_nlink_inc() fails, it needs to
call bch2_trans_iter_exit() in the error path.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
 fs/bcachefs/fs-common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c
index 6c737def357e..508d029ac53d 100644
--- a/fs/bcachefs/fs-common.c
+++ b/fs/bcachefs/fs-common.c
@@ -200,12 +200,12 @@ int bch2_link_trans(struct btree_trans *trans,
 
 	ret = bch2_inode_peek(trans, &inode_iter, inode_u, inum, BTREE_ITER_intent);
 	if (ret)
-		goto err;
+		return ret;
 
 	inode_u->bi_ctime = now;
 	ret = bch2_inode_nlink_inc(inode_u);
 	if (ret)
-		return ret;
+		goto err;
 
 	ret = bch2_inode_peek(trans, &dir_iter, dir_u, dir, BTREE_ITER_intent);
 	if (ret)
-- 
2.34.1
Re: [PATCH] bcachefs: Fix error path of bch2_link_trans()
Posted by Kent Overstreet 1 year, 7 months ago
On Tue, Apr 30, 2024 at 11:28:39AM +0800, Youling Tang wrote:
> From: Youling Tang <tangyouling@kylinos.cn>
> 
> In bch2_link_trans(), if bch2_inode_nlink_inc() fails, it needs to
> call bch2_trans_iter_exit() in the error path.

Thanks - applied.
> 
> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
> ---
>  fs/bcachefs/fs-common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c
> index 6c737def357e..508d029ac53d 100644
> --- a/fs/bcachefs/fs-common.c
> +++ b/fs/bcachefs/fs-common.c
> @@ -200,12 +200,12 @@ int bch2_link_trans(struct btree_trans *trans,
>  
>  	ret = bch2_inode_peek(trans, &inode_iter, inode_u, inum, BTREE_ITER_intent);
>  	if (ret)
> -		goto err;
> +		return ret;
>  
>  	inode_u->bi_ctime = now;
>  	ret = bch2_inode_nlink_inc(inode_u);
>  	if (ret)
> -		return ret;
> +		goto err;
>  
>  	ret = bch2_inode_peek(trans, &dir_iter, dir_u, dir, BTREE_ITER_intent);
>  	if (ret)
> -- 
> 2.34.1
>
Re: bcachefs: Fix error path of bch2_link_trans()
Posted by Markus Elfring 1 year, 7 months ago
> > In bch2_link_trans(), if bch2_inode_nlink_inc() fails, it needs to
> > call bch2_trans_iter_exit() in the error path.
>
> Thanks - applied.

https://evilpiepirate.org/git/bcachefs.git/commit/?id=d04db1c7653dee5ee5f918ce951c05eefddad7eb

Would it have been nice to add the tag “Fixes” (besides an imperative wording) accordingly?

Regards,
Markus
Re: bcachefs: Fix error path of bch2_link_trans()
Posted by Youling Tang 1 year, 7 months ago
Hi, Kent

On 30/04/2024 17:18, Markus Elfring wrote:
>>> In bch2_link_trans(), if bch2_inode_nlink_inc() fails, it needs to
>>> call bch2_trans_iter_exit() in the error path.
>> Thanks - applied.
> https://evilpiepirate.org/git/bcachefs.git/commit/?id=d04db1c7653dee5ee5f918ce951c05eefddad7eb
>
> Would it have been nice to add the tag “Fixes” (besides an imperative wording) accordingly?
The following labels can be added:
Fixes: 962ad1a7666 ("bcachefs: Don't BUG_ON() inode link count underflow")

Thanks,
Youling.
Re: bcachefs: Fix error path of bch2_link_trans()
Posted by Markus Elfring 1 year, 7 months ago
>> https://evilpiepirate.org/git/bcachefs.git/commit/?id=d04db1c7653dee5ee5f918ce951c05eefddad7eb
>>
>> Would it have been nice to add the tag “Fixes” (besides an imperative wording) accordingly?
> The following labels can be added:
> Fixes: 962ad1a7666 ("bcachefs: Don't BUG_ON() inode link count underflow")

May the corresponding hash be longer than eleven characters?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc6#n145

Regards,
Markus