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 | } | |
014bb1de N |
19 | int swap_writepage(struct page *page, struct writeback_control *wbc); |
20 | void end_swap_bio_write(struct bio *bio); | |
21 | int __swap_writepage(struct page *page, struct writeback_control *wbc, | |
22 | bio_end_io_t end_write_func); | |
23 | ||
24 | /* linux/mm/swap_state.c */ | |
25 | /* One swap address space for each 64M swap space */ | |
26 | #define SWAP_ADDRESS_SPACE_SHIFT 14 | |
27 | #define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT) | |
28 | extern struct address_space *swapper_spaces[]; | |
29 | #define swap_address_space(entry) \ | |
30 | (&swapper_spaces[swp_type(entry)][swp_offset(entry) \ | |
31 | >> SWAP_ADDRESS_SPACE_SHIFT]) | |
32 | ||
33 | void show_swap_cache_info(void); | |
34 | int add_to_swap(struct page *page); | |
35 | void *get_shadow_from_swap_cache(swp_entry_t entry); | |
36 | int add_to_swap_cache(struct page *page, swp_entry_t entry, | |
37 | gfp_t gfp, void **shadowp); | |
38 | void __delete_from_swap_cache(struct page *page, | |
39 | swp_entry_t entry, void *shadow); | |
40 | void delete_from_swap_cache(struct page *page); | |
41 | void clear_shadow_from_swap_cache(int type, unsigned long begin, | |
42 | unsigned long end); | |
43 | void free_swap_cache(struct page *page); | |
44 | struct page *lookup_swap_cache(swp_entry_t entry, | |
45 | struct vm_area_struct *vma, | |
46 | unsigned long addr); | |
47 | struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index); | |
48 | ||
49 | struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, | |
50 | struct vm_area_struct *vma, | |
51 | unsigned long addr, | |
5169b844 N |
52 | bool do_poll, |
53 | struct swap_iocb **plug); | |
014bb1de N |
54 | struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, |
55 | struct vm_area_struct *vma, | |
56 | unsigned long addr, | |
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); | |
62 | ||
d791ea67 N |
63 | static inline unsigned int page_swap_flags(struct page *page) |
64 | { | |
65 | return page_swap_info(page)->flags; | |
66 | } | |
014bb1de | 67 | #else /* CONFIG_SWAP */ |
5169b844 N |
68 | struct swap_iocb; |
69 | static inline int swap_readpage(struct page *page, bool do_poll, | |
70 | struct swap_iocb **plug) | |
014bb1de N |
71 | { |
72 | return 0; | |
73 | } | |
74 | ||
75 | static inline struct address_space *swap_address_space(swp_entry_t entry) | |
76 | { | |
77 | return NULL; | |
78 | } | |
79 | ||
80 | static inline void free_swap_cache(struct page *page) | |
81 | { | |
82 | } | |
83 | ||
84 | static inline void show_swap_cache_info(void) | |
85 | { | |
86 | } | |
87 | ||
88 | static inline struct page *swap_cluster_readahead(swp_entry_t entry, | |
89 | gfp_t gfp_mask, struct vm_fault *vmf) | |
90 | { | |
91 | return NULL; | |
92 | } | |
93 | ||
94 | static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask, | |
95 | struct vm_fault *vmf) | |
96 | { | |
97 | return NULL; | |
98 | } | |
99 | ||
100 | static inline int swap_writepage(struct page *p, struct writeback_control *wbc) | |
101 | { | |
102 | return 0; | |
103 | } | |
104 | ||
105 | static inline struct page *lookup_swap_cache(swp_entry_t swp, | |
106 | struct vm_area_struct *vma, | |
107 | unsigned long addr) | |
108 | { | |
109 | return NULL; | |
110 | } | |
111 | ||
112 | static inline | |
113 | struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index) | |
114 | { | |
115 | return find_get_page(mapping, index); | |
116 | } | |
117 | ||
118 | static inline int add_to_swap(struct page *page) | |
119 | { | |
120 | return 0; | |
121 | } | |
122 | ||
123 | static inline void *get_shadow_from_swap_cache(swp_entry_t entry) | |
124 | { | |
125 | return NULL; | |
126 | } | |
127 | ||
128 | static inline int add_to_swap_cache(struct page *page, swp_entry_t entry, | |
129 | gfp_t gfp_mask, void **shadowp) | |
130 | { | |
131 | return -1; | |
132 | } | |
133 | ||
134 | static inline void __delete_from_swap_cache(struct page *page, | |
135 | swp_entry_t entry, void *shadow) | |
136 | { | |
137 | } | |
138 | ||
139 | static inline void delete_from_swap_cache(struct page *page) | |
140 | { | |
141 | } | |
142 | ||
143 | static inline void clear_shadow_from_swap_cache(int type, unsigned long begin, | |
144 | unsigned long end) | |
145 | { | |
146 | } | |
147 | ||
d791ea67 N |
148 | static inline unsigned int page_swap_flags(struct page *page) |
149 | { | |
150 | return 0; | |
151 | } | |
014bb1de N |
152 | #endif /* CONFIG_SWAP */ |
153 | #endif /* _MM_SWAP_H */ |