[01/10] btrfs-progs: Add support for freespace tree in btrfs_read_fs_root
diff mbox series

Message ID 1538405181-25231-2-git-send-email-nborisov@suse.com
State New
Headers show
Series
  • Freespace tree repair support v2
Related show

Commit Message

Nikolay Borisov Oct. 1, 2018, 2:46 p.m. UTC
For completeness sake add code to btrfs_read_fs_root so that it can
handle the freespace tree.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 disk-io.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Omar Sandoval Oct. 2, 2018, 7:20 p.m. UTC | #1
On Mon, Oct 01, 2018 at 05:46:12PM +0300, Nikolay Borisov wrote:
> For completeness sake add code to btrfs_read_fs_root so that it can
> handle the freespace tree.

Reviewed-by: Omar Sandoval <osandov@fb.com>

> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  disk-io.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/disk-io.c b/disk-io.c
> index 2e6d56a36af9..14f0fd5c2f0c 100644
> --- a/disk-io.c
> +++ b/disk-io.c
> @@ -668,6 +668,9 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
>  	if (location->objectid == BTRFS_QUOTA_TREE_OBJECTID)
>  		return fs_info->quota_enabled ? fs_info->quota_root :
>  				ERR_PTR(-ENOENT);
> +	if (location->objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
> +        return fs_info->free_space_root ? fs_info->free_space_root :
> +                                                  ERR_PTR(-ENOENT);
>  
>  	BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID ||
>  	       location->offset != (u64)-1);
> -- 
> 2.7.4
>
Su Yue Oct. 4, 2018, 1:05 a.m. UTC | #2
On 10/1/18 10:46 PM, Nikolay Borisov wrote:
> For completeness sake add code to btrfs_read_fs_root so that it can
> handle the freespace tree.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
>   disk-io.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/disk-io.c b/disk-io.c
> index 2e6d56a36af9..14f0fd5c2f0c 100644
> --- a/disk-io.c
> +++ b/disk-io.c
> @@ -668,6 +668,9 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
>   	if (location->objectid == BTRFS_QUOTA_TREE_OBJECTID)
>   		return fs_info->quota_enabled ? fs_info->quota_root :
>   				ERR_PTR(-ENOENT);
> +	if (location->objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
> +        return fs_info->free_space_root ? fs_info->free_space_root :
> +                                                  ERR_PTR(-ENOENT);
>   
>   	BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID ||
>   	       location->offset != (u64)-1);
>

Patch
diff mbox series

diff --git a/disk-io.c b/disk-io.c
index 2e6d56a36af9..14f0fd5c2f0c 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -668,6 +668,9 @@  struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
 	if (location->objectid == BTRFS_QUOTA_TREE_OBJECTID)
 		return fs_info->quota_enabled ? fs_info->quota_root :
 				ERR_PTR(-ENOENT);
+	if (location->objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
+        return fs_info->free_space_root ? fs_info->free_space_root :
+                                                  ERR_PTR(-ENOENT);
 
 	BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID ||
 	       location->offset != (u64)-1);