Skip to content

Commit 9d05b11

Browse files
fdmananakdave
authored andcommitted
btrfs: rename the functions to search for bits in extent ranges
These functions are exported so they should have a 'btrfs_' prefix by convention, to make it clear they are btrfs specific and to avoid collisions with functions from elsewhere in the kernel. So add a 'btrfs_' prefix to their name to make it clear they are from btrfs. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 266914f commit 9d05b11

12 files changed

+59
-58
lines changed

fs/btrfs/block-group.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ int btrfs_add_new_free_space(struct btrfs_block_group *block_group, u64 start,
525525
*total_added_ret = 0;
526526

527527
while (start < end) {
528-
if (!find_first_extent_bit(&info->excluded_extents, start,
529-
&extent_start, &extent_end,
530-
EXTENT_DIRTY, NULL))
528+
if (!btrfs_find_first_extent_bit(&info->excluded_extents, start,
529+
&extent_start, &extent_end,
530+
EXTENT_DIRTY, NULL))
531531
break;
532532

533533
if (extent_start <= start) {

fs/btrfs/dev-replace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,9 @@ static int btrfs_set_target_alloc_state(struct btrfs_device *srcdev,
794794

795795
lockdep_assert_held(&srcdev->fs_info->chunk_mutex);
796796

797-
while (find_first_extent_bit(&srcdev->alloc_state, start,
798-
&found_start, &found_end,
799-
CHUNK_ALLOCATED, &cached_state)) {
797+
while (btrfs_find_first_extent_bit(&srcdev->alloc_state, start,
798+
&found_start, &found_end,
799+
CHUNK_ALLOCATED, &cached_state)) {
800800
ret = btrfs_set_extent_bit(&tgtdev->alloc_state, found_start,
801801
found_end, CHUNK_ALLOCATED, NULL);
802802
if (ret)

fs/btrfs/disk-io.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4237,8 +4237,9 @@ static void warn_about_uncommitted_trans(struct btrfs_fs_info *fs_info)
42374237
u64 found_end;
42384238

42394239
found = true;
4240-
while (find_first_extent_bit(&trans->dirty_pages, cur,
4241-
&found_start, &found_end, EXTENT_DIRTY, &cached)) {
4240+
while (btrfs_find_first_extent_bit(&trans->dirty_pages, cur,
4241+
&found_start, &found_end,
4242+
EXTENT_DIRTY, &cached)) {
42424243
dirty_bytes += found_end + 1 - found_start;
42434244
cur = found_end + 1;
42444245
}
@@ -4691,8 +4692,8 @@ static void btrfs_destroy_marked_extents(struct btrfs_fs_info *fs_info,
46914692
u64 start = 0;
46924693
u64 end;
46934694

4694-
while (find_first_extent_bit(dirty_pages, start, &start, &end,
4695-
mark, NULL)) {
4695+
while (btrfs_find_first_extent_bit(dirty_pages, start, &start, &end,
4696+
mark, NULL)) {
46964697
btrfs_clear_extent_bits(dirty_pages, start, end, mark);
46974698
while (start <= end) {
46984699
eb = find_extent_buffer(fs_info, start);
@@ -4726,8 +4727,8 @@ static void btrfs_destroy_pinned_extent(struct btrfs_fs_info *fs_info,
47264727
* the same extent range.
47274728
*/
47284729
mutex_lock(&fs_info->unused_bg_unpin_mutex);
4729-
if (!find_first_extent_bit(unpin, 0, &start, &end,
4730-
EXTENT_DIRTY, &cached_state)) {
4730+
if (!btrfs_find_first_extent_bit(unpin, 0, &start, &end,
4731+
EXTENT_DIRTY, &cached_state)) {
47314732
mutex_unlock(&fs_info->unused_bg_unpin_mutex);
47324733
break;
47334734
}

fs/btrfs/extent-io-tree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,9 @@ static struct extent_state *find_first_extent_bit_state(struct extent_io_tree *t
869869
* Return true if we find something, and update @start_ret and @end_ret.
870870
* Return false if we found nothing.
871871
*/
872-
bool find_first_extent_bit(struct extent_io_tree *tree, u64 start,
873-
u64 *start_ret, u64 *end_ret, u32 bits,
874-
struct extent_state **cached_state)
872+
bool btrfs_find_first_extent_bit(struct extent_io_tree *tree, u64 start,
873+
u64 *start_ret, u64 *end_ret, u32 bits,
874+
struct extent_state **cached_state)
875875
{
876876
struct extent_state *state;
877877
bool ret = false;
@@ -930,8 +930,8 @@ bool find_first_extent_bit(struct extent_io_tree *tree, u64 start,
930930
* then walk down the tree until we find a non-contiguous area. The area
931931
* returned will be the full contiguous area with the bits set.
932932
*/
933-
int find_contiguous_extent_bit(struct extent_io_tree *tree, u64 start,
934-
u64 *start_ret, u64 *end_ret, u32 bits)
933+
int btrfs_find_contiguous_extent_bit(struct extent_io_tree *tree, u64 start,
934+
u64 *start_ret, u64 *end_ret, u32 bits)
935935
{
936936
struct extent_state *state;
937937
int ret = 1;
@@ -1495,8 +1495,8 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
14951495
* spans (last_range_end, end of device]. In this case it's up to the caller to
14961496
* trim @end_ret to the appropriate size.
14971497
*/
1498-
void find_first_clear_extent_bit(struct extent_io_tree *tree, u64 start,
1499-
u64 *start_ret, u64 *end_ret, u32 bits)
1498+
void btrfs_find_first_clear_extent_bit(struct extent_io_tree *tree, u64 start,
1499+
u64 *start_ret, u64 *end_ret, u32 bits)
15001500
{
15011501
struct extent_state *state;
15021502
struct extent_state *prev = NULL, *next = NULL;

fs/btrfs/extent-io-tree.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
214214
u32 bits, u32 clear_bits,
215215
struct extent_state **cached_state);
216216

217-
bool find_first_extent_bit(struct extent_io_tree *tree, u64 start,
218-
u64 *start_ret, u64 *end_ret, u32 bits,
219-
struct extent_state **cached_state);
220-
void find_first_clear_extent_bit(struct extent_io_tree *tree, u64 start,
221-
u64 *start_ret, u64 *end_ret, u32 bits);
222-
int find_contiguous_extent_bit(struct extent_io_tree *tree, u64 start,
223-
u64 *start_ret, u64 *end_ret, u32 bits);
217+
bool btrfs_find_first_extent_bit(struct extent_io_tree *tree, u64 start,
218+
u64 *start_ret, u64 *end_ret, u32 bits,
219+
struct extent_state **cached_state);
220+
void btrfs_find_first_clear_extent_bit(struct extent_io_tree *tree, u64 start,
221+
u64 *start_ret, u64 *end_ret, u32 bits);
222+
int btrfs_find_contiguous_extent_bit(struct extent_io_tree *tree, u64 start,
223+
u64 *start_ret, u64 *end_ret, u32 bits);
224224
bool btrfs_find_delalloc_range(struct extent_io_tree *tree, u64 *start,
225225
u64 *end, u64 max_bytes,
226226
struct extent_state **cached_state);

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,8 +2829,8 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans)
28292829
struct extent_state *cached_state = NULL;
28302830

28312831
mutex_lock(&fs_info->unused_bg_unpin_mutex);
2832-
if (!find_first_extent_bit(unpin, 0, &start, &end,
2833-
EXTENT_DIRTY, &cached_state)) {
2832+
if (!btrfs_find_first_extent_bit(unpin, 0, &start, &end,
2833+
EXTENT_DIRTY, &cached_state)) {
28342834
mutex_unlock(&fs_info->unused_bg_unpin_mutex);
28352835
break;
28362836
}
@@ -6391,9 +6391,9 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed)
63916391
if (ret)
63926392
break;
63936393

6394-
find_first_clear_extent_bit(&device->alloc_state, start,
6395-
&start, &end,
6396-
CHUNK_TRIMMED | CHUNK_ALLOCATED);
6394+
btrfs_find_first_clear_extent_bit(&device->alloc_state, start,
6395+
&start, &end,
6396+
CHUNK_TRIMMED | CHUNK_ALLOCATED);
63976397

63986398
/* Check if there are any CHUNK_* bits left */
63996399
if (start > device->total_bytes) {

fs/btrfs/file-item.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_siz
5555
goto out_unlock;
5656
}
5757

58-
ret = find_contiguous_extent_bit(inode->file_extent_tree, 0, &start,
59-
&end, EXTENT_DIRTY);
58+
ret = btrfs_find_contiguous_extent_bit(inode->file_extent_tree, 0, &start,
59+
&end, EXTENT_DIRTY);
6060
if (!ret && start == 0)
6161
i_size = min(i_size, end + 1);
6262
else

fs/btrfs/free-space-cache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,9 +1219,9 @@ static noinline_for_stack int write_pinned_extent_entries(
12191219
start = block_group->start;
12201220

12211221
while (start < block_group->start + block_group->length) {
1222-
if (!find_first_extent_bit(unpin, start,
1223-
&extent_start, &extent_end,
1224-
EXTENT_DIRTY, NULL))
1222+
if (!btrfs_find_first_extent_bit(unpin, start,
1223+
&extent_start, &extent_end,
1224+
EXTENT_DIRTY, NULL))
12251225
return 0;
12261226

12271227
/* This pinned extent is out of our range */

fs/btrfs/relocation.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,9 +3433,9 @@ int find_next_extent(struct reloc_control *rc, struct btrfs_path *path,
34333433
goto next;
34343434
}
34353435

3436-
block_found = find_first_extent_bit(&rc->processed_blocks,
3437-
key.objectid, &start, &end,
3438-
EXTENT_DIRTY, NULL);
3436+
block_found = btrfs_find_first_extent_bit(&rc->processed_blocks,
3437+
key.objectid, &start, &end,
3438+
EXTENT_DIRTY, NULL);
34393439

34403440
if (block_found && start <= key.objectid) {
34413441
btrfs_release_path(path);

fs/btrfs/tests/extent-io-tests.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int test_find_first_clear_extent_bit(void)
566566
extent_io_tree_init(NULL, &tree, IO_TREE_SELFTEST);
567567

568568
/* Test correct handling of empty tree */
569-
find_first_clear_extent_bit(&tree, 0, &start, &end, CHUNK_TRIMMED);
569+
btrfs_find_first_clear_extent_bit(&tree, 0, &start, &end, CHUNK_TRIMMED);
570570
if (start != 0 || end != -1) {
571571
test_err(
572572
"error getting a range from completely empty tree: start %llu end %llu",
@@ -580,8 +580,8 @@ static int test_find_first_clear_extent_bit(void)
580580
btrfs_set_extent_bit(&tree, SZ_1M, SZ_4M - 1,
581581
CHUNK_TRIMMED | CHUNK_ALLOCATED, NULL);
582582

583-
find_first_clear_extent_bit(&tree, SZ_512K, &start, &end,
584-
CHUNK_TRIMMED | CHUNK_ALLOCATED);
583+
btrfs_find_first_clear_extent_bit(&tree, SZ_512K, &start, &end,
584+
CHUNK_TRIMMED | CHUNK_ALLOCATED);
585585

586586
if (start != 0 || end != SZ_1M - 1) {
587587
test_err("error finding beginning range: start %llu end %llu",
@@ -596,8 +596,8 @@ static int test_find_first_clear_extent_bit(void)
596596
/*
597597
* Request first hole starting at 12M, we should get 4M-32M
598598
*/
599-
find_first_clear_extent_bit(&tree, 12 * SZ_1M, &start, &end,
600-
CHUNK_TRIMMED | CHUNK_ALLOCATED);
599+
btrfs_find_first_clear_extent_bit(&tree, 12 * SZ_1M, &start, &end,
600+
CHUNK_TRIMMED | CHUNK_ALLOCATED);
601601

602602
if (start != SZ_4M || end != SZ_32M - 1) {
603603
test_err("error finding trimmed range: start %llu end %llu",
@@ -609,8 +609,8 @@ static int test_find_first_clear_extent_bit(void)
609609
* Search in the middle of allocated range, should get the next one
610610
* available, which happens to be unallocated -> 4M-32M
611611
*/
612-
find_first_clear_extent_bit(&tree, SZ_2M, &start, &end,
613-
CHUNK_TRIMMED | CHUNK_ALLOCATED);
612+
btrfs_find_first_clear_extent_bit(&tree, SZ_2M, &start, &end,
613+
CHUNK_TRIMMED | CHUNK_ALLOCATED);
614614

615615
if (start != SZ_4M || end != SZ_32M - 1) {
616616
test_err("error finding next unalloc range: start %llu end %llu",
@@ -623,17 +623,17 @@ static int test_find_first_clear_extent_bit(void)
623623
* being unset in this range, we should get the entry in range 64M-72M
624624
*/
625625
btrfs_set_extent_bit(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED, NULL);
626-
find_first_clear_extent_bit(&tree, SZ_64M + SZ_1M, &start, &end,
627-
CHUNK_TRIMMED);
626+
btrfs_find_first_clear_extent_bit(&tree, SZ_64M + SZ_1M, &start, &end,
627+
CHUNK_TRIMMED);
628628

629629
if (start != SZ_64M || end != SZ_64M + SZ_8M - 1) {
630630
test_err("error finding exact range: start %llu end %llu",
631631
start, end);
632632
goto out;
633633
}
634634

635-
find_first_clear_extent_bit(&tree, SZ_64M - SZ_8M, &start, &end,
636-
CHUNK_TRIMMED);
635+
btrfs_find_first_clear_extent_bit(&tree, SZ_64M - SZ_8M, &start, &end,
636+
CHUNK_TRIMMED);
637637

638638
/*
639639
* Search in the middle of set range whose immediate neighbour doesn't
@@ -649,7 +649,7 @@ static int test_find_first_clear_extent_bit(void)
649649
* Search beyond any known range, shall return after last known range
650650
* and end should be -1
651651
*/
652-
find_first_clear_extent_bit(&tree, -1, &start, &end, CHUNK_TRIMMED);
652+
btrfs_find_first_clear_extent_bit(&tree, -1, &start, &end, CHUNK_TRIMMED);
653653
if (start != SZ_64M + SZ_8M || end != -1) {
654654
test_err(
655655
"error handling beyond end of range search: start %llu end %llu",

0 commit comments

Comments
 (0)