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
- wait_on_page
1 #ifndef _LINUX_PAGEMAP_H
2 #define _LINUX_PAGEMAP_H
3
4 #include <asm/system.h>
5
6
7
8
9
10
11
12 #include <linux/mm.h>
13 #include <linux/fs.h>
14
15 static inline unsigned long page_address(struct page * page)
16 {
17 return PAGE_OFFSET + PAGE_SIZE * page->map_nr;
18 }
19
20 #define PAGE_HASH_BITS 10
21 #define PAGE_HASH_SIZE (1 << PAGE_HASH_BITS)
22
23 #define PAGE_AGE_VALUE 16
24
25 extern unsigned long page_cache_size;
26 extern struct page * page_hash_table[PAGE_HASH_SIZE];
27
28
29
30
31
32
33
34 static inline unsigned long _page_hashfn(struct inode * inode, unsigned long offset)
35 {
36 #define i (((unsigned long) inode)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))
37 #define o (offset >> PAGE_SHIFT)
38 #define s(x) ((x)+((x)>>PAGE_HASH_BITS))
39 return s(i+o) & (PAGE_HASH_SIZE-1);
40 #undef i
41 #undef o
42 #undef s
43 }
44
45 #define page_hash(inode,offset) page_hash_table[_page_hashfn(inode,offset)]
46
47 static inline struct page * find_page(struct inode * inode, unsigned long offset)
48 {
49 struct page *page;
50
51 for (page = page_hash(inode, offset); page ; page = page->next_hash) {
52 if (page->inode != inode)
53 continue;
54 if (page->offset != offset)
55 continue;
56
57 atomic_inc(&page->count);
58 set_bit(PG_referenced, &page->flags);
59 break;
60 }
61 return page;
62 }
63
64 static inline void remove_page_from_hash_queue(struct page * page)
65 {
66 struct page **p = &page_hash(page->inode,page->offset);
67
68 page_cache_size--;
69 if (page->next_hash)
70 page->next_hash->prev_hash = page->prev_hash;
71 if (page->prev_hash)
72 page->prev_hash->next_hash = page->next_hash;
73 if (*p == page)
74 *p = page->next_hash;
75 page->next_hash = page->prev_hash = NULL;
76 }
77
78 static inline void add_page_to_hash_queue(struct inode * inode, struct page * page)
79 {
80 struct page **p = &page_hash(inode,page->offset);
81
82 page_cache_size++;
83 set_bit(PG_referenced, &page->flags);
84 page->age = PAGE_AGE_VALUE;
85 page->prev_hash = NULL;
86 if ((page->next_hash = *p) != NULL)
87 page->next_hash->prev_hash = page;
88 *p = page;
89 }
90
91 static inline void remove_page_from_inode_queue(struct page * page)
92 {
93 struct inode * inode = page->inode;
94
95 page->inode = NULL;
96 inode->i_nrpages--;
97 if (inode->i_pages == page)
98 inode->i_pages = page->next;
99 if (page->next)
100 page->next->prev = page->prev;
101 if (page->prev)
102 page->prev->next = page->next;
103 page->next = NULL;
104 page->prev = NULL;
105 }
106
107 static inline void add_page_to_inode_queue(struct inode * inode, struct page * page)
108 {
109 struct page **p = &inode->i_pages;
110
111 inode->i_nrpages++;
112 page->inode = inode;
113 page->prev = NULL;
114 if ((page->next = *p) != NULL)
115 page->next->prev = page;
116 *p = page;
117 }
118
119 extern void __wait_on_page(struct page *);
120 static inline void wait_on_page(struct page * page)
121 {
122 if (PageLocked(page))
123 __wait_on_page(page);
124 }
125
126 extern void update_vm_cache(struct inode *, unsigned long, const char *, int);
127
128 #endif