Commit d4aeb5f7 authored by Li Zetao's avatar Li Zetao Committed by David Sterba

btrfs: convert get_next_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. Use folio_pos instead of page_offset, which is more
consistent with folio usage.
Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 266a9361
...@@ -4041,17 +4041,17 @@ void memmove_extent_buffer(const struct extent_buffer *dst, ...@@ -4041,17 +4041,17 @@ void memmove_extent_buffer(const struct extent_buffer *dst,
#define GANG_LOOKUP_SIZE 16 #define GANG_LOOKUP_SIZE 16
static struct extent_buffer *get_next_extent_buffer( static struct extent_buffer *get_next_extent_buffer(
const struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr) const struct btrfs_fs_info *fs_info, struct folio *folio, u64 bytenr)
{ {
struct extent_buffer *gang[GANG_LOOKUP_SIZE]; struct extent_buffer *gang[GANG_LOOKUP_SIZE];
struct extent_buffer *found = NULL; struct extent_buffer *found = NULL;
u64 page_start = page_offset(page); u64 folio_start = folio_pos(folio);
u64 cur = page_start; u64 cur = folio_start;
ASSERT(in_range(bytenr, page_start, PAGE_SIZE)); ASSERT(in_range(bytenr, folio_start, PAGE_SIZE));
lockdep_assert_held(&fs_info->buffer_lock); lockdep_assert_held(&fs_info->buffer_lock);
while (cur < page_start + PAGE_SIZE) { while (cur < folio_start + PAGE_SIZE) {
int ret; int ret;
int i; int i;
...@@ -4063,7 +4063,7 @@ static struct extent_buffer *get_next_extent_buffer( ...@@ -4063,7 +4063,7 @@ static struct extent_buffer *get_next_extent_buffer(
goto out; goto out;
for (i = 0; i < ret; i++) { for (i = 0; i < ret; i++) {
/* Already beyond page end */ /* Already beyond page end */
if (gang[i]->start >= page_start + PAGE_SIZE) if (gang[i]->start >= folio_start + PAGE_SIZE)
goto out; goto out;
/* Found one */ /* Found one */
if (gang[i]->start >= bytenr) { if (gang[i]->start >= bytenr) {
...@@ -4096,7 +4096,7 @@ static int try_release_subpage_extent_buffer(struct page *page) ...@@ -4096,7 +4096,7 @@ static int try_release_subpage_extent_buffer(struct page *page)
* with spinlock rather than RCU. * with spinlock rather than RCU.
*/ */
spin_lock(&fs_info->buffer_lock); spin_lock(&fs_info->buffer_lock);
eb = get_next_extent_buffer(fs_info, page, cur); eb = get_next_extent_buffer(fs_info, page_folio(page), cur);
if (!eb) { if (!eb) {
/* No more eb in the page range after or at cur */ /* No more eb in the page range after or at cur */
spin_unlock(&fs_info->buffer_lock); spin_unlock(&fs_info->buffer_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment