diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-06-25 16:01:31 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:04 -0400 |
commit | 1b1e2135dc1e4efbcf25ac9ac9979316d4e1193e (patch) | |
tree | 2af53ed5d4c368bbefd9de94f0adc2902a785468 /fs/btrfs/inode.c | |
parent | 079899c2384023cd8efcd3806680b4f1d2abbd54 (diff) |
Btrfs: Add a per-inode csum mutex to avoid races creating csum items
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index bbba3350d023..d39433dfb2c7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -351,7 +351,9 @@ int __btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, | |||
351 | trans = btrfs_start_transaction(root, 1); | 351 | trans = btrfs_start_transaction(root, 1); |
352 | 352 | ||
353 | btrfs_set_trans_block_group(trans, inode); | 353 | btrfs_set_trans_block_group(trans, inode); |
354 | mutex_lock(&BTRFS_I(inode)->csum_mutex); | ||
354 | btrfs_csum_file_blocks(trans, root, inode, bio, sums); | 355 | btrfs_csum_file_blocks(trans, root, inode, bio, sums); |
356 | mutex_unlock(&BTRFS_I(inode)->csum_mutex); | ||
355 | 357 | ||
356 | ret = btrfs_end_transaction(trans, root); | 358 | ret = btrfs_end_transaction(trans, root); |
357 | BUG_ON(ret); | 359 | BUG_ON(ret); |
@@ -1400,6 +1402,7 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p) | |||
1400 | inode->i_mapping, GFP_NOFS); | 1402 | inode->i_mapping, GFP_NOFS); |
1401 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, | 1403 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, |
1402 | inode->i_mapping, GFP_NOFS); | 1404 | inode->i_mapping, GFP_NOFS); |
1405 | mutex_init(&BTRFS_I(inode)->csum_mutex); | ||
1403 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); | 1406 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); |
1404 | return 0; | 1407 | return 0; |
1405 | } | 1408 | } |
@@ -1701,6 +1704,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
1701 | inode->i_mapping, GFP_NOFS); | 1704 | inode->i_mapping, GFP_NOFS); |
1702 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, | 1705 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, |
1703 | inode->i_mapping, GFP_NOFS); | 1706 | inode->i_mapping, GFP_NOFS); |
1707 | mutex_init(&BTRFS_I(inode)->csum_mutex); | ||
1704 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); | 1708 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); |
1705 | BTRFS_I(inode)->delalloc_bytes = 0; | 1709 | BTRFS_I(inode)->delalloc_bytes = 0; |
1706 | BTRFS_I(inode)->root = root; | 1710 | BTRFS_I(inode)->root = root; |
@@ -1924,6 +1928,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
1924 | inode->i_mapping, GFP_NOFS); | 1928 | inode->i_mapping, GFP_NOFS); |
1925 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, | 1929 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, |
1926 | inode->i_mapping, GFP_NOFS); | 1930 | inode->i_mapping, GFP_NOFS); |
1931 | mutex_init(&BTRFS_I(inode)->csum_mutex); | ||
1927 | BTRFS_I(inode)->delalloc_bytes = 0; | 1932 | BTRFS_I(inode)->delalloc_bytes = 0; |
1928 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); | 1933 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); |
1929 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | 1934 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; |
@@ -2862,6 +2867,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
2862 | inode->i_mapping, GFP_NOFS); | 2867 | inode->i_mapping, GFP_NOFS); |
2863 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, | 2868 | extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree, |
2864 | inode->i_mapping, GFP_NOFS); | 2869 | inode->i_mapping, GFP_NOFS); |
2870 | mutex_init(&BTRFS_I(inode)->csum_mutex); | ||
2865 | BTRFS_I(inode)->delalloc_bytes = 0; | 2871 | BTRFS_I(inode)->delalloc_bytes = 0; |
2866 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); | 2872 | atomic_set(&BTRFS_I(inode)->ordered_writeback, 0); |
2867 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | 2873 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; |