diff mbox series

btrfs: Eliminate insert label in add_falloc_range

Message ID 20210601060815.148705-1-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: Eliminate insert label in add_falloc_range | expand

Commit Message

Nikolay Borisov June 1, 2021, 6:08 a.m. UTC
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>
Suggested-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/file.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

--
2.25.1

Comments

David Sterba June 2, 2021, 2:34 p.m. UTC | #1
On Tue, Jun 01, 2021 at 09:08:15AM +0300, Nikolay Borisov wrote:
> 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>
> Suggested-by: David Sterba <dsterba@suse.cz>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 2b28a3daa5a9..dcd3fd64dde7 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -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;