summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorNikolay Borisov2018-10-15 16:04:01 +0200
committerDavid Sterba2018-12-17 14:51:31 +0100
commit46cc775e29c55d6ae9f4dbb733ec066ff56d3922 (patch)
tree1ab1d81434df3ad42830b55b8a52a63ebc3d029e /fs/btrfs/extent_io.c
parentbtrfs: Remove special handling of EXTENT_BUFFER_UNMAPPED while freeing (diff)
downloadkernel-qcow2-linux-46cc775e29c55d6ae9f4dbb733ec066ff56d3922.tar.gz
kernel-qcow2-linux-46cc775e29c55d6ae9f4dbb733ec066ff56d3922.tar.xz
kernel-qcow2-linux-46cc775e29c55d6ae9f4dbb733ec066ff56d3922.zip
btrfs: Adjust loop in free_extent_buffer
The loop construct in free_extent_buffer was added in 242e18c7c1a8 ("Btrfs: reduce lock contention on extent buffer locks") as means of reducing the times the eb lock is taken, the non-last ref count is decremented and lock is released. As the special handling of UNMAPPED extent buffers was removed now there is only one decrement op which is happening for EXTENT_BUFFER_UNMAPPED case. This commit modifies the loop condition so that in case of UNMAPPED buffers the eb's lock is taken only if we are 100% sure the eb is going to be freed by the current executor of the code. Additionally, remove superfluous ref count ops in btrfs test. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 39a41e8777fc..e7cbd3f98404 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5074,7 +5074,9 @@ void free_extent_buffer(struct extent_buffer *eb)
while (1) {
refs = atomic_read(&eb->refs);
- if (refs <= 3)
+ if ((!test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags) && refs <= 3)
+ || (test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags) &&
+ refs == 1))
break;
old = atomic_cmpxchg(&eb->refs, refs, refs - 1);
if (old == refs)