]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - mm/swap.h
Merge tag 'efi-urgent-for-v6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-kernels.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 */
e1209d3a 9int sio_pool_init(void);
5169b844
N
10struct swap_iocb;
11int swap_readpage(struct page *page, bool do_poll,
12 struct swap_iocb **plug);
13void __swap_read_unplug(struct swap_iocb *plug);
14static inline void swap_read_unplug(struct swap_iocb *plug)
15{
16 if (unlikely(plug))
17 __swap_read_unplug(plug);
18}
2282679f 19void swap_write_unplug(struct swap_iocb *sio);
014bb1de
N
20int swap_writepage(struct page *page, struct writeback_control *wbc);
21void end_swap_bio_write(struct bio *bio);
22int __swap_writepage(struct page *page, struct writeback_control *wbc,
23 bio_end_io_t end_write_func);
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)
29extern 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
34void show_swap_cache_info(void);
09c02e56 35bool add_to_swap(struct folio *folio);
014bb1de
N
36void *get_shadow_from_swap_cache(swp_entry_t entry);
37int add_to_swap_cache(struct page *page, swp_entry_t entry,
38 gfp_t gfp, void **shadowp);
ceff9d33 39void __delete_from_swap_cache(struct folio *folio,
014bb1de 40 swp_entry_t entry, void *shadow);
75fa68a5 41void delete_from_swap_cache(struct folio *folio);
014bb1de
N
42void clear_shadow_from_swap_cache(int type, unsigned long begin,
43 unsigned long end);
014bb1de
N
44struct page *lookup_swap_cache(swp_entry_t entry,
45 struct vm_area_struct *vma,
46 unsigned long addr);
47struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index);
48
49struct 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
54struct 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);
58struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
59 struct vm_fault *vmf);
60struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
61 struct vm_fault *vmf);
62
b98c359f 63static inline unsigned int folio_swap_flags(struct folio *folio)
d791ea67 64{
b98c359f 65 return page_swap_info(&folio->page)->flags;
d791ea67 66}
014bb1de 67#else /* CONFIG_SWAP */
5169b844
N
68struct swap_iocb;
69static inline int swap_readpage(struct page *page, bool do_poll,
70 struct swap_iocb **plug)
014bb1de
N
71{
72 return 0;
73}
2282679f
N
74static inline void swap_write_unplug(struct swap_iocb *sio)
75{
76}
014bb1de
N
77
78static inline struct address_space *swap_address_space(swp_entry_t entry)
79{
80 return NULL;
81}
82
014bb1de
N
83static inline void show_swap_cache_info(void)
84{
85}
86
87static inline struct page *swap_cluster_readahead(swp_entry_t entry,
88 gfp_t gfp_mask, struct vm_fault *vmf)
89{
90 return NULL;
91}
92
93static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
94 struct vm_fault *vmf)
95{
96 return NULL;
97}
98
99static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
100{
101 return 0;
102}
103
104static inline struct page *lookup_swap_cache(swp_entry_t swp,
105 struct vm_area_struct *vma,
106 unsigned long addr)
107{
108 return NULL;
109}
110
111static inline
112struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
113{
114 return find_get_page(mapping, index);
115}
116
09c02e56 117static inline bool add_to_swap(struct folio *folio)
014bb1de 118{
09c02e56 119 return false;
014bb1de
N
120}
121
122static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
123{
124 return NULL;
125}
126
127static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
128 gfp_t gfp_mask, void **shadowp)
129{
130 return -1;
131}
132
ceff9d33 133static inline void __delete_from_swap_cache(struct folio *folio,
014bb1de
N
134 swp_entry_t entry, void *shadow)
135{
136}
137
75fa68a5 138static inline void delete_from_swap_cache(struct folio *folio)
014bb1de
N
139{
140}
141
142static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
143 unsigned long end)
144{
145}
146
b98c359f 147static inline unsigned int folio_swap_flags(struct folio *folio)
d791ea67
N
148{
149 return 0;
150}
014bb1de
N
151#endif /* CONFIG_SWAP */
152#endif /* _MM_SWAP_H */