path: root/extent-tree.c
diff options
authorChris Mason <>2012-02-10 13:28:50 -0500
committerChris Mason <>2012-02-10 13:28:50 -0500
commit62b79931546bca1b95a4b23ecec8378c372b26f7 (patch)
tree7870cdcb077193cc20982dbf43279575d4f839d0 /extent-tree.c
parentae1822f73f92adca8ccfac24bc0e6e440f776fa4 (diff)
btrfsck: remove extents from the fsck reference tracker as they are freed
During btrfsck --repair, we make an index of extents that have incorrect reference counts. Once we've collect the whole index, we go through and modify the extent allocation tree to reflect the correct results. Changing the extent allocation tree may free blocks, and so it may end up removing a block that had a missing reference structure. The fsck code may then circle back around and add the reference back. The result is an extent that isn't actually used, but is recorded in the extent allocation tree. This commit adds a hook called as extents are freed. The hook searches the index of incorrect references and updates it to reflect the freeing of the extent. Signed-off-by: Chris Mason <>
Diffstat (limited to 'extent-tree.c')
1 files changed, 6 insertions, 0 deletions
diff --git a/extent-tree.c b/extent-tree.c
index dd593fe6..ee87f1f1 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2083,6 +2083,12 @@ static int __free_extent(struct btrfs_trans_handle *trans,
u32 item_size;
u64 refs;
+ if (root->fs_info->free_extent_hook) {
+ root->fs_info->free_extent_hook(trans, root, bytenr, num_bytes,
+ parent, root_objectid, owner_objectid,
+ owner_offset, refs_to_drop);
+ }
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;