Skip to content

Commit b8ae2bf

Browse files
Li Zetaokdave
authored andcommitted
btrfs: convert try_release_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. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0145aa3 commit b8ae2bf

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static bool btree_release_folio(struct folio *folio, gfp_t gfp_flags)
525525
if (folio_test_writeback(folio) || folio_test_dirty(folio))
526526
return false;
527527

528-
return try_release_extent_buffer(&folio->page);
528+
return try_release_extent_buffer(folio);
529529
}
530530

531531
static void btree_invalidate_folio(struct folio *folio, size_t offset,

fs/btrfs/extent_io.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,21 +4147,20 @@ static int try_release_subpage_extent_buffer(struct folio *folio)
41474147

41484148
}
41494149

4150-
int try_release_extent_buffer(struct page *page)
4150+
int try_release_extent_buffer(struct folio *folio)
41514151
{
4152-
struct folio *folio = page_folio(page);
41534152
struct extent_buffer *eb;
41544153

4155-
if (page_to_fs_info(page)->nodesize < PAGE_SIZE)
4156-
return try_release_subpage_extent_buffer(page_folio(page));
4154+
if (folio_to_fs_info(folio)->nodesize < PAGE_SIZE)
4155+
return try_release_subpage_extent_buffer(folio);
41574156

41584157
/*
41594158
* We need to make sure nobody is changing folio private, as we rely on
41604159
* folio private as the pointer to extent buffer.
41614160
*/
4162-
spin_lock(&page->mapping->i_private_lock);
4161+
spin_lock(&folio->mapping->i_private_lock);
41634162
if (!folio_test_private(folio)) {
4164-
spin_unlock(&page->mapping->i_private_lock);
4163+
spin_unlock(&folio->mapping->i_private_lock);
41654164
return 1;
41664165
}
41674166

@@ -4176,10 +4175,10 @@ int try_release_extent_buffer(struct page *page)
41764175
spin_lock(&eb->refs_lock);
41774176
if (atomic_read(&eb->refs) != 1 || extent_buffer_under_io(eb)) {
41784177
spin_unlock(&eb->refs_lock);
4179-
spin_unlock(&page->mapping->i_private_lock);
4178+
spin_unlock(&folio->mapping->i_private_lock);
41804179
return 0;
41814180
}
4182-
spin_unlock(&page->mapping->i_private_lock);
4181+
spin_unlock(&folio->mapping->i_private_lock);
41834182

41844183
/*
41854184
* If tree ref isn't set then we know the ref on this eb is a real ref,

fs/btrfs/extent_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static inline void extent_changeset_free(struct extent_changeset *changeset)
237237
}
238238

239239
bool try_release_extent_mapping(struct page *page, gfp_t mask);
240-
int try_release_extent_buffer(struct page *page);
240+
int try_release_extent_buffer(struct folio *folio);
241241

242242
int btrfs_read_folio(struct file *file, struct folio *folio);
243243
void extent_write_locked_range(struct inode *inode, const struct folio *locked_folio,

0 commit comments

Comments
 (0)