diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-06-25 16:01:30 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:03 -0400 |
commit | 925baeddc5b0764a53f2214a1253251bab0e0324 (patch) | |
tree | 0e069bf9cc1c4ecd17c812fd1fb81bf807909ee6 /fs/btrfs/inode.c | |
parent | 1cc127b5d1b71453091859301de4a7dd6ee96fa8 (diff) |
Btrfs: Start btree concurrency work.
The allocation trees and the chunk trees are serialized via their own
dedicated mutexes. This means allocation location is still not very
fine grained.
The main FS btree is protected by locks on each block in the btree. Locks
are taken top / down, and as processing finishes on a given level of the
tree, the lock is released after locking the lower level.
The end result of a search is now a path where only the lowest level
is locked. Releasing or freeing the path drops any locks held.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0c79346fd2c9..61bd8953a683 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -115,6 +115,7 @@ static int cow_file_range(struct inode *inode, u64 start, u64 end) | |||
115 | trans = btrfs_start_transaction(root, 1); | 115 | trans = btrfs_start_transaction(root, 1); |
116 | BUG_ON(!trans); | 116 | BUG_ON(!trans); |
117 | btrfs_set_trans_block_group(trans, inode); | 117 | btrfs_set_trans_block_group(trans, inode); |
118 | mutex_unlock(&root->fs_info->fs_mutex); | ||
118 | 119 | ||
119 | num_bytes = (end - start + blocksize) & ~(blocksize - 1); | 120 | num_bytes = (end - start + blocksize) & ~(blocksize - 1); |
120 | num_bytes = max(blocksize, num_bytes); | 121 | num_bytes = max(blocksize, num_bytes); |
@@ -159,6 +160,7 @@ static int cow_file_range(struct inode *inode, u64 start, u64 end) | |||
159 | btrfs_add_ordered_inode(inode); | 160 | btrfs_add_ordered_inode(inode); |
160 | btrfs_update_inode(trans, root, inode); | 161 | btrfs_update_inode(trans, root, inode); |
161 | out: | 162 | out: |
163 | mutex_lock(&root->fs_info->fs_mutex); | ||
162 | btrfs_end_transaction(trans, root); | 164 | btrfs_end_transaction(trans, root); |
163 | return ret; | 165 | return ret; |
164 | } | 166 | } |
@@ -349,10 +351,12 @@ int __btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, | |||
349 | 351 | ||
350 | mutex_lock(&root->fs_info->fs_mutex); | 352 | mutex_lock(&root->fs_info->fs_mutex); |
351 | trans = btrfs_start_transaction(root, 1); | 353 | trans = btrfs_start_transaction(root, 1); |
354 | mutex_unlock(&root->fs_info->fs_mutex); | ||
352 | 355 | ||
353 | btrfs_set_trans_block_group(trans, inode); | 356 | btrfs_set_trans_block_group(trans, inode); |
354 | btrfs_csum_file_blocks(trans, root, inode, bio, sums); | 357 | btrfs_csum_file_blocks(trans, root, inode, bio, sums); |
355 | 358 | ||
359 | mutex_lock(&root->fs_info->fs_mutex); | ||
356 | ret = btrfs_end_transaction(trans, root); | 360 | ret = btrfs_end_transaction(trans, root); |
357 | BUG_ON(ret); | 361 | BUG_ON(ret); |
358 | mutex_unlock(&root->fs_info->fs_mutex); | 362 | mutex_unlock(&root->fs_info->fs_mutex); |
@@ -807,6 +811,7 @@ static int btrfs_unlink_trans(struct btrfs_trans_handle *trans, | |||
807 | goto err; | 811 | goto err; |
808 | } | 812 | } |
809 | ret = btrfs_delete_one_dir_name(trans, root, path, di); | 813 | ret = btrfs_delete_one_dir_name(trans, root, path, di); |
814 | btrfs_release_path(root, path); | ||
810 | 815 | ||
811 | dentry->d_inode->i_ctime = dir->i_ctime; | 816 | dentry->d_inode->i_ctime = dir->i_ctime; |
812 | ret = btrfs_del_inode_ref(trans, root, name, name_len, | 817 | ret = btrfs_del_inode_ref(trans, root, name, name_len, |
@@ -881,8 +886,9 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
881 | struct btrfs_trans_handle *trans; | 886 | struct btrfs_trans_handle *trans; |
882 | unsigned long nr = 0; | 887 | unsigned long nr = 0; |
883 | 888 | ||
884 | if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) | 889 | if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) { |
885 | return -ENOTEMPTY; | 890 | return -ENOTEMPTY; |
891 | } | ||
886 | 892 | ||
887 | mutex_lock(&root->fs_info->fs_mutex); | 893 | mutex_lock(&root->fs_info->fs_mutex); |
888 | ret = btrfs_check_free_space(root, 1, 1); | 894 | ret = btrfs_check_free_space(root, 1, 1); |