Skip to content

Commit cd660d0

Browse files
fdmananakdave
authored andcommitted
btrfs: reorganize logic at free_extent_buffer() for better readability
It's hard to read the logic to break out of the while loop since it's a very long expression consisting of a logical or of two composite expressions, each one composed by a logical and. Further each one is also testing for the EXTENT_BUFFER_UNMAPPED bit, making it more verbose than necessary. So change from this: if ((!test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags) && refs <= 3) || (test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags) && refs == 1)) break; To this: if (test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags)) { if (refs == 1) break; } else if (refs <= 3) { break; } At least on x86_64 using gcc 9.3.0, this doesn't change the object size. Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 9516bae commit cd660d0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/btrfs/extent_io.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3487,10 +3487,13 @@ void free_extent_buffer(struct extent_buffer *eb)
34873487

34883488
refs = atomic_read(&eb->refs);
34893489
while (1) {
3490-
if ((!test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags) && refs <= 3)
3491-
|| (test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags) &&
3492-
refs == 1))
3490+
if (test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags)) {
3491+
if (refs == 1)
3492+
break;
3493+
} else if (refs <= 3) {
34933494
break;
3495+
}
3496+
34943497
if (atomic_try_cmpxchg(&eb->refs, &refs, refs - 1))
34953498
return;
34963499
}

0 commit comments

Comments
 (0)