@@ -1452,16 +1452,16 @@ int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
14521452 * find a contiguous range of bytes in the file marked as delalloc, not
14531453 * more than 'max_bytes'. start and end are used to return the range,
14541454 *
1455- * 1 is returned if we find something, 0 if nothing was in the tree
1455+ * true is returned if we find something, false if nothing was in the tree
14561456 */
1457- static noinline u64 find_delalloc_range (struct extent_io_tree * tree ,
1457+ static noinline bool find_delalloc_range (struct extent_io_tree * tree ,
14581458 u64 * start , u64 * end , u64 max_bytes ,
14591459 struct extent_state * * cached_state )
14601460{
14611461 struct rb_node * node ;
14621462 struct extent_state * state ;
14631463 u64 cur_start = * start ;
1464- u64 found = 0 ;
1464+ bool found = false ;
14651465 u64 total_bytes = 0 ;
14661466
14671467 spin_lock (& tree -> lock );
@@ -1472,8 +1472,7 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
14721472 */
14731473 node = tree_search (tree , cur_start );
14741474 if (!node ) {
1475- if (!found )
1476- * end = (u64 )- 1 ;
1475+ * end = (u64 )- 1 ;
14771476 goto out ;
14781477 }
14791478
@@ -1493,7 +1492,7 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
14931492 * cached_state = state ;
14941493 refcount_inc (& state -> refs );
14951494 }
1496- found ++ ;
1495+ found = true ;
14971496 * end = state -> end ;
14981497 cur_start = state -> end + 1 ;
14991498 node = rb_next (node );
@@ -1551,21 +1550,22 @@ static noinline int lock_delalloc_pages(struct inode *inode,
15511550}
15521551
15531552/*
1554- * find a contiguous range of bytes in the file marked as delalloc, not
1555- * more than ' max_bytes' . start and end are used to return the range,
1553+ * Find and lock a contiguous range of bytes in the file marked as delalloc, no
1554+ * more than @ max_bytes. @Start and @ end are used to return the range,
15561555 *
1557- * 1 is returned if we find something, 0 if nothing was in the tree
1556+ * Return: true if we find something
1557+ * false if nothing was in the tree
15581558 */
15591559EXPORT_FOR_TESTS
1560- noinline_for_stack u64 find_lock_delalloc_range (struct inode * inode ,
1560+ noinline_for_stack bool find_lock_delalloc_range (struct inode * inode ,
15611561 struct extent_io_tree * tree ,
15621562 struct page * locked_page , u64 * start ,
15631563 u64 * end )
15641564{
15651565 u64 max_bytes = BTRFS_MAX_EXTENT_SIZE ;
15661566 u64 delalloc_start ;
15671567 u64 delalloc_end ;
1568- u64 found ;
1568+ bool found ;
15691569 struct extent_state * cached_state = NULL ;
15701570 int ret ;
15711571 int loops = 0 ;
@@ -1580,7 +1580,7 @@ noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
15801580 * start = delalloc_start ;
15811581 * end = delalloc_end ;
15821582 free_extent_state (cached_state );
1583- return 0 ;
1583+ return false ;
15841584 }
15851585
15861586 /*
@@ -1612,7 +1612,7 @@ noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
16121612 loops = 1 ;
16131613 goto again ;
16141614 } else {
1615- found = 0 ;
1615+ found = false ;
16161616 goto out_failed ;
16171617 }
16181618 }
@@ -3195,19 +3195,19 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode,
31953195{
31963196 struct extent_io_tree * tree = & BTRFS_I (inode )-> io_tree ;
31973197 u64 page_end = delalloc_start + PAGE_SIZE - 1 ;
3198- u64 nr_delalloc ;
3198+ bool found ;
31993199 u64 delalloc_to_write = 0 ;
32003200 u64 delalloc_end = 0 ;
32013201 int ret ;
32023202 int page_started = 0 ;
32033203
32043204
32053205 while (delalloc_end < page_end ) {
3206- nr_delalloc = find_lock_delalloc_range (inode , tree ,
3206+ found = find_lock_delalloc_range (inode , tree ,
32073207 page ,
32083208 & delalloc_start ,
32093209 & delalloc_end );
3210- if (nr_delalloc == 0 ) {
3210+ if (! found ) {
32113211 delalloc_start = delalloc_end + 1 ;
32123212 continue ;
32133213 }
0 commit comments