linux/include/linux/frontswap.h
<<
>>
Prefs
   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);
  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);
  14};
  15
  16extern bool frontswap_enabled;
  17extern struct frontswap_ops
  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);
  22#define FRONTSWAP_HAS_EXCLUSIVE_GETS
  23extern void frontswap_tmem_exclusive_gets(bool);
  24
  25extern void __frontswap_init(unsigned type);
  26extern int __frontswap_store(struct page *page);
  27extern int __frontswap_load(struct page *page);
  28extern void __frontswap_invalidate_page(unsigned, pgoff_t);
  29extern void __frontswap_invalidate_area(unsigned);
  30
  31#ifdef CONFIG_FRONTSWAP
  32
  33static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
  34{
  35        bool ret = false;
  36
  37        if (frontswap_enabled && sis->frontswap_map)
  38                ret = test_bit(offset, sis->frontswap_map);
  39        return ret;
  40}
  41
  42static inline void frontswap_set(struct swap_info_struct *sis, pgoff_t offset)
  43{
  44        if (frontswap_enabled && sis->frontswap_map)
  45                set_bit(offset, sis->frontswap_map);
  46}
  47
  48static inline void frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
  49{
  50        if (frontswap_enabled && sis->frontswap_map)
  51                clear_bit(offset, sis->frontswap_map);
  52}
  53
  54static inline void frontswap_map_set(struct swap_info_struct *p,
  55                                     unsigned long *map)
  56{
  57        p->frontswap_map = map;
  58}
  59
  60static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
  61{
  62        return p->frontswap_map;
  63}
  64#else
  65/* all inline routines become no-ops and all externs are ignored */
  66
  67#define frontswap_enabled (0)
  68
  69static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
  70{
  71        return false;
  72}
  73
  74static inline void frontswap_set(struct swap_info_struct *sis, pgoff_t offset)
  75{
  76}
  77
  78static inline void frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
  79{
  80}
  81
  82static inline void frontswap_map_set(struct swap_info_struct *p,
  83                                     unsigned long *map)
  84{
  85}
  86
  87static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
  88{
  89        return NULL;
  90}
  91#endif
  92
  93static inline int frontswap_store(struct page *page)
  94{
  95        int ret = -1;
  96
  97        if (frontswap_enabled)
  98                ret = __frontswap_store(page);
  99        return ret;
 100}
 101
 102static inline int frontswap_load(struct page *page)
 103{
 104        int ret = -1;
 105
 106        if (frontswap_enabled)
 107                ret = __frontswap_load(page);
 108        return ret;
 109}
 110
 111static inline void frontswap_invalidate_page(unsigned type, pgoff_t offset)
 112{
 113        if (frontswap_enabled)
 114                __frontswap_invalidate_page(type, offset);
 115}
 116
 117static inline void frontswap_invalidate_area(unsigned type)
 118{
 119        if (frontswap_enabled)
 120                __frontswap_invalidate_area(type);
 121}
 122
 123static inline void frontswap_init(unsigned type)
 124{
 125        if (frontswap_enabled)
 126                __frontswap_init(type);
 127}
 128
 129#endif /* _LINUX_FRONTSWAP_H */
 130
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.