|
@@ -6136,7 +6136,6 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
|
|
struct extent_buffer *buf,
|
|
struct extent_buffer *buf,
|
|
u64 parent, int last_ref)
|
|
u64 parent, int last_ref)
|
|
{
|
|
{
|
|
- struct btrfs_block_group_cache *cache = NULL;
|
|
|
|
int pin = 1;
|
|
int pin = 1;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
@@ -6152,17 +6151,20 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
|
|
if (!last_ref)
|
|
if (!last_ref)
|
|
return;
|
|
return;
|
|
|
|
|
|
- cache = btrfs_lookup_block_group(root->fs_info, buf->start);
|
|
|
|
-
|
|
|
|
if (btrfs_header_generation(buf) == trans->transid) {
|
|
if (btrfs_header_generation(buf) == trans->transid) {
|
|
|
|
+ struct btrfs_block_group_cache *cache;
|
|
|
|
+
|
|
if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
|
|
if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
|
|
ret = check_ref_cleanup(trans, root, buf->start);
|
|
ret = check_ref_cleanup(trans, root, buf->start);
|
|
if (!ret)
|
|
if (!ret)
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ cache = btrfs_lookup_block_group(root->fs_info, buf->start);
|
|
|
|
+
|
|
if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
|
|
if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
|
|
pin_down_extent(root, cache, buf->start, buf->len, 1);
|
|
pin_down_extent(root, cache, buf->start, buf->len, 1);
|
|
|
|
+ btrfs_put_block_group(cache);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -6170,6 +6172,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
|
|
|
|
|
|
btrfs_add_free_space(cache, buf->start, buf->len);
|
|
btrfs_add_free_space(cache, buf->start, buf->len);
|
|
btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE, 0);
|
|
btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE, 0);
|
|
|
|
+ btrfs_put_block_group(cache);
|
|
trace_btrfs_reserved_extent_free(root, buf->start, buf->len);
|
|
trace_btrfs_reserved_extent_free(root, buf->start, buf->len);
|
|
pin = 0;
|
|
pin = 0;
|
|
}
|
|
}
|
|
@@ -6184,7 +6187,6 @@ out:
|
|
* anymore.
|
|
* anymore.
|
|
*/
|
|
*/
|
|
clear_bit(EXTENT_BUFFER_CORRUPT, &buf->bflags);
|
|
clear_bit(EXTENT_BUFFER_CORRUPT, &buf->bflags);
|
|
- btrfs_put_block_group(cache);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/* Can return -ENOMEM */
|
|
/* Can return -ENOMEM */
|