netlib.narod.ru< Назад | Оглавление | Далее >

include/linux/swap.h

17504 #ifndef _LINUX_SWAP_H
17505 #define _LINUX_SWAP_H
17506 
17507 #include <asm/page.h>
17508 
17509 /* set if swap priority specified */
17510 #define SWAP_FLAG_PREFER      0x8000
17511 #define SWAP_FLAG_PRIO_MASK   0x7fff
17512 #define SWAP_FLAG_PRIO_SHIFT  0
17513 
17514 #define MAX_SWAPFILES 8
17515 
17516 union swap_header {
17517   struct
17518   {
17519     char reserved[PAGE_SIZE - 10];
17520     char magic[10];
17521   } magic;
17522   struct
17523   {
17524     char bootbits[1024]; /* Space for disklabel etc. */
17525     unsigned int version;
17526     unsigned int last_page;
17527     unsigned int nr_badpages;
17528     unsigned int padding[125];
17529     unsigned int badpages[1];
17530   } info;
17531 };
17532 
17533 #ifdef __KERNEL__
17534 
17535 /* Max bad pages in the new format.. */
17536 #define __swapoffset(x)                                 \
17537   ((unsigned long)&((union swap_header *)0)->x)
17538 #define MAX_SWAP_BADPAGES                               \
17539   ((__swapoffset(magic.magic) -                         \
17540     __swapoffset(info.badpages)) / sizeof(int))
17541 
17542 #undef DEBUG_SWAP
17543 
17544 #include <asm/atomic.h>
17545 
17546 #define SWP_USED        1
17547 #define SWP_WRITEOK     3
17548 
17549 #define SWAP_CLUSTER_MAX 32
17550 
17551 #define SWAP_MAP_MAX    0x7fff
17552 #define SWAP_MAP_BAD    0x8000
17553 
17554 struct swap_info_struct {
17555   unsigned int flags;
17556   kdev_t swap_device;
17557   struct dentry * swap_file;
17558   unsigned short * swap_map;
17559   unsigned char * swap_lockmap;
17560   unsigned int lowest_bit;
17561   unsigned int highest_bit;
17562   unsigned int cluster_next;
17563   unsigned int cluster_nr;
17564   int prio;                 /* swap priority */
17565   int pages;
17566   unsigned long max;
17567   int next;                 /* next entry on swap list */
17568 };
17569 
17570 extern int nr_swap_pages;
17571 extern int nr_free_pages;
17572 extern atomic_t nr_async_pages;
17573 extern struct inode swapper_inode;
17574 extern unsigned long page_cache_size;
17575 extern int buffermem;
17576 
17577 /* Incomplete types for prototype declarations: */
17578 struct task_struct;
17579 struct vm_area_struct;
17580 struct sysinfo;
17581 
17582 /* linux/ipc/shm.c */
17583 extern int shm_swap (int, int);
17584 
17585 /* linux/mm/swap.c */
17586 extern void swap_setup (void);
17587 
17588 /* linux/mm/vmscan.c */
17589 extern int try_to_free_pages(unsigned int gfp_mask);
17590 
17591 /* linux/mm/page_io.c */
17592 extern void rw_swap_page(int, unsigned long, char *,int);
17593 extern void rw_swap_page_nocache(int, unsigned long,
17594                                  char *);
17595 extern void rw_swap_page_nolock(int, unsigned long,
17596                                 char *, int);
17597 extern void swap_after_unlock_page (unsigned long entry);
17598 
17599 /* linux/mm/page_alloc.c */
17600 extern void swap_in(struct task_struct *,
17601   struct vm_area_struct *, pte_t *, unsigned long, int);
17602 
17603 
17604 /* linux/mm/swap_state.c */
17605 extern void show_swap_cache_info(void);
17606 extern int add_to_swap_cache(struct page *,
17607                              unsigned long);
17608 extern int swap_duplicate(unsigned long);
17609 extern int swap_check_entry(unsigned long);
17610 struct page * lookup_swap_cache(unsigned long);
17611 extern struct page * read_swap_cache_async(unsigned long,
17612                                            int);
17613 #define read_swap_cache(entry)                          \
17614   read_swap_cache_async(entry, 1);
17615 extern int FASTCALL(swap_count(unsigned long));
17616 /* Make these inline later once they are working
17617  * properly. */
17618 extern void delete_from_swap_cache(struct page *page);
17619 extern void free_page_and_swap_cache(unsigned long addr);
17620 
17621 /* linux/mm/swapfile.c */
17622 extern unsigned int nr_swapfiles;
17623 extern struct swap_info_struct swap_info[];
17624 void si_swapinfo(struct sysinfo *);
17625 unsigned long get_swap_page(void);
17626 extern void FASTCALL(swap_free(unsigned long));
17627 struct swap_list_t {
17628   int head;  /* head of priority-ordered swapfile list */
17629   int next;  /* swapfile to be used next */
17630 };
17631 extern struct swap_list_t swap_list;
17632 asmlinkage int sys_swapoff(const char *);
17633 asmlinkage int sys_swapon(const char *, int);
17634 
17635 /* vm_ops not present page codes for shared memory.
17636  *
17637  * Will go away eventually..  */
17638 #define SHM_SWP_TYPE 0x20
17639 
17640 /* swap cache stuff (in linux/mm/swap_state.c) */
17641 
17642 #define SWAP_CACHE_INFO
17643 
17644 #ifdef SWAP_CACHE_INFO
17645 extern unsigned long swap_cache_add_total;
17646 extern unsigned long swap_cache_del_total;
17647 extern unsigned long swap_cache_find_total;
17648 extern unsigned long swap_cache_find_success;
17649 #endif
17650 
17651 extern inline unsigned long
17652 in_swap_cache(struct page *page)
17653 {
17654   if (PageSwapCache(page))
17655     return page->offset;
17656   return 0;
17657 }
17658 
17659 /* Work out if there are any other processes sharing this
17660  * page, ignoring any page reference coming from the swap
17661  * cache, or from outstanding swap IO on this page.  (The
17662  * page cache _does_ count as another valid reference to
17663  * the page, however.)  */
17664 static inline int is_page_shared(struct page *page)
17665 {
17666   unsigned int count;
17667   if (PageReserved(page))
17668     return 1;
17669   count = atomic_read(&page->count);
17670   if (PageSwapCache(page))
17671     count += swap_count(page->offset) - 2;
17672   if (PageFreeAfter(page))
17673     count--;
17674   return  count > 1;
17675 }
17676 
17677 #endif /* __KERNEL__*/
17678 
17679 #endif /* _LINUX_SWAP_H */

netlib.narod.ru< Назад | Оглавление | Далее >

Сайт управляется системой uCoz