diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2016-02-22 14:59:54 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-02-26 17:27:58 +0100 |
commit | 43318324d20cccccfacf2e82ac10e27eefb6cc95 (patch) | |
tree | a15dbe5de507252b055409ed00d23334c3f181f1 /disk-io.h | |
parent | e2e0dae926b2174c368ee6dbed610d9f98c193a5 (diff) |
btrfs-progs: Allow open_ctree to return fs_info even chunk tree is corrupted
Current open_ctree_fs_info() won't return anything if chunk tree root is
corrupted.
This makes some function, like btrfs-find-root, unable to find any older
chunk tree root, even it is possible to use system_chunk_array in super
block.
And at least two users in mail list has reported such heavily chunk
corruption.
Although we have 'btrfs rescue chunk-recovery' but it's too time
consuming and sometimes not able to cope with a specific filesystem
corruption.
This patch adds a new open ctree flag,
OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR, allowing fs_info to be returned from
open_ctree_fs_info() even there is no valid tree root in it.
Also adds a new close_ctree() variant, close_ctree_fs_info() to handle
possible fs_info without any root.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ adjusted error messages ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'disk-io.h')
-rw-r--r-- | disk-io.h | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -53,7 +53,15 @@ enum btrfs_open_ctree_flags { * Like split PARTIAL into SKIP_CSUM/SKIP_EXTENT */ - OPEN_CTREE_IGNORE_FSID_MISMATCH = (1 << 10) + OPEN_CTREE_IGNORE_FSID_MISMATCH = (1 << 10), + + /* + * Allow open_ctree_fs_info() to return a incomplete fs_info with + * system chunks from super block only. + * It's useful for chunk corruption case. + * Makes no sense for open_ctree variants returning btrfs_root. + */ + OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR = (1 << 11) }; static inline u64 btrfs_sb_offset(int mirror) @@ -101,7 +109,13 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, struct btrfs_fs_info *open_ctree_fs_info(const char *filename, u64 sb_bytenr, u64 root_tree_bytenr, enum btrfs_open_ctree_flags flags); -int close_ctree(struct btrfs_root *root); +int close_ctree_fs_info(struct btrfs_fs_info *fs_info); +static inline int close_ctree(struct btrfs_root *root) +{ + BUG_ON(!root); + return close_ctree_fs_info(root->fs_info); +} + int write_all_supers(struct btrfs_root *root); int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root *root); |