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 - mem_map);
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(unsigned long))
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 unsigned long flags;
51
52 for (page = page_hash(inode, offset); page ; page = page->next_hash) {
53 if (page->inode != inode)
54 continue;
55 if (page->offset != offset)
56 continue;
57
58 save_flags(flags);
59 cli();
60 page->referenced = 1;
61 page->count++;
62 restore_flags(flags);
63 break;
64 }
65 return page;
66 }
67
68 static inline void remove_page_from_hash_queue(struct page * page)
69 {
70 struct page **p = &page_hash(page->inode,page->offset);
71
72 page_cache_size--;
73 if (page->next_hash)
74 page->next_hash->prev_hash = page->prev_hash;
75 if (page->prev_hash)
76 page->prev_hash->next_hash = page->next_hash;
77 if (*p == page)
78 *p = page->next_hash;
79 page->next_hash = page->prev_hash = NULL;
80 }
81
82 static inline void add_page_to_hash_queue(struct inode * inode, struct page * page)
83 {
84 struct page **p = &page_hash(inode,page->offset);
85
86 page_cache_size++;
87 page->referenced = 1;
88 page->age = PAGE_AGE_VALUE;
89 page->prev_hash = NULL;
90 if ((page->next_hash = *p) != NULL)
91 page->next_hash->prev_hash = page;
92 *p = page;
93 }
94
95 static inline void remove_page_from_inode_queue(struct page * page)
96 {
97 struct inode * inode = page->inode;
98
99 page->inode = NULL;
100 inode->i_nrpages--;
101 if (inode->i_pages == page)
102 inode->i_pages = page->next;
103 if (page->next)
104 page->next->prev = page->prev;
105 if (page->prev)
106 page->prev->next = page->next;
107 page->next = NULL;
108 page->prev = NULL;
109 }
110
111 static inline void add_page_to_inode_queue(struct inode * inode, struct page * page)
112 {
113 struct page **p = &inode->i_pages;
114
115 inode->i_nrpages++;
116 page->inode = inode;
117 page->prev = NULL;
118 if ((page->next = *p) != NULL)
119 page->next->prev = page;
120 *p = page;
121 }
122
123 extern void __wait_on_page(struct page *);
124 static inline void wait_on_page(struct page * page)
125 {
126 if (page->locked)
127 __wait_on_page(page);
128 }
129
130 extern void update_vm_cache(struct inode *, unsigned long, const char *, int);
131
132 #endif