Skip to content

Commit 0145aa3

Browse files
Li Zetaokdave
authored andcommitted
btrfs: convert try_release_subpage_extent_buffer() to take a folio
The old page API is being gradually replaced and converted to use folio to improve code readability and avoid repeated conversion between page and folio. And use folio_pos instead of page_offset, which is more consistent with folio usage. At the same time, folio_test_private() can handle folio directly without converting from page to folio first. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent d4aeb5f commit 0145aa3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fs/btrfs/extent_io.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,11 +4077,11 @@ static struct extent_buffer *get_next_extent_buffer(
40774077
return found;
40784078
}
40794079

4080-
static int try_release_subpage_extent_buffer(struct page *page)
4080+
static int try_release_subpage_extent_buffer(struct folio *folio)
40814081
{
4082-
struct btrfs_fs_info *fs_info = page_to_fs_info(page);
4083-
u64 cur = page_offset(page);
4084-
const u64 end = page_offset(page) + PAGE_SIZE;
4082+
struct btrfs_fs_info *fs_info = folio_to_fs_info(folio);
4083+
u64 cur = folio_pos(folio);
4084+
const u64 end = cur + PAGE_SIZE;
40854085
int ret;
40864086

40874087
while (cur < end) {
@@ -4096,7 +4096,7 @@ static int try_release_subpage_extent_buffer(struct page *page)
40964096
* with spinlock rather than RCU.
40974097
*/
40984098
spin_lock(&fs_info->buffer_lock);
4099-
eb = get_next_extent_buffer(fs_info, page_folio(page), cur);
4099+
eb = get_next_extent_buffer(fs_info, folio, cur);
41004100
if (!eb) {
41014101
/* No more eb in the page range after or at cur */
41024102
spin_unlock(&fs_info->buffer_lock);
@@ -4137,12 +4137,12 @@ static int try_release_subpage_extent_buffer(struct page *page)
41374137
* Finally to check if we have cleared folio private, as if we have
41384138
* released all ebs in the page, the folio private should be cleared now.
41394139
*/
4140-
spin_lock(&page->mapping->i_private_lock);
4141-
if (!folio_test_private(page_folio(page)))
4140+
spin_lock(&folio->mapping->i_private_lock);
4141+
if (!folio_test_private(folio))
41424142
ret = 1;
41434143
else
41444144
ret = 0;
4145-
spin_unlock(&page->mapping->i_private_lock);
4145+
spin_unlock(&folio->mapping->i_private_lock);
41464146
return ret;
41474147

41484148
}
@@ -4153,7 +4153,7 @@ int try_release_extent_buffer(struct page *page)
41534153
struct extent_buffer *eb;
41544154

41554155
if (page_to_fs_info(page)->nodesize < PAGE_SIZE)
4156-
return try_release_subpage_extent_buffer(page);
4156+
return try_release_subpage_extent_buffer(page_folio(page));
41574157

41584158
/*
41594159
* We need to make sure nobody is changing folio private, as we rely on

0 commit comments

Comments
 (0)