mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-26 23:43:09 +00:00
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>
This commit is contained in:
parent
0c05f623b1
commit
abf010e593
@ -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;
|
||||
}
|
||||
|
||||
|
12
disk-io.h
12
disk-io.h
@ -38,7 +38,17 @@ enum btrfs_open_ctree_flags {
|
||||
* Don't print error messages if bytenr or checksums do not match in
|
||||
* tree block headers. Turn on by OPEN_CTREE_SUPPRESS_ERROR
|
||||
*/
|
||||
OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS = (1 << 8)
|
||||
OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS = (1 << 8),
|
||||
/* Return chunk root */
|
||||
__OPEN_CTREEE_RETURN_CHUNK_ROOT = (1 << 9),
|
||||
OPEN_CTREE_CHUNK_ROOT_ONLY = OPEN_CTREE_PARTIAL +
|
||||
OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS +
|
||||
__OPEN_CTREEE_RETURN_CHUNK_ROOT,
|
||||
/*
|
||||
* TODO: cleanup: Split the open_ctree_flags into more indepent
|
||||
* tree bits.
|
||||
* Like split PARTIAL into SKIP_CSUM/SKIP_EXTENT
|
||||
*/
|
||||
};
|
||||
|
||||
static inline u64 btrfs_sb_offset(int mirror)
|
||||
|
Loading…
Reference in New Issue
Block a user