]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/frontswap.h
8021q: fix a potential memory leak
[mirror_ubuntu-bionic-kernel.git] / include / linux / frontswap.h
CommitLineData
c3ba9698
DM
1#ifndef _LINUX_FRONTSWAP_H
2#define _LINUX_FRONTSWAP_H
3
4#include <linux/swap.h>
5#include <linux/mm.h>
6#include <linux/bitops.h>
7
8struct frontswap_ops {
9 void (*init)(unsigned);
165c8aed
KRW
10 int (*store)(unsigned, pgoff_t, struct page *);
11 int (*load)(unsigned, pgoff_t, struct page *);
c3ba9698
DM
12 void (*invalidate_page)(unsigned, pgoff_t);
13 void (*invalidate_area)(unsigned);
14};
15
16extern bool frontswap_enabled;
1e01c968 17extern struct frontswap_ops *
c3ba9698
DM
18 frontswap_register_ops(struct frontswap_ops *ops);
19extern void frontswap_shrink(unsigned long);
20extern unsigned long frontswap_curr_pages(void);
21extern void frontswap_writethrough(bool);
e3483a5f
DM
22#define FRONTSWAP_HAS_EXCLUSIVE_GETS
23extern void frontswap_tmem_exclusive_gets(bool);
c3ba9698 24
f066ea23 25extern bool __frontswap_test(struct swap_info_struct *, pgoff_t);
4f89849d 26extern void __frontswap_init(unsigned type, unsigned long *map);
165c8aed
KRW
27extern int __frontswap_store(struct page *page);
28extern int __frontswap_load(struct page *page);
c3ba9698
DM
29extern void __frontswap_invalidate_page(unsigned, pgoff_t);
30extern void __frontswap_invalidate_area(unsigned);
31
32#ifdef CONFIG_FRONTSWAP
f066ea23 33#define frontswap_enabled (1)
c3ba9698
DM
34
35static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
36{
f066ea23 37 return __frontswap_test(sis, offset);
c3ba9698
DM
38}
39
40static inline void frontswap_map_set(struct swap_info_struct *p,
41 unsigned long *map)
42{
43 p->frontswap_map = map;
44}
45
46static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
47{
48 return p->frontswap_map;
49}
50#else
51/* all inline routines become no-ops and all externs are ignored */
52
53#define frontswap_enabled (0)
54
55static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
56{
57 return false;
58}
59
c3ba9698
DM
60static inline void frontswap_map_set(struct swap_info_struct *p,
61 unsigned long *map)
62{
63}
64
65static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
66{
67 return NULL;
68}
69#endif
70
165c8aed 71static inline int frontswap_store(struct page *page)
c3ba9698
DM
72{
73 int ret = -1;
74
75 if (frontswap_enabled)
165c8aed 76 ret = __frontswap_store(page);
c3ba9698
DM
77 return ret;
78}
79
165c8aed 80static inline int frontswap_load(struct page *page)
c3ba9698
DM
81{
82 int ret = -1;
83
84 if (frontswap_enabled)
165c8aed 85 ret = __frontswap_load(page);
c3ba9698
DM
86 return ret;
87}
88
89static inline void frontswap_invalidate_page(unsigned type, pgoff_t offset)
90{
91 if (frontswap_enabled)
92 __frontswap_invalidate_page(type, offset);
93}
94
95static inline void frontswap_invalidate_area(unsigned type)
96{
97 if (frontswap_enabled)
98 __frontswap_invalidate_area(type);
99}
100
4f89849d 101static inline void frontswap_init(unsigned type, unsigned long *map)
c3ba9698
DM
102{
103 if (frontswap_enabled)
4f89849d 104 __frontswap_init(type, map);
c3ba9698
DM
105}
106
107#endif /* _LINUX_FRONTSWAP_H */