root/include/linux/pagemap.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. page_address
  2. _page_hashfn
  3. find_page
  4. remove_page_from_hash_queue
  5. add_page_to_hash_queue
  6. remove_page_from_inode_queue
  7. add_page_to_inode_queue

   1 #ifndef _LINUX_PAGEMAP_H
   2 #define _LINUX_PAGEMAP_H
   3 
   4 /*
   5  * Page-mapping primitive inline functions
   6  *
   7  * Copyright 1995 Linus Torvalds
   8  */
   9 
  10 static inline unsigned long page_address(struct page * page)
     /* [previous][next][first][last][top][bottom][index][help] */
  11 {
  12         return PAGE_OFFSET + PAGE_SIZE*(page - mem_map);
  13 }
  14 
  15 #define PAGE_HASH_SIZE 257
  16 #define PAGE_AGE_VALUE 16
  17 
  18 extern unsigned long page_cache_size;
  19 extern struct page * page_hash_table[PAGE_HASH_SIZE];
  20 
  21 static inline unsigned long _page_hashfn(struct inode * inode, unsigned long offset)
     /* [previous][next][first][last][top][bottom][index][help] */
  22 {
  23         offset ^= (unsigned long) inode;
  24         return offset % PAGE_HASH_SIZE;
  25 }
  26 
  27 #define page_hash(inode,offset) page_hash_table[_page_hashfn(inode,offset)]
  28 
  29 static inline struct page * find_page(struct inode * inode, unsigned long offset)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31         struct page *page;
  32 
  33         for (page = page_hash(inode, offset); page ; page = page->next_hash) {
  34                 if (page->inode != inode)
  35                         continue;
  36                 if (page->offset != offset)
  37                         continue;
  38                 page->age = PAGE_AGE_VALUE | (page->age >> 1);
  39                 page->count++;
  40                 break;
  41         }
  42         return page;
  43 }
  44 
  45 static inline void remove_page_from_hash_queue(struct page * page)
     /* [previous][next][first][last][top][bottom][index][help] */
  46 {
  47         struct page **p = &page_hash(page->inode,page->offset);
  48 
  49         page_cache_size--;
  50         if (page->next_hash)
  51                 page->next_hash->prev_hash = page->prev_hash;
  52         if (page->prev_hash)
  53                 page->prev_hash->next_hash = page->next_hash;
  54         if (*p == page)
  55                 *p = page->next_hash;
  56         page->next_hash = page->prev_hash = NULL;
  57 }
  58 
  59 static inline void add_page_to_hash_queue(struct inode * inode, struct page * page)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61         struct page **p = &page_hash(inode,page->offset);
  62 
  63         page_cache_size++;
  64         page->age = PAGE_AGE_VALUE;
  65         page->prev_hash = NULL;
  66         if ((page->next_hash = *p) != NULL)
  67                 page->next_hash->prev_hash = page;
  68         *p = page;
  69 }
  70 
  71 static inline void remove_page_from_inode_queue(struct page * page)
     /* [previous][next][first][last][top][bottom][index][help] */
  72 {
  73         struct inode * inode = page->inode;
  74 
  75         page->inode = NULL;
  76         inode->i_nrpages--;
  77         if (inode->i_pages == page)
  78                 inode->i_pages = page->next;
  79         if (page->next)
  80                 page->next->prev = page->prev;
  81         if (page->prev)
  82                 page->prev->next = page->next;
  83         page->next = NULL;
  84         page->prev = NULL;
  85 }
  86 
  87 static inline void add_page_to_inode_queue(struct inode * inode, struct page * page)
     /* [previous][next][first][last][top][bottom][index][help] */
  88 {
  89         struct page **p = &inode->i_pages;
  90 
  91         inode->i_nrpages++;
  92         page->inode = inode;
  93         page->prev = NULL;
  94         if ((page->next = *p) != NULL)
  95                 page->next->prev = page;
  96         *p = page;
  97 }
  98 
  99 extern void update_vm_cache(struct inode *, unsigned long, const char *, int);
 100 
 101 #endif

/* [previous][next][first][last][top][bottom][index][help] */