aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-06-09 09:35:50 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commit48ec2cf8738b0db53dc8361026cb7a328f7ad386 (patch)
treeadcb56cf494b67c578a5032b3454203c21171419 /fs/btrfs/transaction.c
parente1b81e6761bd8419146d4bbe0aadd8b2d348a01c (diff)
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: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 57746c11eae..1cb084efd6e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -56,7 +56,6 @@ static noinline int join_transaction(struct btrfs_root *root)
total_trans++;
BUG_ON(!cur_trans);
root->fs_info->generation++;
- root->fs_info->running_transaction = cur_trans;
root->fs_info->last_alloc = 0;
root->fs_info->last_data_alloc = 0;
cur_trans->num_writers = 1;
@@ -74,6 +73,9 @@ static noinline int join_transaction(struct btrfs_root *root)
extent_io_tree_init(&cur_trans->dirty_pages,
root->fs_info->btree_inode->i_mapping,
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 {
cur_trans->num_writers++;
cur_trans->num_joined++;