Skip to content

Commit

Permalink
hugetlb: Convert huge_add_to_page_cache() to use a folio
Browse files Browse the repository at this point in the history
Remove the last caller of add_to_page_cache()

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
Reviewed-by: Muchun Song <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) committed Jun 29, 2022
1 parent 211d044 commit d9ef44d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,

SetHPageMigratable(page);
/*
* unlock_page because locked by add_to_page_cache()
* unlock_page because locked by huge_add_to_page_cache()
* put_page() due to reference from alloc_huge_page()
*/
unlock_page(page);
Expand Down
14 changes: 10 additions & 4 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5414,19 +5414,25 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
pgoff_t idx)
{
struct folio *folio = page_folio(page);
struct inode *inode = mapping->host;
struct hstate *h = hstate_inode(inode);
int err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
int err;

if (err)
__folio_set_locked(folio);
err = __filemap_add_folio(mapping, folio, idx, GFP_KERNEL, NULL);

if (unlikely(err)) {
__folio_clear_locked(folio);
return err;
}
ClearHPageRestoreReserve(page);

/*
* set page dirty so that it will not be removed from cache/file
* mark folio dirty so that it will not be removed from cache/file
* by non-hugetlbfs specific code paths.
*/
set_page_dirty(page);
folio_mark_dirty(folio);

spin_lock(&inode->i_lock);
inode->i_blocks += blocks_per_huge_page(h);
Expand Down

0 comments on commit d9ef44d

Please sign in to comment.