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].
Unified · Split
| @@ -253,6 +253,20 @@ static inline struct address_space *page_mapping_file(struct page *page) · 252 unmodified lines | ||
| 253 | 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 | 270 | static inline bool page_cache_add_speculative(struct page *page, int count) |
| 257 | 271 | { |
| 258 | 272 | VM_BUG_ON_PAGE(PageTail(page), page); |
| @@ -2967,7 +2967,7 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); · 2966 unmodified lines | ||
| 2967 | 2967 | */ |
| 2968 | 2968 | void folio_wait_stable(struct folio *folio) |
| 2969 | 2969 | { |
| 2970 | − if (folio->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES) | |
| 2970 | + if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) | |
| 2971 | 2971 | folio_wait_writeback(folio); |
| 2972 | 2972 | } |
| 2973 | 2973 | EXPORT_SYMBOL_GPL(folio_wait_stable); |