Skip to content

Commit ba1bfbd

Browse files
author
Jan Schmidt
committed
Btrfs: fix a tree mod logging issue for root replacement operations
Avoid the implicit free by tree_mod_log_set_root_pointer, which is wrong in two places. Where needed, we call tree_mod_log_free_eb explicitly now. Signed-off-by: Jan Schmidt <[email protected]>
1 parent 57911b8 commit ba1bfbd

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

fs/btrfs/ctree.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,6 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info,
647647
if (tree_mod_dont_log(fs_info, NULL))
648648
return 0;
649649

650-
__tree_mod_log_free_eb(fs_info, old_root);
651-
652650
ret = tree_mod_alloc(fs_info, flags, &tm);
653651
if (ret < 0)
654652
goto out;
@@ -926,12 +924,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
926924
ret = btrfs_dec_ref(trans, root, buf, 1, 1);
927925
BUG_ON(ret); /* -ENOMEM */
928926
}
929-
/*
930-
* don't log freeing in case we're freeing the root node, this
931-
* is done by tree_mod_log_set_root_pointer later
932-
*/
933-
if (buf != root->node && btrfs_header_level(buf) != 0)
934-
tree_mod_log_free_eb(root->fs_info, buf);
927+
tree_mod_log_free_eb(root->fs_info, buf);
935928
clean_tree_block(trans, root, buf);
936929
*last_ref = 1;
937930
}
@@ -1728,6 +1721,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
17281721
goto enospc;
17291722
}
17301723

1724+
tree_mod_log_free_eb(root->fs_info, root->node);
17311725
tree_mod_log_set_root_pointer(root, child);
17321726
rcu_assign_pointer(root->node, child);
17331727

0 commit comments

Comments
 (0)