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