]>
Commit | Line | Data |
---|---|---|
014bb1de N |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _MM_SWAP_H | |
3 | #define _MM_SWAP_H | |
4 | ||
5 | #ifdef CONFIG_SWAP | |
6 | #include <linux/blk_types.h> /* for bio_end_io_t */ | |
7 | ||
8 | /* linux/mm/page_io.c */ | |
e1209d3a | 9 | int sio_pool_init(void); |
5169b844 N |
10 | struct swap_iocb; |
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) | |
15 | { | |
16 | if (unlikely(plug)) | |
17 | __swap_read_unplug(plug); | |
18 | } | |
2282679f | 19 | void swap_write_unplug(struct swap_iocb *sio); |
014bb1de | 20 | int swap_writepage(struct page *page, struct writeback_control *wbc); |
cf1e3fe4 | 21 | int __swap_writepage(struct page *page, struct writeback_control *wbc); |
014bb1de N |
22 | |
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]) | |
31 | ||
32 | void show_swap_cache_info(void); | |
09c02e56 | 33 | bool add_to_swap(struct folio *folio); |
014bb1de | 34 | void *get_shadow_from_swap_cache(swp_entry_t entry); |
a4c366f0 | 35 | int add_to_swap_cache(struct folio *folio, swp_entry_t entry, |
014bb1de | 36 | gfp_t gfp, void **shadowp); |
ceff9d33 | 37 | void __delete_from_swap_cache(struct folio *folio, |
014bb1de | 38 | swp_entry_t entry, void *shadow); |
75fa68a5 | 39 | void delete_from_swap_cache(struct folio *folio); |
014bb1de N |
40 | void clear_shadow_from_swap_cache(int type, unsigned long begin, |
41 | unsigned long end); | |
c9edc242 MWO |
42 | struct folio *swap_cache_get_folio(swp_entry_t entry, |
43 | struct vm_area_struct *vma, unsigned long addr); | |
524984ff MWO |
44 | struct folio *filemap_get_incore_folio(struct address_space *mapping, |
45 | pgoff_t index); | |
014bb1de N |
46 | |
47 | struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, | |
48 | struct vm_area_struct *vma, | |
49 | unsigned long addr, | |
5169b844 N |
50 | bool do_poll, |
51 | struct swap_iocb **plug); | |
014bb1de N |
52 | struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, |
53 | struct vm_area_struct *vma, | |
54 | unsigned long addr, | |
55 | bool *new_page_allocated); | |
56 | struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag, | |
57 | struct vm_fault *vmf); | |
58 | struct page *swapin_readahead(swp_entry_t entry, gfp_t flag, | |
59 | struct vm_fault *vmf); | |
60 | ||
b98c359f | 61 | static inline unsigned int folio_swap_flags(struct folio *folio) |
d791ea67 | 62 | { |
b98c359f | 63 | return page_swap_info(&folio->page)->flags; |
d791ea67 | 64 | } |
014bb1de | 65 | #else /* CONFIG_SWAP */ |
5169b844 N |
66 | struct swap_iocb; |
67 | static inline int swap_readpage(struct page *page, bool do_poll, | |
68 | struct swap_iocb **plug) | |
014bb1de N |
69 | { |
70 | return 0; | |
71 | } | |
2282679f N |
72 | static inline void swap_write_unplug(struct swap_iocb *sio) |
73 | { | |
74 | } | |
014bb1de N |
75 | |
76 | static inline struct address_space *swap_address_space(swp_entry_t entry) | |
77 | { | |
78 | return NULL; | |
79 | } | |
80 | ||
014bb1de N |
81 | static inline void show_swap_cache_info(void) |
82 | { | |
83 | } | |
84 | ||
85 | static inline struct page *swap_cluster_readahead(swp_entry_t entry, | |
86 | gfp_t gfp_mask, struct vm_fault *vmf) | |
87 | { | |
88 | return NULL; | |
89 | } | |
90 | ||
91 | static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask, | |
92 | struct vm_fault *vmf) | |
93 | { | |
94 | return NULL; | |
95 | } | |
96 | ||
97 | static inline int swap_writepage(struct page *p, struct writeback_control *wbc) | |
98 | { | |
99 | return 0; | |
100 | } | |
101 | ||
c9edc242 MWO |
102 | static inline struct folio *swap_cache_get_folio(swp_entry_t entry, |
103 | struct vm_area_struct *vma, unsigned long addr) | |
104 | { | |
105 | return NULL; | |
106 | } | |
107 | ||
014bb1de | 108 | static inline |
524984ff MWO |
109 | struct folio *filemap_get_incore_folio(struct address_space *mapping, |
110 | pgoff_t index) | |
014bb1de | 111 | { |
524984ff | 112 | return filemap_get_folio(mapping, index); |
014bb1de N |
113 | } |
114 | ||
09c02e56 | 115 | static inline bool add_to_swap(struct folio *folio) |
014bb1de | 116 | { |
09c02e56 | 117 | return false; |
014bb1de N |
118 | } |
119 | ||
120 | static inline void *get_shadow_from_swap_cache(swp_entry_t entry) | |
121 | { | |
122 | return NULL; | |
123 | } | |
124 | ||
a4c366f0 | 125 | static inline int add_to_swap_cache(struct folio *folio, swp_entry_t entry, |
014bb1de N |
126 | gfp_t gfp_mask, void **shadowp) |
127 | { | |
128 | return -1; | |
129 | } | |
130 | ||
ceff9d33 | 131 | static inline void __delete_from_swap_cache(struct folio *folio, |
014bb1de N |
132 | swp_entry_t entry, void *shadow) |
133 | { | |
134 | } | |
135 | ||
75fa68a5 | 136 | static inline void delete_from_swap_cache(struct folio *folio) |
014bb1de N |
137 | { |
138 | } | |
139 | ||
140 | static inline void clear_shadow_from_swap_cache(int type, unsigned long begin, | |
141 | unsigned long end) | |
142 | { | |
143 | } | |
144 | ||
b98c359f | 145 | static inline unsigned int folio_swap_flags(struct folio *folio) |
d791ea67 N |
146 | { |
147 | return 0; | |
148 | } | |
014bb1de N |
149 | #endif /* CONFIG_SWAP */ |
150 | #endif /* _MM_SWAP_H */ |