Skip to content

Commit

Permalink
folio: Add a function to get the host inode for a folio
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowells committed Nov 10, 2021
1 parent a19672f commit 452c472
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions include/linux/pagemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ static inline struct address_space *page_mapping_file(struct page *page)
return folio_mapping(folio);
}

/**
* folio_inode - Get the host inode for this folio.
* @folio: The folio.
*
* For folios which are in the page cache, return the inode that this folio
* belongs to.
*
* Do not call this for folios which aren't in the page cache.
*/
static inline struct inode *folio_inode(struct folio *folio)
{
return folio->mapping->host;
}

static inline bool page_cache_add_speculative(struct page *page, int count)
{
VM_BUG_ON_PAGE(PageTail(page), page);
Expand Down
2 changes: 1 addition & 1 deletion mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -2967,7 +2967,7 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable);
*/
void folio_wait_stable(struct folio *folio)
{
if (folio->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES)
if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES)
folio_wait_writeback(folio);
}
EXPORT_SYMBOL_GPL(folio_wait_stable);

0 comments on commit 452c472

Please sign in to comment.