Btrfs: return path with unlocked nodes in btrfs_next_leaf
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.
Signed-off-by Filipe Manana <[email protected]>
--- fs/btrfs/ctree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/ctree.c +1 -1
@@ -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