btrfs: Eliminate insert label in add_falloc_range
PATCH 1/1 btrfs: Eliminate insert label in add_falloc_range
By way of inverting the list_empty conditional the insert label can be eliminated, making the function's flow entirely linear.
Signed-off-by Nikolay Borisov <[email protected]>
Suggested-by David Sterba <[email protected]>
--- fs/btrfs/file.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
fs/btrfs/file.c +11 -12
@@ -3036,19 +3036,18 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len) {struct falloc_range *range =NULL ; -if (list_empty (head)) - goto insert; - -/* -* As fallocate iterate by bytenr order, we only need to check -* the last range. -*/ - range = list_last_entry(head, struct falloc_range, list); -if (range->start + range->len == start) { - range->len += len; -return 0 ; +if (!list_empty (head)) { +/* +* As fallocate iterate by bytenr order, we only need to check +* the last range. +*/ + range = list_last_entry(head, struct falloc_range, list); +if (range->start + range->len == start) { + range->len += len; +return 0 ; + } } -insert: + range =kmalloc (sizeof (*range),GFP_KERNEL );if (!range)return -ENOMEM ;
--
2.25.1
Quoted 5 lines · Nikolay Borisov
By way of inverting the
list_emptyconditional the insert label can be eliminated, making the function's flow entirely linear.Signed-off-by Nikolay Borisov <[email protected]>Suggested-by David Sterba <[email protected]>
Added to misc-next, thanks.