This source file includes following definitions.
- page_address
- _page_hashfn
- find_page
- remove_page_from_hash_queue
- add_page_to_hash_queue
- remove_page_from_inode_queue
- add_page_to_inode_queue
1 #ifndef _LINUX_PAGEMAP_H
2 #define _LINUX_PAGEMAP_H
3
4
5
6
7
8
9
10 static inline unsigned long page_address(struct page * page)
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)
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)
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)
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)
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)
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)
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