1 #ifndef _LINUX_FRONTSWAP_H
2 #define _LINUX_FRONTSWAP_H
4 #include <linux/swap.h>
8 void (*init
)(unsigned);
9 int (*put_page
)(unsigned, pgoff_t
, struct page
*);
10 int (*get_page
)(unsigned, pgoff_t
, struct page
*);
11 void (*flush_page
)(unsigned, pgoff_t
);
12 void (*flush_area
)(unsigned);
15 extern int frontswap_enabled
;
16 extern struct frontswap_ops
17 frontswap_register_ops(struct frontswap_ops
*ops
);
18 extern void frontswap_shrink(unsigned long);
19 extern unsigned long frontswap_curr_pages(void);
21 extern void __frontswap_init(unsigned type
);
22 extern int __frontswap_put_page(struct page
*page
);
23 extern int __frontswap_get_page(struct page
*page
);
24 extern void __frontswap_flush_page(unsigned, pgoff_t
);
25 extern void __frontswap_flush_area(unsigned);
27 #ifdef CONFIG_FRONTSWAP
29 static inline int frontswap_test(struct swap_info_struct
*sis
, pgoff_t offset
)
33 if (frontswap_enabled
&& sis
->frontswap_map
)
34 ret
= test_bit(offset
, sis
->frontswap_map
);
38 static inline void frontswap_set(struct swap_info_struct
*sis
, pgoff_t offset
)
40 if (frontswap_enabled
&& sis
->frontswap_map
)
41 set_bit(offset
, sis
->frontswap_map
);
44 static inline void frontswap_clear(struct swap_info_struct
*sis
, pgoff_t offset
)
46 if (frontswap_enabled
&& sis
->frontswap_map
)
47 clear_bit(offset
, sis
->frontswap_map
);
50 static inline void frontswap_map_set(struct swap_info_struct
*p
,
53 p
->frontswap_map
= map
;
56 static inline unsigned long *frontswap_map_get(struct swap_info_struct
*p
)
58 return p
->frontswap_map
;
61 /* all inline routines become no-ops and all externs are ignored */
63 #define frontswap_enabled (0)
65 static inline int frontswap_test(struct swap_info_struct
*sis
, pgoff_t offset
)
70 static inline void frontswap_set(struct swap_info_struct
*sis
, pgoff_t offset
)
74 static inline void frontswap_clear(struct swap_info_struct
*sis
, pgoff_t offset
)
78 static inline void frontswap_map_set(struct swap_info_struct
*p
,
83 static inline unsigned long *frontswap_map_get(struct swap_info_struct
*p
)
89 static inline int frontswap_put_page(struct page
*page
)
93 if (frontswap_enabled
)
94 ret
= __frontswap_put_page(page
);
98 static inline int frontswap_get_page(struct page
*page
)
102 if (frontswap_enabled
)
103 ret
= __frontswap_get_page(page
);
107 static inline void frontswap_flush_page(unsigned type
, pgoff_t offset
)
109 if (frontswap_enabled
)
110 __frontswap_flush_page(type
, offset
);
113 static inline void frontswap_flush_area(unsigned type
)
115 if (frontswap_enabled
)
116 __frontswap_flush_area(type
);
119 static inline void frontswap_init(unsigned type
)
121 if (frontswap_enabled
)
122 __frontswap_init(type
);
125 #endif /* _LINUX_FRONTSWAP_H */