Add a convenience function, folio_inode() that will get the host inode from a folio's mapping. Changes: ver #3: - Fix mistake in function description[2]. ver #2: - Fix contradiction between doc and implementation by disallowing use with swap caches[1].
Showing the changes to include (1 of 2 files). Show all
Unified · Split
| @@ -253,6 +253,20 @@ static inline struct address_space *page_mapping_file(struct page *page) · 252 unmodified lines | |||
| 253 | return folio_mapping(folio); | 253 | return folio_mapping(folio); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | /** | ||
| 257 | * folio_inode - Get the host inode for this folio. | ||
| 258 | * @folio: The folio. | ||
| 259 | * | ||
| 260 | * For folios which are in the page cache, return the inode that this folio | ||
| 261 | * belongs to. | ||
| 262 | * | ||
| 263 | * Do not call this for folios which aren't in the page cache. | ||
| 264 | */ | ||
| 265 | static inline struct inode *folio_inode(struct folio *folio) | ||
| 266 | { | ||
| 267 | return folio->mapping->host; | ||
| 268 | } | ||
| 269 | |||
| 256 | static inline bool page_cache_add_speculative(struct page *page, int count) | 270 | static inline bool page_cache_add_speculative(struct page *page, int count) |
| 257 | { | 271 | { |
| 258 | VM_BUG_ON_PAGE(PageTail(page), page); | 272 | VM_BUG_ON_PAGE(PageTail(page), page); |