Blame view
include/linux/frontswap.h
2.69 KB
c3ba96981
|
1 2 3 4 5 6 7 8 |
#ifndef _LINUX_FRONTSWAP_H #define _LINUX_FRONTSWAP_H #include <linux/swap.h> #include <linux/mm.h> #include <linux/bitops.h> struct frontswap_ops { |
d1dc6f1bc
|
9 10 11 12 13 14 |
void (*init)(unsigned); /* this swap type was just swapon'ed */ int (*store)(unsigned, pgoff_t, struct page *); /* store a page */ int (*load)(unsigned, pgoff_t, struct page *); /* load a page */ void (*invalidate_page)(unsigned, pgoff_t); /* page no longer needed */ void (*invalidate_area)(unsigned); /* swap type just swapoff'ed */ struct frontswap_ops *next; /* private pointer to next ops */ |
c3ba96981
|
15 16 17 |
}; extern bool frontswap_enabled; |
d1dc6f1bc
|
18 |
extern void frontswap_register_ops(struct frontswap_ops *ops); |
c3ba96981
|
19 20 21 |
extern void frontswap_shrink(unsigned long); extern unsigned long frontswap_curr_pages(void); extern void frontswap_writethrough(bool); |
e3483a5f3
|
22 23 |
#define FRONTSWAP_HAS_EXCLUSIVE_GETS extern void frontswap_tmem_exclusive_gets(bool); |
c3ba96981
|
24 |
|
f066ea230
|
25 |
extern bool __frontswap_test(struct swap_info_struct *, pgoff_t); |
4f89849da
|
26 |
extern void __frontswap_init(unsigned type, unsigned long *map); |
165c8aed5
|
27 28 |
extern int __frontswap_store(struct page *page); extern int __frontswap_load(struct page *page); |
c3ba96981
|
29 30 31 32 |
extern void __frontswap_invalidate_page(unsigned, pgoff_t); extern void __frontswap_invalidate_area(unsigned); #ifdef CONFIG_FRONTSWAP |
f066ea230
|
33 |
#define frontswap_enabled (1) |
c3ba96981
|
34 35 36 |
static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset) { |
f066ea230
|
37 |
return __frontswap_test(sis, offset); |
c3ba96981
|
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
} static inline void frontswap_map_set(struct swap_info_struct *p, unsigned long *map) { p->frontswap_map = map; } static inline unsigned long *frontswap_map_get(struct swap_info_struct *p) { return p->frontswap_map; } #else /* all inline routines become no-ops and all externs are ignored */ #define frontswap_enabled (0) static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset) { return false; } |
c3ba96981
|
59 60 61 62 63 64 65 66 67 68 |
static inline void frontswap_map_set(struct swap_info_struct *p, unsigned long *map) { } static inline unsigned long *frontswap_map_get(struct swap_info_struct *p) { return NULL; } #endif |
165c8aed5
|
69 |
static inline int frontswap_store(struct page *page) |
c3ba96981
|
70 71 72 73 |
{ int ret = -1; if (frontswap_enabled) |
165c8aed5
|
74 |
ret = __frontswap_store(page); |
c3ba96981
|
75 76 |
return ret; } |
165c8aed5
|
77 |
static inline int frontswap_load(struct page *page) |
c3ba96981
|
78 79 80 81 |
{ int ret = -1; if (frontswap_enabled) |
165c8aed5
|
82 |
ret = __frontswap_load(page); |
c3ba96981
|
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
return ret; } static inline void frontswap_invalidate_page(unsigned type, pgoff_t offset) { if (frontswap_enabled) __frontswap_invalidate_page(type, offset); } static inline void frontswap_invalidate_area(unsigned type) { if (frontswap_enabled) __frontswap_invalidate_area(type); } |
4f89849da
|
97 |
static inline void frontswap_init(unsigned type, unsigned long *map) |
c3ba96981
|
98 99 |
{ if (frontswap_enabled) |
4f89849da
|
100 |
__frontswap_init(type, map); |
c3ba96981
|
101 102 103 |
} #endif /* _LINUX_FRONTSWAP_H */ |