|
38 | 38 | #include "math.h" |
39 | 39 | #include "sysfs.h" |
40 | 40 | #include "qgroup.h" |
| 41 | +#include "ref-verify.h" |
41 | 42 |
|
42 | 43 | #undef SCRAMBLE_DELAYED_REFS |
43 | 44 |
|
@@ -2188,6 +2189,9 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, |
2188 | 2189 | BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID && |
2189 | 2190 | root_objectid == BTRFS_TREE_LOG_OBJECTID); |
2190 | 2191 |
|
| 2192 | + btrfs_ref_tree_mod(root, bytenr, num_bytes, parent, root_objectid, |
| 2193 | + owner, offset, BTRFS_ADD_DELAYED_REF); |
| 2194 | + |
2191 | 2195 | if (owner < BTRFS_FIRST_FREE_OBJECTID) { |
2192 | 2196 | ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr, |
2193 | 2197 | num_bytes, parent, |
@@ -7280,6 +7284,10 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, |
7280 | 7284 | if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) { |
7281 | 7285 | int old_ref_mod, new_ref_mod; |
7282 | 7286 |
|
| 7287 | + btrfs_ref_tree_mod(root, buf->start, buf->len, parent, |
| 7288 | + root->root_key.objectid, |
| 7289 | + btrfs_header_level(buf), 0, |
| 7290 | + BTRFS_DROP_DELAYED_REF); |
7283 | 7291 | ret = btrfs_add_delayed_tree_ref(fs_info, trans, buf->start, |
7284 | 7292 | buf->len, parent, |
7285 | 7293 | root->root_key.objectid, |
@@ -7343,6 +7351,11 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, |
7343 | 7351 | if (btrfs_is_testing(fs_info)) |
7344 | 7352 | return 0; |
7345 | 7353 |
|
| 7354 | + if (root_objectid != BTRFS_TREE_LOG_OBJECTID) |
| 7355 | + btrfs_ref_tree_mod(root, bytenr, num_bytes, parent, |
| 7356 | + root_objectid, owner, offset, |
| 7357 | + BTRFS_DROP_DELAYED_REF); |
| 7358 | + |
7346 | 7359 | /* |
7347 | 7360 | * tree log blocks never actually go into the extent allocation |
7348 | 7361 | * tree, just update pinning info and exit early. |
@@ -8318,6 +8331,10 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, |
8318 | 8331 |
|
8319 | 8332 | BUG_ON(root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID); |
8320 | 8333 |
|
| 8334 | + btrfs_ref_tree_mod(root, ins->objectid, ins->offset, 0, |
| 8335 | + root->root_key.objectid, owner, offset, |
| 8336 | + BTRFS_ADD_DELAYED_EXTENT); |
| 8337 | + |
8321 | 8338 | ret = btrfs_add_delayed_data_ref(fs_info, trans, ins->objectid, |
8322 | 8339 | ins->offset, 0, |
8323 | 8340 | root->root_key.objectid, owner, |
@@ -8542,6 +8559,9 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, |
8542 | 8559 | extent_op->is_data = false; |
8543 | 8560 | extent_op->level = level; |
8544 | 8561 |
|
| 8562 | + btrfs_ref_tree_mod(root, ins.objectid, ins.offset, parent, |
| 8563 | + root_objectid, level, 0, |
| 8564 | + BTRFS_ADD_DELAYED_EXTENT); |
8545 | 8565 | ret = btrfs_add_delayed_tree_ref(fs_info, trans, ins.objectid, |
8546 | 8566 | ins.offset, parent, |
8547 | 8567 | root_objectid, level, |
@@ -10391,6 +10411,8 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, |
10391 | 10411 | * remove it. |
10392 | 10412 | */ |
10393 | 10413 | free_excluded_extents(fs_info, block_group); |
| 10414 | + btrfs_free_ref_tree_range(fs_info, block_group->key.objectid, |
| 10415 | + block_group->key.offset); |
10394 | 10416 |
|
10395 | 10417 | memcpy(&key, &block_group->key, sizeof(key)); |
10396 | 10418 | index = get_block_group_index(block_group); |
|
0 commit comments