Skip to content

Commit 5c5948a

Browse files
fdmananakdave
authored andcommitted
btrfs: add btrfs prefix to main lock, try lock and unlock extent functions
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 prefix to their name. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent dc2a609 commit 5c5948a

16 files changed

+152
-151
lines changed

fs/btrfs/compression.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
499499
}
500500

501501
page_end = (pg_index << PAGE_SHIFT) + folio_size(folio) - 1;
502-
lock_extent(tree, cur, page_end, NULL);
502+
btrfs_lock_extent(tree, cur, page_end, NULL);
503503
read_lock(&em_tree->lock);
504504
em = lookup_extent_mapping(em_tree, cur, page_end + 1 - cur);
505505
read_unlock(&em_tree->lock);
@@ -514,14 +514,14 @@ static noinline int add_ra_bio_pages(struct inode *inode,
514514
(extent_map_block_start(em) >> SECTOR_SHIFT) !=
515515
orig_bio->bi_iter.bi_sector) {
516516
free_extent_map(em);
517-
unlock_extent(tree, cur, page_end, NULL);
517+
btrfs_unlock_extent(tree, cur, page_end, NULL);
518518
folio_unlock(folio);
519519
folio_put(folio);
520520
break;
521521
}
522522
add_size = min(em->start + em->len, page_end + 1) - cur;
523523
free_extent_map(em);
524-
unlock_extent(tree, cur, page_end, NULL);
524+
btrfs_unlock_extent(tree, cur, page_end, NULL);
525525

