Skip to contentSkip to conversation

bcachefs: Fix error path of bch2_link_trans()

PATCH In review Youling Tang 3 participants 5 messages Apr 30, 2024 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/bcachefs/fs-common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/bcachefs/fs-common.c +2 -2
index 6c737def357e..508d029ac53d 100644
@@ -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)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Youling Tang

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.

Quoted 28 lines
---
 fs/bcachefs/fs-common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/bcachefs/fs-common.c +2 -2
index 6c737def357e..508d029ac53d 100644
@@ -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)
Signature · 1 line
2.34.1
#3 lore raw

Hi, Kent

Quoted 6 lines · Markus Elfring
Quoted 3 lines
Quoted 2 lines

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.

#4 lore raw
Quoted 5 lines
Quoted 3 lines

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