aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-07-24 15:45:34 -0400
committerChris Mason <chris.mason@oracle.com>2011-07-27 12:46:46 -0400
commit81317fdeddcef259b6ecf7b5c0d04caa167c6b54 (patch)
treeaeca005b8b595539b554a6b8a92dc052ccad5601 /fs/btrfs/transaction.c
parenta65917156e345946dbde3d7effd28124c6d6a8c2 (diff)
Btrfs: fix deadlock when throttling transactions
Hit this nice little deadlock. What happens is this __btrfs_end_transaction with throttle set, --use_count so it equals 0 btrfs_commit_transaction <somebody else actually manages to start the commit> btrfs_end_transaction --use_count so now its -1 <== BAD we just return and wait on the transaction This is bad because we just return after our use_count is -1 and don't let go of our num_writer count on the transaction, so the guy committing the transaction just sits there forever. Fix this by inc'ing our use_count if we're going to call commit_transaction so that if we call btrfs_end_transaction it's valid. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 654755b18951..eb55863bb4ae 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -497,10 +497,17 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
497 } 497 }
498 498
499 if (lock && cur_trans->blocked && !cur_trans->in_commit) { 499 if (lock && cur_trans->blocked && !cur_trans->in_commit) {
500 if (throttle) 500 if (throttle) {
501 /*
502 * We may race with somebody else here so end up having
503 * to call end_transaction on ourselves again, so inc
504 * our use_count.
505 */
506 trans->use_count++;
501 return btrfs_commit_transaction(trans, root); 507 return btrfs_commit_transaction(trans, root);
502 else 508 } else {
503 wake_up_process(info->transaction_kthread); 509 wake_up_process(info->transaction_kthread);
510 }
504 } 511 }
505 512
506 WARN_ON(cur_trans != info->running_transaction); 513 WARN_ON(cur_trans != info->running_transaction);