1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/blk_types.h> /* for bio_end_io_t */
8 /* linux/mm/page_io.c */
9 int sio_pool_init(void);
11 int swap_readpage(struct page *page, bool do_poll,
12 struct swap_iocb **plug);
13 void __swap_read_unplug(struct swap_iocb *plug);
14 static inline void swap_read_unplug(struct swap_iocb *plug)
17 __swap_read_unplug(plug);
19 void swap_write_unplug(struct swap_iocb *sio);
20 int swap_writepage(struct page *page, struct writeback_control *wbc);
21 int __swap_writepage(struct page *page, struct writeback_control *wbc);
23 /* linux/mm/swap_state.c */
24 /* One swap address space for each 64M swap space */
25 #define SWAP_ADDRESS_SPACE_SHIFT 14
26 #define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT)
27 extern struct address_space *swapper_spaces[];
28 #define swap_address_space(entry) \
29 (&swapper_spaces[swp_type(entry)][swp_offset(entry) \
30 >> SWAP_ADDRESS_SPACE_SHIFT])
32 void show_swap_cache_info(void);
33 bool add_to_swap(struct folio *folio);
34 void *get_shadow_from_swap_cache(swp_entry_t entry);
35 int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
36 gfp_t gfp, void **shadowp);
37 void __delete_from_swap_cache(struct folio *folio,
38 swp_entry_t entry, void *shadow);
39 void delete_from_swap_cache(struct folio *folio);
40 void clear_shadow_from_swap_cache(int type, unsigned long begin,
42 struct folio *swap_cache_get_folio(swp_entry_t entry,
43 struct vm_area_struct *vma, unsigned long addr);
44 struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index);
46 struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
47 struct vm_area_struct *vma,
50 struct swap_iocb **plug);
51 struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
52 struct vm_area_struct *vma,
54 bool *new_page_allocated);
55 struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
56 struct vm_fault *vmf);
57 struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
58 struct vm_fault *vmf);
60 static inline unsigned int folio_swap_flags(struct folio *folio)
62 return page_swap_info(&folio->page)->flags;
64 #else /* CONFIG_SWAP */
66 static inline int swap_readpage(struct page *page, bool do_poll,
67 struct swap_iocb **plug)
71 static inline void swap_write_unplug(struct swap_iocb *sio)
75 static inline struct address_space *swap_address_space(swp_entry_t entry)
80 static inline void show_swap_cache_info(void)
84 static inline struct page *swap_cluster_readahead(swp_entry_t entry,
85 gfp_t gfp_mask, struct vm_fault *vmf)
90 static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
96 static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
101 static inline struct folio *swap_cache_get_folio(swp_entry_t entry,
102 struct vm_area_struct *vma, unsigned long addr)
108 struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
110 return find_get_page(mapping, index);
113 static inline bool add_to_swap(struct folio *folio)
118 static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
123 static inline int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
124 gfp_t gfp_mask, void **shadowp)
129 static inline void __delete_from_swap_cache(struct folio *folio,
130 swp_entry_t entry, void *shadow)
134 static inline void delete_from_swap_cache(struct folio *folio)
138 static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
143 static inline unsigned int folio_swap_flags(struct folio *folio)
147 #endif /* CONFIG_SWAP */
148 #endif /* _MM_SWAP_H */