aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pagemap.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r--include/linux/pagemap.h36
1 files changed, 23 insertions, 13 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 8a83537d6978..db8a410ae9e1 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -84,11 +84,11 @@ static inline struct page *page_cache_alloc_cold(struct address_space *x)
84typedef int filler_t(void *, struct page *); 84typedef int filler_t(void *, struct page *);
85 85
86extern struct page * find_get_page(struct address_space *mapping, 86extern struct page * find_get_page(struct address_space *mapping,
87 unsigned long index); 87 pgoff_t index);
88extern struct page * find_lock_page(struct address_space *mapping, 88extern struct page * find_lock_page(struct address_space *mapping,
89 unsigned long index); 89 pgoff_t index);
90extern struct page * find_or_create_page(struct address_space *mapping, 90extern struct page * find_or_create_page(struct address_space *mapping,
91 unsigned long index, gfp_t gfp_mask); 91 pgoff_t index, gfp_t gfp_mask);
92unsigned find_get_pages(struct address_space *mapping, pgoff_t start, 92unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
93 unsigned int nr_pages, struct page **pages); 93 unsigned int nr_pages, struct page **pages);
94unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start, 94unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
@@ -96,44 +96,47 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
96unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, 96unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
97 int tag, unsigned int nr_pages, struct page **pages); 97 int tag, unsigned int nr_pages, struct page **pages);
98 98
99struct page *__grab_cache_page(struct address_space *mapping, pgoff_t index);
100
99/* 101/*
100 * Returns locked page at given index in given cache, creating it if needed. 102 * Returns locked page at given index in given cache, creating it if needed.
101 */ 103 */
102static inline struct page *grab_cache_page(struct address_space *mapping, unsigned long index) 104static inline struct page *grab_cache_page(struct address_space *mapping,
105 pgoff_t index)
103{ 106{
104 return find_or_create_page(mapping, index, mapping_gfp_mask(mapping)); 107 return find_or_create_page(mapping, index, mapping_gfp_mask(mapping));
105} 108}
106 109
107extern struct page * grab_cache_page_nowait(struct address_space *mapping, 110extern struct page * grab_cache_page_nowait(struct address_space *mapping,
108 unsigned long index); 111 pgoff_t index);
109extern struct page * read_cache_page_async(struct address_space *mapping, 112extern struct page * read_cache_page_async(struct address_space *mapping,
110 unsigned long index, filler_t *filler, 113 pgoff_t index, filler_t *filler,
111 void *data); 114 void *data);
112extern struct page * read_cache_page(struct address_space *mapping, 115extern struct page * read_cache_page(struct address_space *mapping,
113 unsigned long index, filler_t *filler, 116 pgoff_t index, filler_t *filler,
114 void *data); 117 void *data);
115extern int read_cache_pages(struct address_space *mapping, 118extern int read_cache_pages(struct address_space *mapping,
116 struct list_head *pages, filler_t *filler, void *data); 119 struct list_head *pages, filler_t *filler, void *data);
117 120
118static inline struct page *read_mapping_page_async( 121static inline struct page *read_mapping_page_async(
119 struct address_space *mapping, 122 struct address_space *mapping,
120 unsigned long index, void *data) 123 pgoff_t index, void *data)
121{ 124{
122 filler_t *filler = (filler_t *)mapping->a_ops->readpage; 125 filler_t *filler = (filler_t *)mapping->a_ops->readpage;
123 return read_cache_page_async(mapping, index, filler, data); 126 return read_cache_page_async(mapping, index, filler, data);
124} 127}
125 128
126static inline struct page *read_mapping_page(struct address_space *mapping, 129static inline struct page *read_mapping_page(struct address_space *mapping,
127 unsigned long index, void *data) 130 pgoff_t index, void *data)
128{ 131{
129 filler_t *filler = (filler_t *)mapping->a_ops->readpage; 132 filler_t *filler = (filler_t *)mapping->a_ops->readpage;
130 return read_cache_page(mapping, index, filler, data); 133 return read_cache_page(mapping, index, filler, data);
131} 134}
132 135
133int add_to_page_cache(struct page *page, struct address_space *mapping, 136int add_to_page_cache(struct page *page, struct address_space *mapping,
134 unsigned long index, gfp_t gfp_mask); 137 pgoff_t index, gfp_t gfp_mask);
135int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 138int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
136 unsigned long index, gfp_t gfp_mask); 139 pgoff_t index, gfp_t gfp_mask);
137extern void remove_from_page_cache(struct page *page); 140extern void remove_from_page_cache(struct page *page);
138extern void __remove_from_page_cache(struct page *page); 141extern void __remove_from_page_cache(struct page *page);
139 142
@@ -218,6 +221,9 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size)
218{ 221{
219 int ret; 222 int ret;
220 223
224 if (unlikely(size == 0))
225 return 0;
226
221 /* 227 /*
222 * Writing zeroes into userspace here is OK, because we know that if 228 * Writing zeroes into userspace here is OK, because we know that if
223 * the zero gets there, we'll be overwriting it. 229 * the zero gets there, we'll be overwriting it.
@@ -237,19 +243,23 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size)
237 return ret; 243 return ret;
238} 244}
239 245
240static inline void fault_in_pages_readable(const char __user *uaddr, int size) 246static inline int fault_in_pages_readable(const char __user *uaddr, int size)
241{ 247{
242 volatile char c; 248 volatile char c;
243 int ret; 249 int ret;
244 250
251 if (unlikely(size == 0))
252 return 0;
253
245 ret = __get_user(c, uaddr); 254 ret = __get_user(c, uaddr);
246 if (ret == 0) { 255 if (ret == 0) {
247 const char __user *end = uaddr + size - 1; 256 const char __user *end = uaddr + size - 1;
248 257
249 if (((unsigned long)uaddr & PAGE_MASK) != 258 if (((unsigned long)uaddr & PAGE_MASK) !=
250 ((unsigned long)end & PAGE_MASK)) 259 ((unsigned long)end & PAGE_MASK))
251 __get_user(c, end); 260 ret = __get_user(c, end);
252 } 261 }
262 return ret;
253} 263}
254 264
255#endif /* _LINUX_PAGEMAP_H */ 265#endif /* _LINUX_PAGEMAP_H */