2024-04-30 03:29:31

by Youling Tang

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

From: Youling Tang <[email protected]>

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 <[email protected]>
---
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



2024-04-30 03:31:37

by Kent Overstreet

[permalink] [raw]
Subject: Re: [PATCH] bcachefs: Fix error path of bch2_link_trans()

On Tue, Apr 30, 2024 at 11:28:39AM +0800, Youling Tang wrote:
> From: Youling Tang <[email protected]>
>
> 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 <[email protected]>
> ---
> 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
>

2024-04-30 09:29:03

by Markus Elfring

[permalink] [raw]
Subject: Re: bcachefs: Fix error path of bch2_link_trans()

> > 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

2024-04-30 09:30:44

by Youling Tang

[permalink] [raw]
Subject: Re: bcachefs: Fix error path of bch2_link_trans()

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.

2024-04-30 10:56:16

by Markus Elfring

[permalink] [raw]
Subject: Re: bcachefs: Fix error path of bch2_link_trans()

>> 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