Btrfs-progs: make fsck fix certain file extent inconsistencies
authorJosef Bacik <jbacik@fusionio.com>
Tue, 14 May 2013 18:44:22 +0000 (14:44 -0400)
committerChris Mason <chris.mason@fusionio.com>
Wed, 19 Jun 2013 17:52:16 +0000 (13:52 -0400)
commit11be10f71e1af5256f221feb9e91300b3e28bbef
treebda0d77fbae18150aa1d866e008bc71a5b36b9fd
parentbd338824de665c0ccef576ccd119cfc7dace829c
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 <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
cmds-check.c
ctree.h
disk-io.c
extent-tree.c