All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: simplify error handling in btrfs_lookup_dentry
@ 2022-07-11 15:16 Nikolay Borisov
  2022-07-12 19:54 ` Rohit Singh
  2022-07-13 14:03 ` David Sterba
  0 siblings, 2 replies; 6+ messages in thread
From: Nikolay Borisov @ 2022-07-11 15:16 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

In btrfs_lookup_dentry releasing the reference of the sub_root and the
running orphan cleanup should only happen if the dentry found actually
represents a subvolume. This can only be true in the 'else' branch as
otherwise either fixup_tree_root_location returned an ENOENT error, in
which case sub_root wouldn't have been changed or if we got a different
errno this means btrfs_get_fs_root couldn't have executed successfully
again meaning sub_root will equal to root. So simplify all the branches
by moving the code into the 'else'.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/inode.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0b17335555e0..1dd073e96696 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5821,11 +5821,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 			inode = new_simple_dir(dir->i_sb, &location, sub_root);
 	} else {
 		inode = btrfs_iget(dir->i_sb, location.objectid, sub_root);
-	}
-	if (root != sub_root)
 		btrfs_put_root(sub_root);
-
-	if (!IS_ERR(inode) && root != sub_root) {
 		down_read(&fs_info->cleanup_work_sem);
 		if (!sb_rdonly(inode->i_sb))
 			ret = btrfs_orphan_cleanup(sub_root);
-- 
2.25.1


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

end of thread, other threads:[~2022-07-13 14:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-11 15:16 [PATCH] btrfs: simplify error handling in btrfs_lookup_dentry Nikolay Borisov
2022-07-12 19:54 ` Rohit Singh
2022-07-12 20:36   ` Nikolay Borisov
2022-07-12 21:13     ` Rohit Singh
2022-07-12 21:26     ` Sweet Tea Dorminy
2022-07-13 14:03 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.