summaryrefslogtreecommitdiff
path: root/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-05-14 14:44:22 -0400
committerChris Mason <chris.mason@fusionio.com>2013-06-19 13:52:16 -0400
commit11be10f71e1af5256f221feb9e91300b3e28bbef (patch)
treebda0d77fbae18150aa1d866e008bc71a5b36b9fd /extent-tree.c
parentbd338824de665c0ccef576ccd119cfc7dace829c (diff)
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>
Diffstat (limited to 'extent-tree.c')
-rw-r--r--extent-tree.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/extent-tree.c b/extent-tree.c
index 381572d5..9b381836 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2182,6 +2182,12 @@ void btrfs_pin_extent(struct btrfs_fs_info *fs_info,
update_pinned_extents(fs_info->extent_root, bytenr, num_bytes, 1);
}
+void btrfs_unpin_extent(struct btrfs_fs_info *fs_info,
+ u64 bytenr, u64 num_bytes)
+{
+ update_pinned_extents(fs_info->extent_root, bytenr, num_bytes, 0);
+}
+
/*
* remove an extent from the root, returns 0 on success
*/