mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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 <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
3d078efae6
commit
77d255348b
1 changed files with 11 additions and 12 deletions
|
@ -3050,19 +3050,18 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len)
|
||||||
{
|
{
|
||||||
struct falloc_range *range = NULL;
|
struct falloc_range *range = NULL;
|
||||||
|
|
||||||
if (list_empty(head))
|
if (!list_empty(head)) {
|
||||||
goto insert;
|
/*
|
||||||
|
* As fallocate iterates by bytenr order, we only need to check
|
||||||
/*
|
* the last range.
|
||||||
* 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 = list_last_entry(head, struct falloc_range, list);
|
range->len += len;
|
||||||
if (range->start + range->len == start) {
|
return 0;
|
||||||
range->len += len;
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
insert:
|
|
||||||
range = kmalloc(sizeof(*range), GFP_KERNEL);
|
range = kmalloc(sizeof(*range), GFP_KERNEL);
|
||||||
if (!range)
|
if (!range)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue