mm: remove page_swap_info()
[linux-2.6-block.git] / mm / swap.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _MM_SWAP_H
3 #define _MM_SWAP_H
4
5 struct mempolicy;
6
7 #ifdef CONFIG_SWAP
8 #include <linux/blk_types.h> /* for bio_end_io_t */
9
10 /* linux/mm/page_io.c */
11 int sio_pool_init(void);
12 struct swap_iocb;
13 void swap_read_folio(struct folio *folio, bool do_poll,
14                 struct swap_iocb **plug);
15 void __swap_read_unplug(struct swap_iocb *plug);
16 static inline void swap_read_unplug(struct swap_iocb *plug)
17 {
18         if (unlikely(plug))
19                 __swap_read_unplug(plug);
20 }
21 void swap_write_unplug(struct swap_iocb *sio);
22 int swap_writepage(struct page *page, struct writeback_control *wbc);
23 void __swap_writepage(struct folio *folio, struct writeback_control *wbc);
24
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])
33
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 folio *folio, 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,
43                                   unsigned long end);
44 struct folio *swap_cache_get_folio(swp_entry_t entry,
45                 struct vm_area_struct *vma, unsigned long addr);
46 struct folio *filemap_get_incore_folio(struct address_space *mapping,
47                 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,
52                                    struct swap_iocb **plug);
53 struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_flags,
54                 struct mempolicy *mpol, pgoff_t ilx, bool *new_page_allocated,
55                 bool skip_if_exists);
56 struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
57                                     struct mempolicy *mpol, pgoff_t ilx);
58 struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
59                               struct vm_fault *vmf);
60
61 static inline unsigned int folio_swap_flags(struct folio *folio)
62 {
63         return swp_swap_info(folio->swap)->flags;
64 }
65 #else /* CONFIG_SWAP */
66 struct swap_iocb;
67 static inline void swap_read_folio(struct folio *folio, bool do_poll,
68                 struct swap_iocb **plug)
69 {
70 }
71 static inline void swap_write_unplug(struct swap_iocb *sio)
72 {
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 show_swap_cache_info(void)
81 {
82 }
83
84 static inline struct page *swap_cluster_readahead(swp_entry_t entry,
85                         gfp_t gfp_mask, struct mempolicy *mpol, pgoff_t ilx)
86 {
87         return NULL;
88 }
89
90 static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
91                         struct vm_fault *vmf)
92 {
93         return NULL;
94 }
95
96 static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
97 {
98         return 0;
99 }
100
101 static inline struct folio *swap_cache_get_folio(swp_entry_t entry,
102                 struct vm_area_struct *vma, unsigned long addr)
103 {
104         return NULL;
105 }
106
107 static inline
108 struct folio *filemap_get_incore_folio(struct address_space *mapping,
109                 pgoff_t index)
110 {
111         return filemap_get_folio(mapping, index);
112 }
113
114 static inline bool add_to_swap(struct folio *folio)
115 {
116         return false;
117 }
118
119 static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
120 {
121         return NULL;
122 }
123
124 static inline int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
125                                         gfp_t gfp_mask, void **shadowp)
126 {
127         return -1;
128 }
129
130 static inline void __delete_from_swap_cache(struct folio *folio,
131                                         swp_entry_t entry, void *shadow)
132 {
133 }
134
135 static inline void delete_from_swap_cache(struct folio *folio)
136 {
137 }
138
139 static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
140                                 unsigned long end)
141 {
142 }
143
144 static inline unsigned int folio_swap_flags(struct folio *folio)
145 {
146         return 0;
147 }
148 #endif /* CONFIG_SWAP */
149 #endif /* _MM_SWAP_H */