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 void end_swap_bio_write(struct bio *bio);
22 int __swap_writepage(struct page *page, struct writeback_control *wbc,
23 bio_end_io_t end_write_func);
25 /* linux/mm/swap_state.c */
26 /* One swap address space for each 64M swap space */
27 #define SWAP_ADDRESS_SPACE_SHIFT 14
28 #define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT)
29 extern struct address_space *swapper_spaces[];
30 #define swap_address_space(entry) \
31 (&swapper_spaces[swp_type(entry)][swp_offset(entry) \
32 >> SWAP_ADDRESS_SPACE_SHIFT])
34 void show_swap_cache_info(void);
35 bool add_to_swap(struct folio *folio);
36 void *get_shadow_from_swap_cache(swp_entry_t entry);
37 int add_to_swap_cache(struct page *page, swp_entry_t entry,
38 gfp_t gfp, void **shadowp);
39 void __delete_from_swap_cache(struct folio *folio,
40 swp_entry_t entry, void *shadow);
41 void delete_from_swap_cache(struct folio *folio);
42 void clear_shadow_from_swap_cache(int type, unsigned long begin,
44 struct page *lookup_swap_cache(swp_entry_t entry,
45 struct vm_area_struct *vma,
47 struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index);
49 struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
50 struct vm_area_struct *vma,
53 struct swap_iocb **plug);
54 struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
55 struct vm_area_struct *vma,
57 bool *new_page_allocated);
58 struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
59 struct vm_fault *vmf);
60 struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
61 struct vm_fault *vmf);
63 static inline unsigned int folio_swap_flags(struct folio *folio)
65 return page_swap_info(&folio->page)->flags;
67 #else /* CONFIG_SWAP */
69 static inline int swap_readpage(struct page *page, bool do_poll,
70 struct swap_iocb **plug)
74 static inline void swap_write_unplug(struct swap_iocb *sio)
78 static inline struct address_space *swap_address_space(swp_entry_t entry)
83 static inline void show_swap_cache_info(void)
87 static inline struct page *swap_cluster_readahead(swp_entry_t entry,
88 gfp_t gfp_mask, struct vm_fault *vmf)
93 static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
99 static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
104 static inline struct page *lookup_swap_cache(swp_entry_t swp,
105 struct vm_area_struct *vma,
112 struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
114 return find_get_page(mapping, index);
117 static inline bool add_to_swap(struct folio *folio)
122 static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
127 static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
128 gfp_t gfp_mask, void **shadowp)
133 static inline void __delete_from_swap_cache(struct folio *folio,
134 swp_entry_t entry, void *shadow)
138 static inline void delete_from_swap_cache(struct folio *folio)
142 static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
147 static inline unsigned int folio_swap_flags(struct folio *folio)
151 #endif /* CONFIG_SWAP */
152 #endif /* _MM_SWAP_H */