]> git.ipfire.org Git - thirdparty/linux.git/blame - mm/swap.h
btrfs: add and use helpers for reading and writing fs_info->generation
[thirdparty/linux.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 10struct swap_iocb;
a8c1408f 11void swap_readpage(struct page *page, bool do_poll, struct swap_iocb **plug);
5169b844
N
12void __swap_read_unplug(struct swap_iocb *plug);
13static inline void swap_read_unplug(struct swap_iocb *plug)
14{
15 if (unlikely(plug))
16 __swap_read_unplug(plug);
17}
2282679f 18void swap_write_unplug(struct swap_iocb *sio);
014bb1de 19int swap_writepage(struct page *page, struct writeback_control *wbc);
e3e2762b 20void __swap_writepage(struct page *page, struct writeback_control *wbc);
014bb1de
N
21
22/* linux/mm/swap_state.c */
23/* One swap address space for each 64M swap space */
24#define SWAP_ADDRESS_SPACE_SHIFT 14
25#define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT)
26extern struct address_space *swapper_spaces[];
27#define swap_address_space(entry) \
28 (&swapper_spaces[swp_type(entry)][swp_offset(entry) \
29 >> SWAP_ADDRESS_SPACE_SHIFT])
30
31void show_swap_cache_info(void);
09c02e56 32bool add_to_swap(struct folio *folio);
014bb1de 33void *get_shadow_from_swap_cache(swp_entry_t entry);
a4c366f0 34int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
014bb1de 35 gfp_t gfp, void **shadowp);
ceff9d33 36void __delete_from_swap_cache(struct folio *folio,
014bb1de 37 swp_entry_t entry, void *shadow);
75fa68a5 38void delete_from_swap_cache(struct folio *folio);
014bb1de
N
39void clear_shadow_from_swap_cache(int type, unsigned long begin,
40 unsigned long end);
c9edc242
MWO
41struct folio *swap_cache_get_folio(swp_entry_t entry,
42 struct vm_area_struct *vma, unsigned long addr);
524984ff
MWO
43struct folio *filemap_get_incore_folio(struct address_space *mapping,
44 pgoff_t index);
014bb1de
N
45
46struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
47 struct vm_area_struct *vma,
48 unsigned long addr,
5169b844 49 struct swap_iocb **plug);
014bb1de
N
50struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
51 struct vm_area_struct *vma,
52 unsigned long addr,
53 bool *new_page_allocated);
54struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
55 struct vm_fault *vmf);
56struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
57 struct vm_fault *vmf);
58
b98c359f 59static inline unsigned int folio_swap_flags(struct folio *folio)
d791ea67 60{
b98c359f 61 return page_swap_info(&folio->page)->flags;
d791ea67 62}
014bb1de 63#else /* CONFIG_SWAP */
5169b844 64struct swap_iocb;
a8c1408f
CH
65static inline void swap_readpage(struct page *page, bool do_poll,
66 struct swap_iocb **plug)
014bb1de 67{
014bb1de 68}
2282679f
N
69static inline void swap_write_unplug(struct swap_iocb *sio)
70{
71}
014bb1de
N
72
73static inline struct address_space *swap_address_space(swp_entry_t entry)
74{
75 return NULL;
76}
77
014bb1de
N
78static inline void show_swap_cache_info(void)
79{
80}
81
82static inline struct page *swap_cluster_readahead(swp_entry_t entry,
83 gfp_t gfp_mask, struct vm_fault *vmf)
84{
85 return NULL;
86}
87
88static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
89 struct vm_fault *vmf)
90{
91 return NULL;
92}
93
94static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
95{
96 return 0;
97}
98
c9edc242
MWO
99static inline struct folio *swap_cache_get_folio(swp_entry_t entry,
100 struct vm_area_struct *vma, unsigned long addr)
101{
102 return NULL;
103}
104
014bb1de 105static inline
524984ff
MWO
106struct folio *filemap_get_incore_folio(struct address_space *mapping,
107 pgoff_t index)
014bb1de 108{
524984ff 109 return filemap_get_folio(mapping, index);
014bb1de
N
110}
111
09c02e56 112static inline bool add_to_swap(struct folio *folio)
014bb1de 113{
09c02e56 114 return false;
014bb1de
N
115}
116
117static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
118{
119 return NULL;
120}
121
a4c366f0 122static inline int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
014bb1de
N
123 gfp_t gfp_mask, void **shadowp)
124{
125 return -1;
126}
127
ceff9d33 128static inline void __delete_from_swap_cache(struct folio *folio,
014bb1de
N
129 swp_entry_t entry, void *shadow)
130{
131}
132
75fa68a5 133static inline void delete_from_swap_cache(struct folio *folio)
014bb1de
N
134{
135}
136
137static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
138 unsigned long end)
139{
140}
141
b98c359f 142static inline unsigned int folio_swap_flags(struct folio *folio)
d791ea67
N
143{
144 return 0;
145}
014bb1de
N
146#endif /* CONFIG_SWAP */
147#endif /* _MM_SWAP_H */