aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2015-01-16 11:22:28 +0800
committerDavid Sterba <dsterba@suse.cz>2015-02-11 17:19:30 +0100
commitabf010e593cec271a632b746c031a1bf206f7769 (patch)
tree8922b0e19fdc069e32635efafdbdafc44ef4d708 /disk-io.c
parent0c05f623b13f93105163535f016fc049fa04dbb6 (diff)
downloadbtrfs-progs-abf010e593cec271a632b746c031a1bf206f7769.tar.gz
btrfs-progs-abf010e593cec271a632b746c031a1bf206f7769.tar.xz
btrfs-progs-abf010e593cec271a632b746c031a1bf206f7769.zip
btrfs-progs: Add new btrfs_open_ctree_flags CHUNK_ONLY
Add new flag CHUNK_ONLY and internal used only flag __RETURN_CHUNK. CHUNK_ONLY will imply __RETURN_CHUNK, SUPPRESS_ERROR and PARTIAL, which will allow the fs to be opened with only chunk tree OK. This will improve the usability for btrfs-find-root. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/disk-io.c b/disk-io.c
index 6c1961e..b709ff5 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1197,7 +1197,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
BTRFS_UUID_SIZE);
ret = btrfs_setup_all_roots(fs_info, root_tree_bytenr, flags);
- if (ret)
+ if (ret && !(flags & __OPEN_CTREEE_RETURN_CHUNK_ROOT))
goto out_chunk;
return fs_info;
@@ -1242,6 +1242,8 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr,
info = open_ctree_fs_info(filename, sb_bytenr, 0, flags);
if (!info)
return NULL;
+ if (flags & __OPEN_CTREEE_RETURN_CHUNK_ROOT)
+ return info->chunk_root;
return info->fs_root;
}
@@ -1252,6 +1254,8 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
info = __open_ctree_fd(fp, path, sb_bytenr, 0, flags);
if (!info)
return NULL;
+ if (flags & __OPEN_CTREEE_RETURN_CHUNK_ROOT)
+ return info->chunk_root;
return info->fs_root;
}