folio-compat.c (4024B)
1/* 2 * Compatibility functions which bloat the callers too much to make inline. 3 * All of the callers of these functions should be converted to use folios 4 * eventually. 5 */ 6 7#include <linux/migrate.h> 8#include <linux/pagemap.h> 9#include <linux/swap.h> 10#include "internal.h" 11 12struct address_space *page_mapping(struct page *page) 13{ 14 return folio_mapping(page_folio(page)); 15} 16EXPORT_SYMBOL(page_mapping); 17 18void unlock_page(struct page *page) 19{ 20 return folio_unlock(page_folio(page)); 21} 22EXPORT_SYMBOL(unlock_page); 23 24void end_page_writeback(struct page *page) 25{ 26 return folio_end_writeback(page_folio(page)); 27} 28EXPORT_SYMBOL(end_page_writeback); 29 30void wait_on_page_writeback(struct page *page) 31{ 32 return folio_wait_writeback(page_folio(page)); 33} 34EXPORT_SYMBOL_GPL(wait_on_page_writeback); 35 36void wait_for_stable_page(struct page *page) 37{ 38 return folio_wait_stable(page_folio(page)); 39} 40EXPORT_SYMBOL_GPL(wait_for_stable_page); 41 42bool page_mapped(struct page *page) 43{ 44 return folio_mapped(page_folio(page)); 45} 46EXPORT_SYMBOL(page_mapped); 47 48void mark_page_accessed(struct page *page) 49{ 50 folio_mark_accessed(page_folio(page)); 51} 52EXPORT_SYMBOL(mark_page_accessed); 53 54#ifdef CONFIG_MIGRATION 55int migrate_page_move_mapping(struct address_space *mapping, 56 struct page *newpage, struct page *page, int extra_count) 57{ 58 return folio_migrate_mapping(mapping, page_folio(newpage), 59 page_folio(page), extra_count); 60} 61EXPORT_SYMBOL(migrate_page_move_mapping); 62 63void migrate_page_states(struct page *newpage, struct page *page) 64{ 65 folio_migrate_flags(page_folio(newpage), page_folio(page)); 66} 67EXPORT_SYMBOL(migrate_page_states); 68 69void migrate_page_copy(struct page *newpage, struct page *page) 70{ 71 folio_migrate_copy(page_folio(newpage), page_folio(page)); 72} 73EXPORT_SYMBOL(migrate_page_copy); 74#endif 75 76bool set_page_writeback(struct page *page) 77{ 78 return folio_start_writeback(page_folio(page)); 79} 80EXPORT_SYMBOL(set_page_writeback); 81 82bool set_page_dirty(struct page *page) 83{ 84 return folio_mark_dirty(page_folio(page)); 85} 86EXPORT_SYMBOL(set_page_dirty); 87 88int __set_page_dirty_nobuffers(struct page *page) 89{ 90 return filemap_dirty_folio(page_mapping(page), page_folio(page)); 91} 92EXPORT_SYMBOL(__set_page_dirty_nobuffers); 93 94bool clear_page_dirty_for_io(struct page *page) 95{ 96 return folio_clear_dirty_for_io(page_folio(page)); 97} 98EXPORT_SYMBOL(clear_page_dirty_for_io); 99 100bool redirty_page_for_writepage(struct writeback_control *wbc, 101 struct page *page) 102{ 103 return folio_redirty_for_writepage(wbc, page_folio(page)); 104} 105EXPORT_SYMBOL(redirty_page_for_writepage); 106 107void lru_cache_add(struct page *page) 108{ 109 folio_add_lru(page_folio(page)); 110} 111EXPORT_SYMBOL(lru_cache_add); 112 113int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 114 pgoff_t index, gfp_t gfp) 115{ 116 return filemap_add_folio(mapping, page_folio(page), index, gfp); 117} 118EXPORT_SYMBOL(add_to_page_cache_lru); 119 120noinline 121struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, 122 int fgp_flags, gfp_t gfp) 123{ 124 struct folio *folio; 125 126 folio = __filemap_get_folio(mapping, index, fgp_flags, gfp); 127 if ((fgp_flags & FGP_HEAD) || !folio || xa_is_value(folio)) 128 return &folio->page; 129 return folio_file_page(folio, index); 130} 131EXPORT_SYMBOL(pagecache_get_page); 132 133struct page *grab_cache_page_write_begin(struct address_space *mapping, 134 pgoff_t index) 135{ 136 unsigned fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE; 137 138 return pagecache_get_page(mapping, index, fgp_flags, 139 mapping_gfp_mask(mapping)); 140} 141EXPORT_SYMBOL(grab_cache_page_write_begin); 142 143void delete_from_page_cache(struct page *page) 144{ 145 return filemap_remove_folio(page_folio(page)); 146} 147 148int try_to_release_page(struct page *page, gfp_t gfp) 149{ 150 return filemap_release_folio(page_folio(page), gfp); 151} 152EXPORT_SYMBOL(try_to_release_page); 153 154int isolate_lru_page(struct page *page) 155{ 156 if (WARN_RATELIMIT(PageTail(page), "trying to isolate tail page")) 157 return -EBUSY; 158 return folio_isolate_lru((struct folio *)page); 159} 160 161void putback_lru_page(struct page *page) 162{ 163 folio_putback_lru(page_folio(page)); 164}