aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-04-11 17:25:13 -0400
committerJosef Bacik <josef@redhat.com>2011-05-23 13:00:57 -0400
commita4abeea41adfa3c143c289045f4625dfaeba2212 (patch)
tree792e2a398d8ba77447ba3f9f2c4266a1ce2f611c /fs/btrfs/ctree.h
parent2a1eb4614d984d5cd4c928784e9afcf5c07f93be (diff)
Btrfs: kill trans_mutex
We use trans_mutex for lots of things, here's a basic list 1) To serialize trans_handles joining the currently running transaction 2) To make sure that no new trans handles are started while we are committing 3) To protect the dead_roots list and the transaction lists Really the serializing trans_handles joining is not too hard, and can really get bogged down in acquiring a reference to the transaction. So replace the trans_mutex with a trans_lock spinlock and use it to do the following 1) Protect fs_info->running_transaction. All trans handles have to do is check this, and then take a reference of the transaction and keep on going. 2) Protect the fs_info->trans_list. This doesn't get used too much, basically it just holds the current transactions, which will usually just be the currently committing transaction and the currently running transaction at most. 3) Protect the dead roots list. This is only ever processed by splicing the list so this is relatively simple. 4) Protect the fs_info->reloc_ctl stuff. This is very lightweight and was using the trans_mutex before, so this is a pretty straightforward change. 5) Protect fs_info->no_trans_join. Because we don't hold the trans_lock over the entirety of the commit we need to have a way to block new people from creating a new transaction while we're doing our work. So we set no_trans_join and in join_transaction we test to see if that is set, and if it is we do a wait_on_commit. 6) Make the transaction use count atomic so we don't need to take locks to modify it when we're dropping references. 7) Add a commit_lock to the transaction to make sure multiple people trying to commit the same transaction don't race and commit at the same time. 8) Make open_ioctl_trans an atomic so we don't have to take any locks for ioctl trans. I have tested this with xfstests, but obviously it is a pretty hairy change so lots of testing is greatly appreciated. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 8f4b81de3ae2..522a39b0033d 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -919,7 +919,6 @@ struct btrfs_fs_info {
919 * is required instead of the faster short fsync log commits 919 * is required instead of the faster short fsync log commits
920 */ 920 */
921 u64 last_trans_log_full_commit; 921 u64 last_trans_log_full_commit;
922 u64 open_ioctl_trans;
923 unsigned long mount_opt:20; 922 unsigned long mount_opt:20;
924 unsigned long compress_type:4; 923 unsigned long compress_type:4;
925 u64 max_inline; 924 u64 max_inline;
@@ -936,7 +935,6 @@ struct btrfs_fs_info {
936 struct super_block *sb; 935 struct super_block *sb;
937 struct inode *btree_inode; 936 struct inode *btree_inode;
938 struct backing_dev_info bdi; 937 struct backing_dev_info bdi;
939 struct mutex trans_mutex;
940 struct mutex tree_log_mutex; 938 struct mutex tree_log_mutex;
941 struct mutex transaction_kthread_mutex; 939 struct mutex transaction_kthread_mutex;
942 struct mutex cleaner_mutex; 940 struct mutex cleaner_mutex;
@@ -957,6 +955,7 @@ struct btrfs_fs_info {
957 struct rw_semaphore subvol_sem; 955 struct rw_semaphore subvol_sem;
958 struct srcu_struct subvol_srcu; 956 struct srcu_struct subvol_srcu;
959 957
958 spinlock_t trans_lock;
960 struct list_head trans_list; 959 struct list_head trans_list;
961 struct list_head hashers; 960 struct list_head hashers;
962 struct list_head dead_roots; 961 struct list_head dead_roots;
@@ -969,6 +968,7 @@ struct btrfs_fs_info {
969 atomic_t async_submit_draining; 968 atomic_t async_submit_draining;
970 atomic_t nr_async_bios; 969 atomic_t nr_async_bios;
971 atomic_t async_delalloc_pages; 970 atomic_t async_delalloc_pages;
971 atomic_t open_ioctl_trans;
972 972
973 /* 973 /*
974 * this is used by the balancing code to wait for all the pending 974 * this is used by the balancing code to wait for all the pending
@@ -1032,6 +1032,7 @@ struct btrfs_fs_info {
1032 int closing; 1032 int closing;
1033 int log_root_recovering; 1033 int log_root_recovering;
1034 int enospc_unlink; 1034 int enospc_unlink;
1035 int trans_no_join;
1035 1036
1036 u64 total_pinned; 1037 u64 total_pinned;
1037 1038
@@ -1053,7 +1054,6 @@ struct btrfs_fs_info {
1053 struct reloc_control *reloc_ctl; 1054 struct reloc_control *reloc_ctl;
1054 1055
1055 spinlock_t delalloc_lock; 1056 spinlock_t delalloc_lock;
1056 spinlock_t new_trans_lock;
1057 u64 delalloc_bytes; 1057 u64 delalloc_bytes;
1058 1058
1059 /* data_alloc_cluster is only used in ssd mode */ 1059 /* data_alloc_cluster is only used in ssd mode */