public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] btrfs: fix the btrfs_get_global_root return value
@ 2023-05-23  8:40 Christoph Hellwig
  2023-05-23  8:40 ` [PATCH 2/3] btrfs: convert btrfs_get_global_root to use a switch statement Christoph Hellwig
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-05-23  8:40 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs

btrfs_grab_root returns either the root or NULL, and the callers of
btrfs_get_global_root expect it to return the same.  But all the more
recently added roots instead return an ERR_PTR, so fix this.

Fixes: bcef60f24903 ("Btrfs: quota tree support and startup")
Fixes: f7a81ea4cc6b ("Btrfs: create UUID tree if required")
Fixes: 70f6d82ec73c ("Btrfs: add free space tree mount option")
Fixes: 14033b08a029 ("btrfs: don't save block group root into super block")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/disk-io.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index dc2ad0bf88f84c..5dc5d733ecfa4a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1358,19 +1358,13 @@ static struct btrfs_root *btrfs_get_global_root(struct btrfs_fs_info *fs_info,
 	if (objectid == BTRFS_CSUM_TREE_OBJECTID)
 		return btrfs_grab_root(btrfs_global_root(fs_info, &key));
 	if (objectid == BTRFS_QUOTA_TREE_OBJECTID)
-		return btrfs_grab_root(fs_info->quota_root) ?
-			fs_info->quota_root : ERR_PTR(-ENOENT);
+		return btrfs_grab_root(fs_info->quota_root);
 	if (objectid == BTRFS_UUID_TREE_OBJECTID)
-		return btrfs_grab_root(fs_info->uuid_root) ?
-			fs_info->uuid_root : ERR_PTR(-ENOENT);
+		return btrfs_grab_root(fs_info->uuid_root);
 	if (objectid == BTRFS_BLOCK_GROUP_TREE_OBJECTID)
-		return btrfs_grab_root(fs_info->block_group_root) ?
-			fs_info->block_group_root : ERR_PTR(-ENOENT);
-	if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) {
-		struct btrfs_root *root = btrfs_global_root(fs_info, &key);
-
-		return btrfs_grab_root(root) ? root : ERR_PTR(-ENOENT);
-	}
+		return btrfs_grab_root(fs_info->block_group_root);
+	if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
+		return btrfs_grab_root(btrfs_global_root(fs_info, &key));
 	return NULL;
 }
 
-- 
2.39.2


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

end of thread, other threads:[~2023-05-25 23:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-23  8:40 [PATCH 1/3] btrfs: fix the btrfs_get_global_root return value Christoph Hellwig
2023-05-23  8:40 ` [PATCH 2/3] btrfs: convert btrfs_get_global_root to use a switch statement Christoph Hellwig
2023-05-23 10:19   ` Johannes Thumshirn
2023-05-23  8:40 ` [PATCH 3/3] btrfs: remove a pointless NULL check in btrfs_lookup_fs_root Christoph Hellwig
2023-05-23 10:20   ` Johannes Thumshirn
2023-05-23 10:11 ` [PATCH 1/3] btrfs: fix the btrfs_get_global_root return value Johannes Thumshirn
2023-05-23 11:37 ` Anand Jain
2023-05-23 11:48   ` Christoph Hellwig
2023-05-25 23:12     ` David Sterba
2023-05-25 23:15 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox