Skip to contentSkip to conversation

Btrfs: return path with unlocked nodes in btrfs_next_leaf

PATCH New Filipe Manana 1 participant 1 message Jul 31, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: return path with unlocked nodes in btrfs_next_leaf

Calling unlock_up() to release our new path doesn't release the read lock on the node at level 1, because our return path has path->slots[0] == 0, which makes unlock_up() skip unlocking that node. Since we don't need to return that node locked, call btrfs_unlock_up_safe() instead of unlock_up(), which will release all nodes in the path (except the leaf of course).
For any level N >= 2, the corresponding node lock isn't released by unlock_up() too if path->slots[N - 1] == 0.

Releasing the read lock immediately will allow concurrent writers to write lock that node at level 1 (or higher levels if applicable) while the btrfs_next_leaf() caller processes the leaf.

---
 fs/btrfs/ctree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/ctree.c +1 -1
index 783ea3b..8ca6761 100644
@@ -5833,7 +5833,7 @@ again:
 	}
 	ret = 0;
 done:
-	unlock_up(path, 0, 1, 0, NULL);
+	btrfs_unlock_up_safe(path, 1);
 	path->leave_spinning = old_spinning;
 	if (!old_spinning)
 		btrfs_set_path_blocking(path);
Signature · 1 line
1.9.1