Btrfs: hold trans_mutex when using btrfs_record_root_in_trans
btrfs_record_root_in_trans needs the trans_mutex held to make sure two callers don't race to setup the root in a given transaction. This adds it to all the places that were missing it. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
This commit is contained in:
Родитель
4008c04a07
Коммит
2456242530
|
@ -5658,7 +5658,9 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root,
|
||||||
prev_block = block_start;
|
prev_block = block_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_lock(&extent_root->fs_info->trans_mutex);
|
||||||
btrfs_record_root_in_trans(found_root);
|
btrfs_record_root_in_trans(found_root);
|
||||||
|
mutex_unlock(&extent_root->fs_info->trans_mutex);
|
||||||
if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) {
|
if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) {
|
||||||
/*
|
/*
|
||||||
* try to update data extent references while
|
* try to update data extent references while
|
||||||
|
|
|
@ -688,7 +688,9 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
|
||||||
num_bytes -= btrfs_root_used(&dirty->root->root_item);
|
num_bytes -= btrfs_root_used(&dirty->root->root_item);
|
||||||
bytes_used = btrfs_root_used(&root->root_item);
|
bytes_used = btrfs_root_used(&root->root_item);
|
||||||
if (num_bytes) {
|
if (num_bytes) {
|
||||||
|
mutex_lock(&root->fs_info->trans_mutex);
|
||||||
btrfs_record_root_in_trans(root);
|
btrfs_record_root_in_trans(root);
|
||||||
|
mutex_unlock(&root->fs_info->trans_mutex);
|
||||||
btrfs_set_root_used(&root->root_item,
|
btrfs_set_root_used(&root->root_item,
|
||||||
bytes_used - num_bytes);
|
bytes_used - num_bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2832,7 +2832,9 @@ again:
|
||||||
BUG_ON(!wc.replay_dest);
|
BUG_ON(!wc.replay_dest);
|
||||||
|
|
||||||
wc.replay_dest->log_root = log;
|
wc.replay_dest->log_root = log;
|
||||||
|
mutex_lock(&fs_info->trans_mutex);
|
||||||
btrfs_record_root_in_trans(wc.replay_dest);
|
btrfs_record_root_in_trans(wc.replay_dest);
|
||||||
|
mutex_unlock(&fs_info->trans_mutex);
|
||||||
ret = walk_log_tree(trans, log, &wc);
|
ret = walk_log_tree(trans, log, &wc);
|
||||||
BUG_ON(ret);
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче