Commit 77d25534 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba
Browse files

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: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3d078efa
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -3050,11 +3050,9 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len)
{
	struct falloc_range *range = NULL;

	if (list_empty(head))
		goto insert;

	if (!list_empty(head)) {
		/*
	 * As fallocate iterate by bytenr order, we only need to check
		 * As fallocate iterates by bytenr order, we only need to check
		 * the last range.
		 */
		range = list_last_entry(head, struct falloc_range, list);
@@ -3062,7 +3060,8 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len)
			range->len += len;
			return 0;
		}
insert:
	}

	range = kmalloc(sizeof(*range), GFP_KERNEL);
	if (!range)
		return -ENOMEM;