2.2.0-final
[davej-history.git] / include / linux / swap.h
blob66ba5d6235202fd4da46ead4a7134879d7e2bdda
1 #ifndef _LINUX_SWAP_H
2 #define _LINUX_SWAP_H
4 #include <asm/page.h>
6 #define SWAP_FLAG_PREFER 0x8000 /* set if swap priority specified */
7 #define SWAP_FLAG_PRIO_MASK 0x7fff
8 #define SWAP_FLAG_PRIO_SHIFT 0
10 #define MAX_SWAPFILES 8
12 union swap_header {
13 struct
15 char reserved[PAGE_SIZE - 10];
16 char magic[10];
17 } magic;
18 struct
20 char bootbits[1024]; /* Space for disklabel etc. */
21 unsigned int version;
22 unsigned int last_page;
23 unsigned int nr_badpages;
24 unsigned int padding[125];
25 unsigned int badpages[1];
26 } info;
29 #ifdef __KERNEL__
32 * Max bad pages in the new format..
34 #define __swapoffset(x) ((unsigned long)&((union swap_header *)0)->x)
35 #define MAX_SWAP_BADPAGES \
36 ((__swapoffset(magic.magic) - __swapoffset(info.badpages)) / sizeof(int))
38 #undef DEBUG_SWAP
40 #include <asm/atomic.h>
42 #define SWP_USED 1
43 #define SWP_WRITEOK 3
45 #define SWAP_CLUSTER_MAX 32
47 #define SWAP_MAP_MAX 0x7fff
48 #define SWAP_MAP_BAD 0x8000
50 struct swap_info_struct {
51 unsigned int flags;
52 kdev_t swap_device;
53 struct dentry * swap_file;
54 unsigned short * swap_map;
55 unsigned char * swap_lockmap;
56 unsigned int lowest_bit;
57 unsigned int highest_bit;
58 unsigned int cluster_next;
59 unsigned int cluster_nr;
60 int prio; /* swap priority */
61 int pages;
62 unsigned long max;
63 int next; /* next entry on swap list */
66 extern int nr_swap_pages;
67 extern int nr_free_pages;
68 extern atomic_t nr_async_pages;
69 extern struct inode swapper_inode;
70 extern unsigned long page_cache_size;
71 extern int buffermem;
73 /* Incomplete types for prototype declarations: */
74 struct task_struct;
75 struct vm_area_struct;
76 struct sysinfo;
78 /* linux/ipc/shm.c */
79 extern int shm_swap (int, int);
81 /* linux/mm/swap.c */
82 extern void swap_setup (void);
84 /* linux/mm/vmscan.c */
85 extern int try_to_free_pages(unsigned int gfp_mask);
87 /* linux/mm/page_io.c */
88 extern void rw_swap_page(int, unsigned long, char *, int);
89 extern void rw_swap_page_nocache(int, unsigned long, char *);
90 extern void rw_swap_page_nolock(int, unsigned long, char *, int);
91 extern void swap_after_unlock_page (unsigned long entry);
93 /* linux/mm/page_alloc.c */
94 extern void swap_in(struct task_struct *, struct vm_area_struct *,
95 pte_t *, unsigned long, int);
98 /* linux/mm/swap_state.c */
99 extern void show_swap_cache_info(void);
100 extern int add_to_swap_cache(struct page *, unsigned long);
101 extern int swap_duplicate(unsigned long);
102 extern int swap_check_entry(unsigned long);
103 struct page * lookup_swap_cache(unsigned long);
104 extern struct page * read_swap_cache_async(unsigned long, int);
105 #define read_swap_cache(entry) read_swap_cache_async(entry, 1);
106 extern int FASTCALL(swap_count(unsigned long));
108 * Make these inline later once they are working properly.
110 extern void delete_from_swap_cache(struct page *page);
111 extern void free_page_and_swap_cache(unsigned long addr);
113 /* linux/mm/swapfile.c */
114 extern unsigned int nr_swapfiles;
115 extern struct swap_info_struct swap_info[];
116 void si_swapinfo(struct sysinfo *);
117 unsigned long get_swap_page(void);
118 extern void FASTCALL(swap_free(unsigned long));
119 struct swap_list_t {
120 int head; /* head of priority-ordered swapfile list */
121 int next; /* swapfile to be used next */
123 extern struct swap_list_t swap_list;
124 asmlinkage int sys_swapoff(const char *);
125 asmlinkage int sys_swapon(const char *, int);
128 * vm_ops not present page codes for shared memory.
130 * Will go away eventually..
132 #define SHM_SWP_TYPE 0x20
135 * swap cache stuff (in linux/mm/swap_state.c)
138 #define SWAP_CACHE_INFO
140 #ifdef SWAP_CACHE_INFO
141 extern unsigned long swap_cache_add_total;
142 extern unsigned long swap_cache_del_total;
143 extern unsigned long swap_cache_find_total;
144 extern unsigned long swap_cache_find_success;
145 #endif
147 extern inline unsigned long in_swap_cache(struct page *page)
149 if (PageSwapCache(page))
150 return page->offset;
151 return 0;
155 * Work out if there are any other processes sharing this page, ignoring
156 * any page reference coming from the swap cache, or from outstanding
157 * swap IO on this page. (The page cache _does_ count as another valid
158 * reference to the page, however.)
160 static inline int is_page_shared(struct page *page)
162 unsigned int count;
163 if (PageReserved(page))
164 return 1;
165 count = atomic_read(&page->count);
166 if (PageSwapCache(page))
167 count += swap_count(page->offset) - 2;
168 if (PageFreeAfter(page))
169 count--;
170 return count > 1;
173 #endif /* __KERNEL__*/
175 #endif /* _LINUX_SWAP_H */