[06/10] btrfs-progs: Hook FST code in extent (de)alloc
diff mbox series

Message ID 1538405181-25231-7-git-send-email-nborisov@suse.com
State New
Headers show
Series
  • Freespace tree repair support v2
Related show

Commit Message

Nikolay Borisov Oct. 1, 2018, 2:46 p.m. UTC
For now this doesn't change the functionality since FST code is not
yet enabled via the compat bits. But this will be needed when it's
enabled so that the FST is correctly modified during repair operations
that allocate/deallocate  extents.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 extent-tree.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch
diff mbox series

diff --git a/extent-tree.c b/extent-tree.c
index b9a30644720b..7adda557f8e6 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -29,6 +29,7 @@ 
 #include "crc32c.h"
 #include "volumes.h"
 #include "free-space-cache.h"
+#include "free-space-tree.h"
 #include "utils.h"
 
 #define PENDING_EXTENT_INSERT 0
@@ -2276,6 +2277,11 @@  static int __free_extent(struct btrfs_trans_handle *trans,
 			BUG_ON(ret);
 		}
 
+		ret = add_to_free_space_tree(trans, bytenr, num_bytes);
+		if (ret) {
+			goto fail;
+		}
+
 		update_block_group(trans->fs_info, bytenr, num_bytes, 0,
 				   mark_free);
 	}
@@ -2595,6 +2601,11 @@  static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 	btrfs_mark_buffer_dirty(leaf);
 	btrfs_free_path(path);
 
+	ret = remove_from_free_space_tree(trans, ins.objectid,
+					  fs_info->nodesize);
+	if (ret)
+		return ret;
+
 	ret = update_block_group(fs_info, ins.objectid, fs_info->nodesize, 1,
 				 0);