Skip to contentSkip to conversation

Btrfs: avoid deadlock in btrfs_async_run_delayed_root

PATCH In review Liu Bo 1 participant 2 messages Oct 21, 2017 Btrfs file system

lore
Share & tools
lore

Liu Bo

author
#0 lore raw

PATCH 1/1 Btrfs: avoid deadlock in btrfs_async_run_delayed_root

Here %path is set with ->leave_spinning=1, thus it'll hold the rwlock after btrfs_search_slot(), however, when processing delayed items in __btrfs_commit_inode_delayed_items(), it goes to acquire node->mutex which might sleep, that is, it may sleep under spin_lock.

Given node->mutex is necessary to avoid race between async works, this remove the ->leave_spining setting.

---
 fs/btrfs/delayed-inode.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/delayed-inode.c +0 -1
index 19e4ad2..a857a2f 100644
@@ -1331,7 +1331,6 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work)
 	if (!delayed_node)
 		goto free_path;
 
-	path->leave_spinning = 1;
 	root = delayed_node->root;
 
 	trans = btrfs_join_transaction(root);
Signature · 1 line
2.9.4
author
#1 lore raw

Hi,

Please ignore this patch, I misunderstood the lock order.

thanks,

-liubo

Quoted 32 lines · Liu Bo

Here %path is set with ->leave_spinning=1, thus it'll hold the rwlock after btrfs_search_slot(), however, when processing delayed items in __btrfs_commit_inode_delayed_items(), it goes to acquire node->mutex which might sleep, that is, it may sleep under spin_lock.

Given node->mutex is necessary to avoid race between async works, this remove the ->leave_spining setting.

---
 fs/btrfs/delayed-inode.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/delayed-inode.c +0 -1
index 19e4ad2..a857a2f 100644
@@ -1331,7 +1331,6 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work)
 	if (!delayed_node)
 		goto free_path;
 
-	path->leave_spinning = 1;
 	root = delayed_node->root;
 
 	trans = btrfs_join_transaction(root);
Signature · 6 lines
2.9.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html