Commit 48ec2cf8 authored by Chris Mason's avatar Chris Mason

Btrfs: Fix race in running_transaction checks

When a new transaction was started, the code would incorrectly
set the pointer in fs_info before all the data structures were setup.
fsync heavy workloads hit races on the setup of the ordered inode spinlock
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent e1b81e67
...@@ -56,7 +56,6 @@ static noinline int join_transaction(struct btrfs_root *root) ...@@ -56,7 +56,6 @@ static noinline int join_transaction(struct btrfs_root *root)
total_trans++; total_trans++;
BUG_ON(!cur_trans); BUG_ON(!cur_trans);
root->fs_info->generation++; root->fs_info->generation++;
root->fs_info->running_transaction = cur_trans;
root->fs_info->last_alloc = 0; root->fs_info->last_alloc = 0;
root->fs_info->last_data_alloc = 0; root->fs_info->last_data_alloc = 0;
cur_trans->num_writers = 1; cur_trans->num_writers = 1;
...@@ -74,6 +73,9 @@ static noinline int join_transaction(struct btrfs_root *root) ...@@ -74,6 +73,9 @@ static noinline int join_transaction(struct btrfs_root *root)
extent_io_tree_init(&cur_trans->dirty_pages, extent_io_tree_init(&cur_trans->dirty_pages,
root->fs_info->btree_inode->i_mapping, root->fs_info->btree_inode->i_mapping,
GFP_NOFS); GFP_NOFS);
spin_lock(&root->fs_info->new_trans_lock);
root->fs_info->running_transaction = cur_trans;
spin_unlock(&root->fs_info->new_trans_lock);
} else { } else {
cur_trans->num_writers++; cur_trans->num_writers++;
cur_trans->num_joined++; cur_trans->num_joined++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment