btrfs: Refactor main loop in extent_readpages
authorNikolay Borisov <nborisov@suse.com>
Thu, 29 Nov 2018 16:41:31 +0000 (18:41 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:49 +0000 (14:51 +0100)
commit61ed3a144aa75e76a3b0f75c2f49c81435e74621
tree805a03861d79339eed44394ebe54ccd32453cf8e
parent15c8276302c42ebf704b44578f25bc35dfdbde24
btrfs: Refactor main loop in extent_readpages

extent_readpages processes all pages in the readlist in batches of 16,
this is implemented by a single for loop but thanks to an if condition
the loop does 2 things based on whether we've filled the batch or not.
Additionally due to the structure of the code there is an additional
check which deals with partial batches.

Streamline all of this by explicitly using two loops. The outter one is
used to process all pages while the inner one just fills in the batch
of 16 (currently). Due to this new structure the code guarantees that
all pages are processed in the loop hence the code to deal with any
leftovers is eliminated.

This also enable the compiler to inline __extent_readpages:

./scripts/bloat-o-meter fs/btrfs/extent_io.o extent_io.for

add/remove: 0/1 grow/shrink: 1/0 up/down: 660/-820 (-160)
Function                                     old     new   delta
extent_readpages                             476    1136    +660
__extent_readpages                           820       -    -820
Total: Before=44315, After=44155, chg -0.36%

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