From 11be10f71e1af5256f221feb9e91300b3e28bbef Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 14 May 2013 14:44:22 -0400 Subject: Btrfs-progs: make fsck fix certain file extent inconsistencies The tree log bug I introduced could create inconsistent file extent entries in the file system tree and in some worst cases even create multiple extent entries for the same entry. To fix this we need to do a few things 1) Keep track of extent items that overlap and then pick the one that covers the largest area and delete the rest of the items. 2) Keep track of file extent items that land in extent items but don't match disk_bytenr/disk_num_bytes exactly. Once we find these we need to figure out who is the right ref and then fix all of the other refs to agree. Each of these cases require a complete rescan of all of the extents, so unfortunately if you hit this particular problem the fsck is going to take quite a while since it will likely rescan all the trees 2 or 3 times. With this patch the broken file system a user sent me is fixed and a broken file system that was created by my reproducer is also fixed. Thanks, Signed-off-by: Josef Bacik Signed-off-by: Chris Mason --- disk-io.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'disk-io.c') diff --git a/disk-io.c b/disk-io.c index 21b410d3..9ffe6e4e 100644 --- a/disk-io.c +++ b/disk-io.c @@ -538,7 +538,10 @@ static int commit_tree_roots(struct btrfs_trans_handle *trans, list_del_init(next); root = list_entry(next, struct btrfs_root, dirty_list); update_cowonly_root(trans, root); + free_extent_buffer(root->commit_root); + root->commit_root = NULL; } + return 0; } -- cgit v1.2.3