Btrfs: avoid deadlock on transaction waiting list
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 4 Mar 2013 16:25:41 +0000 (16:25 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Mon, 4 Mar 2013 21:33:23 +0000 (16:33 -0500)
Only let one trans handle to wait for other handles, otherwise we
will get ABBA issues.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/transaction.c

index d8fce6fe9cf8361ceda3062615cf5170d37ec57e..fedede1fe178b46f087ae7ad9a00346cc997dc19 100644 (file)
@@ -1457,6 +1457,13 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
        btrfs_abort_transaction(trans, root, err);
 
        spin_lock(&root->fs_info->trans_lock);
+
+       if (list_empty(&cur_trans->list)) {
+               spin_unlock(&root->fs_info->trans_lock);
+               btrfs_end_transaction(trans, root);
+               return;
+       }
+
        list_del_init(&cur_trans->list);
        if (cur_trans == root->fs_info->running_transaction) {
                root->fs_info->trans_no_join = 1;