Import 2.3.7pre7
[davej-history.git] / include / linux / swap.h
blobf0ba314054cb162c6ad3518697a1bd70e7023452
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 atomic_t 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 extern int is_swap_partition(kdev_t);
117 void si_swapinfo(struct sysinfo *);
118 unsigned long get_swap_page(void);
119 extern void FASTCALL(swap_free(unsigned long));
120 struct swap_list_t {
121 int head; /* head of priority-ordered swapfile list */
122 int next; /* swapfile to be used next */
124 extern struct swap_list_t swap_list;
125 asmlinkage int sys_swapoff(const char *);
126 asmlinkage int sys_swapon(const char *, int);
129 * vm_ops not present page codes for shared memory.
131 * Will go away eventually..
133 #define SHM_SWP_TYPE 0x20
136 * swap cache stuff (in linux/mm/swap_state.c)
139 #define SWAP_CACHE_INFO
141 #ifdef SWAP_CACHE_INFO
142 extern unsigned long swap_cache_add_total;
143 extern unsigned long swap_cache_del_total;
144 extern unsigned long swap_cache_find_total;
145 extern unsigned long swap_cache_find_success;
146 #endif
148 extern inline unsigned long in_swap_cache(struct page *page)
150 if (PageSwapCache(page))
151 return page->offset;
152 return 0;
156 * Work out if there are any other processes sharing this page, ignoring
157 * any page reference coming from the swap cache, or from outstanding
158 * swap IO on this page. (The page cache _does_ count as another valid
159 * reference to the page, however.)
161 static inline int is_page_shared(struct page *page)
163 unsigned int count;
164 if (PageReserved(page))
165 return 1;
166 count = page_count(page);
167 if (PageSwapCache(page))
168 count += swap_count(page->offset) - 2;
169 if (PageFreeAfter(page))
170 count--;
171 return count > 1;
174 #endif /* __KERNEL__*/
176 #endif /* _LINUX_SWAP_H */