Btrfs: add a extent ref verify tool
We were having corruption issues that were tied back to problems with the extent tree. In order to track them down I built this tool to try and find the culprit, which was pretty successful. If you compile with this tool on it will live verify every ref update that the fs makes and make sure it is consistent and valid. I've run this through with xfstests and haven't gotten any false positives. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> [ update error messages, add fixup from Dan Carpenter to handle errors of read_tree_block ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
84f7d8e624
commit
fd708b81d9
@ -51,6 +51,7 @@
|
||||
#include "qgroup.h"
|
||||
#include "compression.h"
|
||||
#include "tree-checker.h"
|
||||
#include "ref-verify.h"
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
#include <asm/cpufeature.h>
|
||||
@ -2509,6 +2510,7 @@ int open_ctree(struct super_block *sb,
|
||||
/* readahead state */
|
||||
INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
||||
spin_lock_init(&fs_info->reada_lock);
|
||||
btrfs_init_ref_verify(fs_info);
|
||||
|
||||
fs_info->thread_pool_size = min_t(unsigned long,
|
||||
num_online_cpus() + 2, 8);
|
||||
@ -2920,6 +2922,9 @@ retry_root_backup:
|
||||
if (ret)
|
||||
goto fail_trans_kthread;
|
||||
|
||||
if (btrfs_build_ref_tree(fs_info))
|
||||
btrfs_err(fs_info, "couldn't build ref tree");
|
||||
|
||||
/* do not make disk changes in broken FS or nologreplay is given */
|
||||
if (btrfs_super_log_root(disk_super) != 0 &&
|
||||
!btrfs_test_opt(fs_info, NOLOGREPLAY)) {
|
||||
@ -3785,6 +3790,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)
|
||||
cleanup_srcu_struct(&fs_info->subvol_srcu);
|
||||
|
||||
btrfs_free_stripe_hash_table(fs_info);
|
||||
btrfs_free_ref_cache(fs_info);
|
||||
|
||||
__btrfs_free_block_rsv(root->orphan_block_rsv);
|
||||
root->orphan_block_rsv = NULL;
|
||||
|
Reference in New Issue
Block a user