aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-02-13 11:09:14 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:57 -0500
commit569e0f358c0c37f6733702d4a5d2c412860f7169 (patch)
tree8ab0ece9bd2716da66a43406628f6f5176604817 /fs/btrfs/disk-io.c
parentdde5740fdd6175fc95aecf4ccc7856fbbad9b44e (diff)
Btrfs: place ordered operations on a per transaction list
Miao made the ordered operations stuff run async, which introduced a deadlock where we could get somebody (sync) racing in and committing the transaction while a commit was already happening. The new committer would try and flush ordered operations which would hang waiting for the commit to finish because it is done asynchronously and no longer inherits the callers trans handle. To fix this we need to make the ordered operations list a per transaction list. We can get new inodes added to the ordered operation list by truncating them and then having another process writing to them, so this makes it so that anybody trying to add an ordered operation _must_ start a transaction in order to add itself to the list, which will keep new inodes from getting added to the ordered operations list after we start committing. This should fix the deadlock and also keeps us from doing a lot more work than we need to during commit. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9fcce54ecde4..e511d9f78c19 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -56,7 +56,8 @@ static void end_workqueue_fn(struct btrfs_work *work);
56static void free_fs_root(struct btrfs_root *root); 56static void free_fs_root(struct btrfs_root *root);
57static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, 57static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
58 int read_only); 58 int read_only);
59static void btrfs_destroy_ordered_operations(struct btrfs_root *root); 59static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t,
60 struct btrfs_root *root);
60static void btrfs_destroy_ordered_extents(struct btrfs_root *root); 61static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
61static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, 62static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
62 struct btrfs_root *root); 63 struct btrfs_root *root);
@@ -2029,7 +2030,6 @@ int open_ctree(struct super_block *sb,
2029 INIT_LIST_HEAD(&fs_info->dead_roots); 2030 INIT_LIST_HEAD(&fs_info->dead_roots);
2030 INIT_LIST_HEAD(&fs_info->delayed_iputs); 2031 INIT_LIST_HEAD(&fs_info->delayed_iputs);
2031 INIT_LIST_HEAD(&fs_info->delalloc_inodes); 2032 INIT_LIST_HEAD(&fs_info->delalloc_inodes);
2032 INIT_LIST_HEAD(&fs_info->ordered_operations);
2033 INIT_LIST_HEAD(&fs_info->caching_block_groups); 2033 INIT_LIST_HEAD(&fs_info->caching_block_groups);
2034 spin_lock_init(&fs_info->delalloc_lock); 2034 spin_lock_init(&fs_info->delalloc_lock);
2035 spin_lock_init(&fs_info->trans_lock); 2035 spin_lock_init(&fs_info->trans_lock);
@@ -3538,7 +3538,8 @@ void btrfs_error_commit_super(struct btrfs_root *root)
3538 btrfs_cleanup_transaction(root); 3538 btrfs_cleanup_transaction(root);
3539} 3539}
3540 3540
3541static void btrfs_destroy_ordered_operations(struct btrfs_root *root) 3541static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t,
3542 struct btrfs_root *root)
3542{ 3543{
3543 struct btrfs_inode *btrfs_inode; 3544 struct btrfs_inode *btrfs_inode;
3544 struct list_head splice; 3545 struct list_head splice;
@@ -3548,7 +3549,7 @@ static void btrfs_destroy_ordered_operations(struct btrfs_root *root)
3548 mutex_lock(&root->fs_info->ordered_operations_mutex); 3549 mutex_lock(&root->fs_info->ordered_operations_mutex);
3549 spin_lock(&root->fs_info->ordered_extent_lock); 3550 spin_lock(&root->fs_info->ordered_extent_lock);
3550 3551
3551 list_splice_init(&root->fs_info->ordered_operations, &splice); 3552 list_splice_init(&t->ordered_operations, &splice);
3552 while (!list_empty(&splice)) { 3553 while (!list_empty(&splice)) {
3553 btrfs_inode = list_entry(splice.next, struct btrfs_inode, 3554 btrfs_inode = list_entry(splice.next, struct btrfs_inode,
3554 ordered_operations); 3555 ordered_operations);
@@ -3829,7 +3830,7 @@ int btrfs_cleanup_transaction(struct btrfs_root *root)
3829 while (!list_empty(&list)) { 3830 while (!list_empty(&list)) {
3830 t = list_entry(list.next, struct btrfs_transaction, list); 3831 t = list_entry(list.next, struct btrfs_transaction, list);
3831 3832
3832 btrfs_destroy_ordered_operations(root); 3833 btrfs_destroy_ordered_operations(t, root);
3833 3834
3834 btrfs_destroy_ordered_extents(root); 3835 btrfs_destroy_ordered_extents(root);
3835 3836