mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-24 23:22:27 +00:00
Btrfs-progs: fsck: deal with corrupted csum root
If checksum root is corrupted, fsck will get segmentation. This is because if we fail to load checksum root, root's node is NULL which cause NULL pointer deferences later. To fix this problem, we just did something like extent tree rebuilding. Allocate a new one and clear uptodate flag. We will do sanity check before fsck going on. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
8d2abcb6cc
commit
ed1b086a30
@ -6990,6 +6990,11 @@ int cmd_check(int argc, char **argv)
|
|||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto close_out;
|
goto close_out;
|
||||||
}
|
}
|
||||||
|
if (!extent_buffer_uptodate(info->csum_root->node)) {
|
||||||
|
fprintf(stderr, "Checksum root corrupted, rerun with --init-csum-tree option\n");
|
||||||
|
ret = -EIO;
|
||||||
|
goto close_out;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "checking extents\n");
|
fprintf(stderr, "checking extents\n");
|
||||||
ret = check_chunks_and_extents(root);
|
ret = check_chunks_and_extents(root);
|
||||||
|
@ -909,6 +909,13 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
|
|||||||
printk("Couldn't setup csum tree\n");
|
printk("Couldn't setup csum tree\n");
|
||||||
if (!(flags & OPEN_CTREE_PARTIAL))
|
if (!(flags & OPEN_CTREE_PARTIAL))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
/* do the same thing as extent tree rebuilding */
|
||||||
|
fs_info->csum_root->node =
|
||||||
|
btrfs_find_create_tree_block(fs_info->extent_root, 0,
|
||||||
|
leafsize);
|
||||||
|
if (!fs_info->csum_root->node)
|
||||||
|
return -ENOMEM;
|
||||||
|
clear_extent_buffer_uptodate(NULL, fs_info->csum_root->node);
|
||||||
}
|
}
|
||||||
fs_info->csum_root->track_dirty = 1;
|
fs_info->csum_root->track_dirty = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user