btrfs: Adjust loop in free_extent_buffer
authorNikolay Borisov <nborisov@suse.com>
Mon, 15 Oct 2018 14:04:01 +0000 (17:04 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:31 +0000 (14:51 +0100)
commitbd6a15e3296c04a645a2bd534be81d862773c186
tree1ab1d81434df3ad42830b55b8a52a63ebc3d029e
parentd482c2943fb728711422d74e7d67369ff906667c
btrfs: Adjust loop in free_extent_buffer

The loop construct in free_extent_buffer was added in
8053f5d747ed ("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>
fs/btrfs/extent_io.c
fs/btrfs/tests/btrfs-tests.c
fs/btrfs/tests/inode-tests.c