526526
if (folio_contains(folio, end_index)) {
527527
size_t zero_offset = offset_in_folio(folio, isize);

fs/btrfs/defrag.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,10 @@ static struct extent_map *defrag_lookup_extent(struct inode *inode, u64 start,
776776

777777
/* Get the big lock and read metadata off disk. */
778778
if (!locked)
779-
lock_extent(io_tree, start, end, &cached);
779+
btrfs_lock_extent(io_tree, start, end, &cached);
780780
em = defrag_get_extent(BTRFS_I(inode), start, newer_than);
781781
if (!locked)
782-
unlock_extent(io_tree, start, end, &cached);
782+
btrfs_unlock_extent(io_tree, start, end, &cached);
783783

784784
if (IS_ERR(em))
785785
return NULL;
@@ -891,10 +891,10 @@ static struct folio *defrag_prepare_one_folio(struct btrfs_inode *inode, pgoff_t
891891
while (1) {
892892
struct btrfs_ordered_extent *ordered;
893893

894-
lock_extent(&inode->io_tree, page_start, page_end, &cached_state);
894+
btrfs_lock_extent(&inode->io_tree, page_start, page_end, &cached_state);
895895
ordered = btrfs_lookup_ordered_range(inode, page_start, PAGE_SIZE);
896-
unlock_extent(&inode->io_tree, page_start, page_end,
897-
&cached_state);
896+
btrfs_unlock_extent(&inode->io_tree, page_start, page_end,
897+
&cached_state);
898898
if (!ordered)
899899
break;
900900

@@ -1223,9 +1223,9 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,
12231223
folio_wait_writeback(folios[i]);
12241224

12251225
/* Lock the pages range */
1226-
lock_extent(&inode->io_tree, start_index << PAGE_SHIFT,
1227-
(last_index << PAGE_SHIFT) + PAGE_SIZE - 1,
1228-
&cached_state);
1226+
btrfs_lock_extent(&inode->io_tree, start_index << PAGE_SHIFT,
1227+
(last_index << PAGE_SHIFT) + PAGE_SIZE - 1,
1228+
&cached_state);
12291229
/*
12301230
* Now we have a consistent view about the extent map, re-check
12311231
* which range really needs to be defragged.
@@ -1251,9 +1251,9 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,
12511251
kfree(entry);
12521252
}
12531253
unlock_extent:
1254-
unlock_extent(&inode->io_tree, start_index << PAGE_SHIFT,
1255-
(last_index << PAGE_SHIFT) + PAGE_SIZE - 1,
1256-
&cached_state);
1254+
btrfs_unlock_extent(&inode->io_tree, start_index << PAGE_SHIFT,
1255+
(last_index << PAGE_SHIFT) + PAGE_SIZE - 1,
1256+
&cached_state);
12571257
free_folios:
12581258
for (i = 0; i < nr_pages; i++) {
12591259
folio_unlock(folios[i]);

fs/btrfs/direct-io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ static int lock_extent_direct(struct inode *inode, u64 lockstart, u64 lockend,
5050

5151
while (1) {
5252
if (nowait) {
53-
if (!try_lock_extent(io_tree, lockstart, lockend,
54-
cached_state)) {
53+
if (!btrfs_try_lock_extent(io_tree, lockstart, lockend,
54+
cached_state)) {
5555
ret = -EAGAIN;
5656
break;
5757
}
5858
} else {
59-
lock_extent(io_tree, lockstart, lockend, cached_state);
59+
btrfs_lock_extent(io_tree, lockstart, lockend, cached_state);
6060
}
6161
/*
6262
* We're concerned with the entire range that we're going to be
@@ -78,7 +78,7 @@ static int lock_extent_direct(struct inode *inode, u64 lockstart, u64 lockend,
7878
lockstart, lockend)))
7979
break;
8080

81-
unlock_extent(io_tree, lockstart, lockend, cached_state);
81+
btrfs_unlock_extent(io_tree, lockstart, lockend, cached_state);
8282

8383
if (ordered) {
8484
if (nowait) {

fs/btrfs/extent-io-tree.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ int __lock_extent(struct extent_io_tree *tree, u64 start, u64 end, u32 bits,
145145
bool __try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, u32 bits,
146146
struct extent_state **cached);
147147

148-
static inline int lock_extent(struct extent_io_tree *tree, u64 start, u64 end,
149-
struct extent_state **cached)
148+
static inline int btrfs_lock_extent(struct extent_io_tree *tree, u64 start, u64 end,
149+
struct extent_state **cached)
150150
{
151151
return __lock_extent(tree, start, end, EXTENT_LOCKED, cached);
152152
}
153153

154-
static inline bool try_lock_extent(struct extent_io_tree *tree, u64 start,
155-
u64 end, struct extent_state **cached)
154+
static inline bool btrfs_try_lock_extent(struct extent_io_tree *tree, u64 start,
155+
u64 end, struct extent_state **cached)
156156
{
157157
return __try_lock_extent(tree, start, end, EXTENT_LOCKED, cached);
158158
}
@@ -184,8 +184,8 @@ static inline int clear_extent_bit(struct extent_io_tree *tree, u64 start,
184184
return __clear_extent_bit(tree, start, end, bits, cached, NULL);
185185
}
186186

187-
static inline int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end,
188-
struct extent_state **cached)
187+
static inline int btrfs_unlock_extent(struct extent_io_tree *tree, u64 start, u64 end,
188+
struct extent_state **cached)
189189
{
190190
return __clear_extent_bit(tree, start, end, EXTENT_LOCKED, cached, NULL);
191191
}

fs/btrfs/extent_io.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
369369
}
370370

371371
/* step three, lock the state bits for the whole range */
372-
lock_extent(tree, delalloc_start, delalloc_end, &cached_state);
372+
btrfs_lock_extent(tree, delalloc_start, delalloc_end, &cached_state);
373373

374374
/* then test to make sure it is all still delalloc */
375375
ret = test_range_bit(tree, delalloc_start, delalloc_end,
376376
EXTENT_DELALLOC, cached_state);
377377

378-
unlock_extent(tree, delalloc_start, delalloc_end, &cached_state);
378+
btrfs_unlock_extent(tree, delalloc_start, delalloc_end, &cached_state);
379379
if (!ret) {
380380
unlock_delalloc_folio(inode, locked_folio, delalloc_start,
381381
delalloc_end);
@@ -1199,7 +1199,7 @@ static void lock_extents_for_read(struct btrfs_inode *inode, u64 start, u64 end,
11991199
ASSERT(IS_ALIGNED(end + 1, PAGE_SIZE));
12001200

12011201
again:
1202-
lock_extent(&inode->io_tree, start, end, cached_state);
1202+
btrfs_lock_extent(&inode->io_tree, start, end, cached_state);
12031203
cur_pos = start;
12041204
while (cur_pos < end) {
12051205
struct btrfs_ordered_extent *ordered;
@@ -1222,7 +1222,7 @@ static void lock_extents_for_read(struct btrfs_inode *inode, u64 start, u64 end,
12221222
}
12231223

12241224
/* Now wait for the OE to finish. */
1225-
unlock_extent(&inode->io_tree, start, end, cached_state);
1225+
btrfs_unlock_extent(&inode->io_tree, start, end, cached_state);
12261226
btrfs_start_ordered_extent_nowriteback(ordered, start, end + 1 - start);
12271227
btrfs_put_ordered_extent(ordered);
12281228
/* We have unlocked the whole range, restart from the beginning. */
@@ -1242,7 +1242,7 @@ int btrfs_read_folio(struct file *file, struct folio *folio)
12421242

12431243
lock_extents_for_read(inode, start, end, &cached_state);
12441244
ret = btrfs_do_readpage(folio, &em_cached, &bio_ctrl, NULL);
1245-
unlock_extent(&inode->io_tree, start, end, &cached_state);
1245+
btrfs_unlock_extent(&inode->io_tree, start, end, &cached_state);
12461246

12471247
free_extent_map(em_cached);
12481248

@@ -1430,8 +1430,8 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,
14301430
* We've hit an error during previous delalloc range,
14311431
* have to cleanup the remaining locked ranges.
14321432
*/
1433-
unlock_extent(&inode->io_tree, found_start,
1434-
found_start + found_len - 1, NULL);
1433+
btrfs_unlock_extent(&inode->io_tree, found_start,
1434+
found_start + found_len - 1, NULL);
14351435
unlock_delalloc_folio(&inode->vfs_inode, folio,
14361436
found_start,
14371437
found_start + found_len - 1);
@@ -2561,7 +2561,7 @@ void btrfs_readahead(struct readahead_control *rac)
25612561
while ((folio = readahead_folio(rac)) != NULL)
25622562
btrfs_do_readpage(folio, &em_cached, &bio_ctrl, &prev_em_start);
25632563

2564-
unlock_extent(&inode->io_tree, start, end, &cached_state);
2564+
btrfs_unlock_extent(&inode->io_tree, start, end, &cached_state);
25652565

25662566
if (em_cached)
25672567
free_extent_map(em_cached);
@@ -2588,15 +2588,15 @@ int extent_invalidate_folio(struct extent_io_tree *tree,
25882588
if (start > end)
25892589
return 0;
25902590

2591-
lock_extent(tree, start, end, &cached_state);
2591+
btrfs_lock_extent(tree, start, end, &cached_state);
25922592
folio_wait_writeback(folio);
25932593

25942594
/*
25952595
* Currently for btree io tree, only EXTENT_LOCKED is utilized,
25962596
* so here we only need to unlock the extent range to free any
25972597
* existing extent state.
25982598
*/
2599-
unlock_extent(tree, start, end, &cached_state);
2599+
btrfs_unlock_extent(tree, start, end, &cached_state);
26002600
return 0;
26012601
}
26022602

fs/btrfs/extent_map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ int split_extent_map(struct btrfs_inode *inode, u64 start, u64 len, u64 pre,
10551055
goto out_free_pre;
10561056
}
10571057

1058-
lock_extent(&inode->io_tree, start, start + len - 1, NULL);
1058+
btrfs_lock_extent(&inode->io_tree, start, start + len - 1, NULL);
10591059
write_lock(&em_tree->lock);
10601060
em = lookup_extent_mapping(em_tree, start, len);
10611061
if (!em) {
@@ -1108,7 +1108,7 @@ int split_extent_map(struct btrfs_inode *inode, u64 start, u64 len, u64 pre,
11081108

11091109
out_unlock:
11101110
write_unlock(&em_tree->lock);
1111-
unlock_extent(&inode->io_tree, start, start + len - 1, NULL);
1111+
btrfs_unlock_extent(&inode->io_tree, start, start + len - 1, NULL);
11121112
free_extent_map(split_mid);
11131113
out_free_pre:
11141114
free_extent_map(split_pre);

fs/btrfs/fiemap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static int extent_fiemap(struct btrfs_inode *inode,
661661
range_end = round_up(start + len, sectorsize);
662662
prev_extent_end = range_start;
663663

664-
lock_extent(&inode->io_tree, range_start, range_end, &cached_state);
664+
btrfs_lock_extent(&inode->io_tree, range_start, range_end, &cached_state);
665665

666666
ret = fiemap_find_last_extent_offset(inode, path, &last_extent_end);
667667
if (ret < 0)
@@ -841,7 +841,7 @@ static int extent_fiemap(struct btrfs_inode *inode,
841841
}
842842

843843
out_unlock:
844-
unlock_extent(&inode->io_tree, range_start, range_end, &cached_state);
844+
btrfs_unlock_extent(&inode->io_tree, range_start, range_end, &cached_state);
845845

846846
if (ret == BTRFS_FIEMAP_FLUSH_CACHE) {
847847
btrfs_release_path(path);

0 commit comments

Comments
 (0)