]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: open code key_search
authorNikolay Borisov <nborisov@suse.com>
Wed, 27 May 2020 10:10:53 +0000 (13:10 +0300)
committerDavid Sterba <dsterba@suse.com>
Thu, 28 May 2020 12:01:52 +0000 (14:01 +0200)
commit421f969dc51a9e62394557151e880cc1f2cb83b7
treeddc23f25b77f786b9df46d1ff96ea79ce1636ad7
parent169ebd574f75984e2a49a0a461a22d8359f90b7a
btrfs: open code key_search

This function wraps the optimisation implemented by 36aa9f02638c
("Btrfs: optimize key searches in btrfs_search_slot") however this
optimisation is really used in only one place - btrfs_search_slot.

Just open code the optimisation and also add a comment explaining how it
works since it's not clear just by looking at the code - the key point
here is it depends on an internal invariant that BTRFS' btree provides,
namely intermediate pointers always contain the key at slot0 at the
child node. So in the case of exact match we can safely assume that the
given key will always be in slot 0 on lower levels.

Furthermore this results in a reduction of btrfs_search_slot's size:

./scripts/bloat-o-meter ctree.orig fs/btrfs/ctree.o
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-75 (-75)
Function                                     old     new   delta
btrfs_search_slot                           2783    2708     -75
Total: Before=50423, After=50348, chg -0.15%

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
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/ctree.c