@@ -1452,16 +1452,16 @@ int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
1452
1452
* find a contiguous range of bytes in the file marked as delalloc, not
1453
1453
* more than 'max_bytes'. start and end are used to return the range,
1454
1454
*
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
1456
1456
*/
1457
- static noinline u64 find_delalloc_range (struct extent_io_tree * tree ,
1457
+ static noinline bool find_delalloc_range (struct extent_io_tree * tree ,
1458
1458
u64 * start , u64 * end , u64 max_bytes ,
1459
1459
struct extent_state * * cached_state )
1460
1460
{
1461
1461
struct rb_node * node ;
1462
1462
struct extent_state * state ;
1463
1463
u64 cur_start = * start ;
1464
- u64 found = 0 ;
1464
+ bool found = false ;
1465
1465
u64 total_bytes = 0 ;
1466
1466
1467
1467
spin_lock (& tree -> lock );
@@ -1472,8 +1472,7 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
1472
1472
*/
1473
1473
node = tree_search (tree , cur_start );
1474
1474
if (!node ) {
1475
- if (!found )
1476
- * end = (u64 )- 1 ;
1475
+ * end = (u64 )- 1 ;
1477
1476
goto out ;
1478
1477
}
1479
1478
@@ -1493,7 +1492,7 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
1493
1492
* cached_state = state ;
1494
1493
refcount_inc (& state -> refs );
1495
1494
}
1496
- found ++ ;
1495
+ found = true ;
1497
1496
* end = state -> end ;
1498
1497
cur_start = state -> end + 1 ;
1499
1498
node = rb_next (node );
@@ -1551,21 +1550,22 @@ static noinline int lock_delalloc_pages(struct inode *inode,
1551
1550
}
1552
1551
1553
1552
/*
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,
1556
1555
*
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
1558
1558
*/
1559
1559
EXPORT_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 ,
1561
1561
struct extent_io_tree * tree ,
1562
1562
struct page * locked_page , u64 * start ,
1563
1563
u64 * end )
1564
1564
{
1565
1565
u64 max_bytes = BTRFS_MAX_EXTENT_SIZE ;
1566
1566
u64 delalloc_start ;
1567
1567
u64 delalloc_end ;
1568
- u64 found ;
1568
+ bool found ;
1569
1569
struct extent_state * cached_state = NULL ;
1570
1570
int ret ;
1571
1571
int loops = 0 ;
@@ -1580,7 +1580,7 @@ noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
1580
1580
* start = delalloc_start ;
1581
1581
* end = delalloc_end ;
1582
1582
free_extent_state (cached_state );
1583
- return 0 ;
1583
+ return false ;
1584
1584
}
1585
1585
1586
1586
/*
@@ -1612,7 +1612,7 @@ noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
1612
1612
loops = 1 ;
1613
1613
goto again ;
1614
1614
} else {
1615
- found = 0 ;
1615
+ found = false ;
1616
1616
goto out_failed ;
1617
1617
}
1618
1618
}
@@ -3195,19 +3195,19 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode,
3195
3195
{
3196
3196
struct extent_io_tree * tree = & BTRFS_I (inode )-> io_tree ;
3197
3197
u64 page_end = delalloc_start + PAGE_SIZE - 1 ;
3198
- u64 nr_delalloc ;
3198
+ bool found ;
3199
3199
u64 delalloc_to_write = 0 ;
3200
3200
u64 delalloc_end = 0 ;
3201
3201
int ret ;
3202
3202
int page_started = 0 ;
3203
3203
3204
3204
3205
3205
while (delalloc_end < page_end ) {
3206
- nr_delalloc = find_lock_delalloc_range (inode , tree ,
3206
+ found = find_lock_delalloc_range (inode , tree ,
3207
3207
page ,
3208
3208
& delalloc_start ,
3209
3209
& delalloc_end );
3210
- if (nr_delalloc == 0 ) {
3210
+ if (! found ) {
3211
3211
delalloc_start = delalloc_end + 1 ;
3212
3212
continue ;
3213
3213
}
0 commit comments