]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/linux/frontswap.h
1 #ifndef _LINUX_FRONTSWAP_H
2 #define _LINUX_FRONTSWAP_H
4 #include <linux/swap.h>
6 #include <linux/bitops.h>
9 void (*init
)(unsigned);
10 int (*store
)(unsigned, pgoff_t
, struct page
*);
11 int (*load
)(unsigned, pgoff_t
, struct page
*);
12 void (*invalidate_page
)(unsigned, pgoff_t
);
13 void (*invalidate_area
)(unsigned);
16 extern bool frontswap_enabled
;
17 extern struct frontswap_ops
18 frontswap_register_ops(struct frontswap_ops
*ops
);
19 extern void frontswap_shrink(unsigned long);
20 extern unsigned long frontswap_curr_pages(void);
21 extern void frontswap_writethrough(bool);
23 extern void __frontswap_init(unsigned type
);
24 extern int __frontswap_store(struct page
*page
);
25 extern int __frontswap_load(struct page
*page
);
26 extern void __frontswap_invalidate_page(unsigned, pgoff_t
);
27 extern void __frontswap_invalidate_area(unsigned);
29 #ifdef CONFIG_FRONTSWAP
31 static inline bool frontswap_test(struct swap_info_struct
*sis
, pgoff_t offset
)
35 if (frontswap_enabled
&& sis
->frontswap_map
)
36 ret
= test_bit(offset
, sis
->frontswap_map
);
40 static inline void frontswap_set(struct swap_info_struct
*sis
, pgoff_t offset
)
42 if (frontswap_enabled
&& sis
->frontswap_map
)
43 set_bit(offset
, sis
->frontswap_map
);
46 static inline void frontswap_clear(struct swap_info_struct
*sis
, pgoff_t offset
)
48 if (frontswap_enabled
&& sis
->frontswap_map
)
49 clear_bit(offset
, sis
->frontswap_map
);
52 static inline void frontswap_map_set(struct swap_info_struct
*p
,
55 p
->frontswap_map
= map
;
58 static inline unsigned long *frontswap_map_get(struct swap_info_struct
*p
)
60 return p
->frontswap_map
;
63 /* all inline routines become no-ops and all externs are ignored */
65 #define frontswap_enabled (0)
67 static inline bool frontswap_test(struct swap_info_struct
*sis
, pgoff_t offset
)
72 static inline void frontswap_set(struct swap_info_struct
*sis
, pgoff_t offset
)
76 static inline void frontswap_clear(struct swap_info_struct
*sis
, pgoff_t offset
)
80 static inline void frontswap_map_set(struct swap_info_struct
*p
,
85 static inline unsigned long *frontswap_map_get(struct swap_info_struct
*p
)
91 static inline int frontswap_store(struct page
*page
)
95 if (frontswap_enabled
)
96 ret
= __frontswap_store(page
);
100 static inline int frontswap_load(struct page
*page
)
104 if (frontswap_enabled
)
105 ret
= __frontswap_load(page
);
109 static inline void frontswap_invalidate_page(unsigned type
, pgoff_t offset
)
111 if (frontswap_enabled
)
112 __frontswap_invalidate_page(type
, offset
);
115 static inline void frontswap_invalidate_area(unsigned type
)
117 if (frontswap_enabled
)
118 __frontswap_invalidate_area(type
);
121 static inline void frontswap_init(unsigned type
)
123 if (frontswap_enabled
)
124 __frontswap_init(type
);
127 #endif /* _LINUX_FRONTSWAP_H */