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_BITS 10
16 #define PAGE_HASH_SIZE (1 << PAGE_HASH_BITS)
17
18 #define PAGE_AGE_VALUE 16
19
20 extern unsigned long page_cache_size;
21 extern struct page * page_hash_table[PAGE_HASH_SIZE];
22
23
24
25
26
27
28
29 static inline unsigned long _page_hashfn(struct inode * inode, unsigned long offset)
30 {
31 #define i (((unsigned long) inode)/sizeof(unsigned long))
32 #define o (offset >> PAGE_SHIFT)
33 #define s(x) ((x)+((x)>>PAGE_HASH_BITS))
34 return s(i+o) & (PAGE_HASH_SIZE-1);
35 #undef i
36 #undef o
37 #undef s
38 }
39
40 #define page_hash(inode,offset) page_hash_table[_page_hashfn(inode,offset)]
41
42 static inline struct page * find_page(struct inode * inode, unsigned long offset)
43 {
44 struct page *page;
45
46 for (page = page_hash(inode, offset); page ; page = page->next_hash) {
47 if (page->inode != inode)
48 continue;
49 if (page->offset != offset)
50 continue;
51 page->age = PAGE_AGE_VALUE | (page->age >> 1);
52 page->count++;
53 break;
54 }
55 return page;
56 }
57
58 static inline void remove_page_from_hash_queue(struct page * page)
59 {
60 struct page **p = &page_hash(page->inode,page->offset);
61
62 page_cache_size--;
63 if (page->next_hash)
64 page->next_hash->prev_hash = page->prev_hash;
65 if (page->prev_hash)
66 page->prev_hash->next_hash = page->next_hash;
67 if (*p == page)
68 *p = page->next_hash;
69 page->next_hash = page->prev_hash = NULL;
70 }
71
72 static inline void add_page_to_hash_queue(struct inode * inode, struct page * page)
73 {
74 struct page **p = &page_hash(inode,page->offset);
75
76 page_cache_size++;
77 page->age = PAGE_AGE_VALUE;
78 page->prev_hash = NULL;
79 if ((page->next_hash = *p) != NULL)
80 page->next_hash->prev_hash = page;
81 *p = page;
82 }
83
84 static inline void remove_page_from_inode_queue(struct page * page)
85 {
86 struct inode * inode = page->inode;
87
88 page->inode = NULL;
89 inode->i_nrpages--;
90 if (inode->i_pages == page)
91 inode->i_pages = page->next;
92 if (page->next)
93 page->next->prev = page->prev;
94 if (page->prev)
95 page->prev->next = page->next;
96 page->next = NULL;
97 page->prev = NULL;
98 }
99
100 static inline void add_page_to_inode_queue(struct inode * inode, struct page * page)
101 {
102 struct page **p = &inode->i_pages;
103
104 inode->i_nrpages++;
105 page->inode = inode;
106 page->prev = NULL;
107 if ((page->next = *p) != NULL)
108 page->next->prev = page;
109 *p = page;
110 }
111
112 extern void update_vm_cache(struct inode *, unsigned long, const char *, int);
113
114 #endif