Skip to contentSkip to conversation

Btrfs: make sure to unblock the transaction when cleaning it up

PATCH In review Josef Bacik 1 participant 2 messages May 31, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: make sure to unblock the transaction when cleaning it up

When a transaction aborts we can get stuck in places where tasks are waiting for the transaction to become unblocked. So we need to unblock the transaction and wake up any waiters so they can exit properly. Thanks,

---
 fs/btrfs/transaction.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
fs/btrfs/transaction.c +7 -0
index 7aed0e8..1715afb 100644
@@ -1204,9 +1204,16 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
 	WARN_ON(trans->use_count > 1);
 
 	spin_lock(&root->fs_info->trans_lock);
+	cur_trans->blocked = 0;
 	list_del_init(&cur_trans->list);
+	if (root->fs_info->running_transaction == cur_trans) {
+		root->fs_info->running_transaction = NULL;
+		root->fs_info->trans_no_join = 0;
+	}
 	spin_unlock(&root->fs_info->trans_lock);
 
+	wake_up(&root->fs_info->transaction_wait);
+
 	btrfs_cleanup_one_transaction(trans->transaction, root);
 
 	put_transaction(cur_trans);
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 32 lines · Josef Bacik

When a transaction aborts we can get stuck in places where tasks are waiting for the transaction to become unblocked. So we need to unblock the transaction and wake up any waiters so they can exit properly. Thanks,

---
 fs/btrfs/transaction.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
fs/btrfs/transaction.c +7 -0
index 7aed0e8..1715afb 100644
@@ -1204,9 +1204,16 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
 	WARN_ON(trans->use_count > 1);
 
 	spin_lock(&root->fs_info->trans_lock);
+	cur_trans->blocked = 0;
 	list_del_init(&cur_trans->list);
+	if (root->fs_info->running_transaction == cur_trans) {
+		root->fs_info->running_transaction = NULL;
+		root->fs_info->trans_no_join = 0;
+	}
 	spin_unlock(&root->fs_info->trans_lock);
 
+	wake_up(&root->fs_info->transaction_wait);
+
 	btrfs_cleanup_one_transaction(trans->transaction, root);
 
 	put_transaction(cur_trans);
Signature · 1 line
1.7.7.6

Actually ignore this, the problem is btrfs_cleanup_one_transaction is just doing waitqueue_active() which is racy, we need to fix it to wake_up, so I'll fix that and send it along. Thanks,

Josef