diff options
Diffstat (limited to 'include/linux/swap.h')
-rw-r--r-- | include/linux/swap.h | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index 4ec90019c1a4..a2602a8207a6 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -145,38 +145,43 @@ enum { | |||
145 | SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */ | 145 | SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */ |
146 | SWP_DISCARDING = (1 << 3), /* now discarding a free cluster */ | 146 | SWP_DISCARDING = (1 << 3), /* now discarding a free cluster */ |
147 | SWP_SOLIDSTATE = (1 << 4), /* blkdev seeks are cheap */ | 147 | SWP_SOLIDSTATE = (1 << 4), /* blkdev seeks are cheap */ |
148 | SWP_CONTINUED = (1 << 5), /* swap_map has count continuation */ | ||
148 | /* add others here before... */ | 149 | /* add others here before... */ |
149 | SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ | 150 | SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ |
150 | }; | 151 | }; |
151 | 152 | ||
152 | #define SWAP_CLUSTER_MAX 32 | 153 | #define SWAP_CLUSTER_MAX 32 |
153 | 154 | ||
154 | #define SWAP_MAP_MAX 0x7ffe | 155 | #define SWAP_MAP_MAX 0x3e /* Max duplication count, in first swap_map */ |
155 | #define SWAP_MAP_BAD 0x7fff | 156 | #define SWAP_MAP_BAD 0x3f /* Note pageblock is bad, in first swap_map */ |
156 | #define SWAP_HAS_CACHE 0x8000 /* There is a swap cache of entry. */ | 157 | #define SWAP_HAS_CACHE 0x40 /* Flag page is cached, in first swap_map */ |
157 | #define SWAP_COUNT_MASK (~SWAP_HAS_CACHE) | 158 | #define SWAP_CONT_MAX 0x7f /* Max count, in each swap_map continuation */ |
159 | #define COUNT_CONTINUED 0x80 /* See swap_map continuation for full count */ | ||
160 | #define SWAP_MAP_SHMEM 0xbf /* Owned by shmem/tmpfs, in first swap_map */ | ||
161 | |||
158 | /* | 162 | /* |
159 | * The in-memory structure used to track swap areas. | 163 | * The in-memory structure used to track swap areas. |
160 | */ | 164 | */ |
161 | struct swap_info_struct { | 165 | struct swap_info_struct { |
162 | unsigned long flags; | 166 | unsigned long flags; /* SWP_USED etc: see above */ |
163 | int prio; /* swap priority */ | 167 | signed short prio; /* swap priority of this type */ |
164 | int next; /* next entry on swap list */ | 168 | signed char type; /* strange name for an index */ |
165 | struct file *swap_file; | 169 | signed char next; /* next type on the swap list */ |
166 | struct block_device *bdev; | 170 | unsigned int max; /* extent of the swap_map */ |
167 | struct list_head extent_list; | 171 | unsigned char *swap_map; /* vmalloc'ed array of usage counts */ |
168 | struct swap_extent *curr_swap_extent; | 172 | unsigned int lowest_bit; /* index of first free in swap_map */ |
169 | unsigned short *swap_map; | 173 | unsigned int highest_bit; /* index of last free in swap_map */ |
170 | unsigned int lowest_bit; | 174 | unsigned int pages; /* total of usable pages of swap */ |
171 | unsigned int highest_bit; | 175 | unsigned int inuse_pages; /* number of those currently in use */ |
176 | unsigned int cluster_next; /* likely index for next allocation */ | ||
177 | unsigned int cluster_nr; /* countdown to next cluster search */ | ||
172 | unsigned int lowest_alloc; /* while preparing discard cluster */ | 178 | unsigned int lowest_alloc; /* while preparing discard cluster */ |
173 | unsigned int highest_alloc; /* while preparing discard cluster */ | 179 | unsigned int highest_alloc; /* while preparing discard cluster */ |
174 | unsigned int cluster_next; | 180 | struct swap_extent *curr_swap_extent; |
175 | unsigned int cluster_nr; | 181 | struct swap_extent first_swap_extent; |
176 | unsigned int pages; | 182 | struct block_device *bdev; /* swap device or bdev of swap file */ |
177 | unsigned int max; | 183 | struct file *swap_file; /* seldom referenced */ |
178 | unsigned int inuse_pages; | 184 | unsigned int old_block_size; /* seldom referenced */ |
179 | unsigned int old_block_size; | ||
180 | }; | 185 | }; |
181 | 186 | ||
182 | struct swap_list_t { | 187 | struct swap_list_t { |
@@ -273,6 +278,7 @@ extern int scan_unevictable_register_node(struct node *node); | |||
273 | extern void scan_unevictable_unregister_node(struct node *node); | 278 | extern void scan_unevictable_unregister_node(struct node *node); |
274 | 279 | ||
275 | extern int kswapd_run(int nid); | 280 | extern int kswapd_run(int nid); |
281 | extern void kswapd_stop(int nid); | ||
276 | 282 | ||
277 | #ifdef CONFIG_MMU | 283 | #ifdef CONFIG_MMU |
278 | /* linux/mm/shmem.c */ | 284 | /* linux/mm/shmem.c */ |
@@ -309,17 +315,18 @@ extern long total_swap_pages; | |||
309 | extern void si_swapinfo(struct sysinfo *); | 315 | extern void si_swapinfo(struct sysinfo *); |
310 | extern swp_entry_t get_swap_page(void); | 316 | extern swp_entry_t get_swap_page(void); |
311 | extern swp_entry_t get_swap_page_of_type(int); | 317 | extern swp_entry_t get_swap_page_of_type(int); |
312 | extern void swap_duplicate(swp_entry_t); | ||
313 | extern int swapcache_prepare(swp_entry_t); | ||
314 | extern int valid_swaphandles(swp_entry_t, unsigned long *); | 318 | extern int valid_swaphandles(swp_entry_t, unsigned long *); |
319 | extern int add_swap_count_continuation(swp_entry_t, gfp_t); | ||
320 | extern void swap_shmem_alloc(swp_entry_t); | ||
321 | extern int swap_duplicate(swp_entry_t); | ||
322 | extern int swapcache_prepare(swp_entry_t); | ||
315 | extern void swap_free(swp_entry_t); | 323 | extern void swap_free(swp_entry_t); |
316 | extern void swapcache_free(swp_entry_t, struct page *page); | 324 | extern void swapcache_free(swp_entry_t, struct page *page); |
317 | extern int free_swap_and_cache(swp_entry_t); | 325 | extern int free_swap_and_cache(swp_entry_t); |
318 | extern int swap_type_of(dev_t, sector_t, struct block_device **); | 326 | extern int swap_type_of(dev_t, sector_t, struct block_device **); |
319 | extern unsigned int count_swap_pages(int, int); | 327 | extern unsigned int count_swap_pages(int, int); |
320 | extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); | 328 | extern sector_t map_swap_page(struct page *, struct block_device **); |
321 | extern sector_t swapdev_block(int, pgoff_t); | 329 | extern sector_t swapdev_block(int, pgoff_t); |
322 | extern struct swap_info_struct *get_swap_info_struct(unsigned); | ||
323 | extern int reuse_swap_page(struct page *); | 330 | extern int reuse_swap_page(struct page *); |
324 | extern int try_to_free_swap(struct page *); | 331 | extern int try_to_free_swap(struct page *); |
325 | struct backing_dev_info; | 332 | struct backing_dev_info; |
@@ -384,8 +391,18 @@ static inline void show_swap_cache_info(void) | |||
384 | #define free_swap_and_cache(swp) is_migration_entry(swp) | 391 | #define free_swap_and_cache(swp) is_migration_entry(swp) |
385 | #define swapcache_prepare(swp) is_migration_entry(swp) | 392 | #define swapcache_prepare(swp) is_migration_entry(swp) |
386 | 393 | ||
387 | static inline void swap_duplicate(swp_entry_t swp) | 394 | static inline int add_swap_count_continuation(swp_entry_t swp, gfp_t gfp_mask) |
388 | { | 395 | { |
396 | return 0; | ||
397 | } | ||
398 | |||
399 | static inline void swap_shmem_alloc(swp_entry_t swp) | ||
400 | { | ||
401 | } | ||
402 | |||
403 | static inline int swap_duplicate(swp_entry_t swp) | ||
404 | { | ||
405 | return 0; | ||
389 | } | 406 | } |
390 | 407 | ||
391 | static inline void swap_free(swp_entry_t swp) | 408 | static inline void swap_free(swp_entry_t swp) |