mm: reclaim mustn't enter FS for SWP_FS_OPS swap-space
[linux-2.6-block.git] / mm / swap.h
CommitLineData
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 */
9int swap_readpage(struct page *page, bool do_poll);
10int swap_writepage(struct page *page, struct writeback_control *wbc);
11void end_swap_bio_write(struct bio *bio);
12int __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)
19extern 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
24void show_swap_cache_info(void);
25int add_to_swap(struct page *page);
26void *get_shadow_from_swap_cache(swp_entry_t entry);
27int add_to_swap_cache(struct page *page, swp_entry_t entry,
28 gfp_t gfp, void **shadowp);
29void __delete_from_swap_cache(struct page *page,
30 swp_entry_t entry, void *shadow);
31void delete_from_swap_cache(struct page *page);
32void clear_shadow_from_swap_cache(int type, unsigned long begin,
33 unsigned long end);
34void free_swap_cache(struct page *page);
35struct page *lookup_swap_cache(swp_entry_t entry,
36 struct vm_area_struct *vma,
37 unsigned long addr);
38struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index);
39
40struct 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);
44struct 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);
48struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
49 struct vm_fault *vmf);
50struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
51 struct vm_fault *vmf);
52
d791ea67
N
53static inline unsigned int page_swap_flags(struct page *page)
54{
55 return page_swap_info(page)->flags;
56}
014bb1de
N
57#else /* CONFIG_SWAP */
58static inline int swap_readpage(struct page *page, bool do_poll)
59{
60 return 0;
61}
62
63static inline struct address_space *swap_address_space(swp_entry_t entry)
64{
65 return NULL;
66}
67
68static inline void free_swap_cache(struct page *page)
69{
70}
71
72static inline void show_swap_cache_info(void)
73{
74}
75
76static 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
82static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
83 struct vm_fault *vmf)
84{
85 return NULL;
86}
87
88static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
89{
90 return 0;
91}
92
93static 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
100static inline
101struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
102{
103 return find_get_page(mapping, index);
104}
105
106static inline int add_to_swap(struct page *page)
107{
108 return 0;
109}
110
111static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
112{
113 return NULL;
114}
115
116static 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
122static inline void __delete_from_swap_cache(struct page *page,
123 swp_entry_t entry, void *shadow)
124{
125}
126
127static inline void delete_from_swap_cache(struct page *page)
128{
129}
130
131static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
132 unsigned long end)
133{
134}
135
d791ea67
N
136static 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 */