path: root/ctree.h
diff options
authorJosef Bacik <>2013-05-14 14:44:22 -0400
committerChris Mason <>2013-06-19 13:52:16 -0400
commit11be10f71e1af5256f221feb9e91300b3e28bbef (patch)
treebda0d77fbae18150aa1d866e008bc71a5b36b9fd /ctree.h
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 <> Signed-off-by: Chris Mason <>
Diffstat (limited to 'ctree.h')
1 files changed, 2 insertions, 0 deletions
diff --git a/ctree.h b/ctree.h
index 4ea37ac3..cc145944 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2073,6 +2073,8 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
int btrfs_check_block_accounting(struct btrfs_root *root);
void btrfs_pin_extent(struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes);
+void btrfs_unpin_extent(struct btrfs_fs_info *fs_info,
+ u64 bytenr, u64 num_bytes);
int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy);