X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=include%2Flinux%2Fpagemap.h;h=db8a410ae9e15a6daf9b64678fd3edefccdcc717;hb=74eb94f7b84f4e631a0e020991fb16f17ce85ab7;hp=7a8dcb82a6999a2c8e8114c17c83be1a2f71d19e;hpb=60f29b1e1600d89aee5e529acb4b276a6650cb8b;p=linux-2.6-omap-h63xx.git diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 7a8dcb82a69..db8a410ae9e 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -11,6 +11,7 @@ #include #include #include +#include /* * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page @@ -19,6 +20,16 @@ #define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */ #define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */ +static inline void mapping_set_error(struct address_space *mapping, int error) +{ + if (error) { + if (error == -ENOSPC) + set_bit(AS_ENOSPC, &mapping->flags); + else + set_bit(AS_EIO, &mapping->flags); + } +} + static inline gfp_t mapping_gfp_mask(struct address_space * mapping) { return (__force gfp_t)mapping->flags & __GFP_BITS_MASK; @@ -73,11 +84,11 @@ static inline struct page *page_cache_alloc_cold(struct address_space *x) typedef int filler_t(void *, struct page *); extern struct page * find_get_page(struct address_space *mapping, - unsigned long index); + pgoff_t index); extern struct page * find_lock_page(struct address_space *mapping, - unsigned long index); + pgoff_t index); extern struct page * find_or_create_page(struct address_space *mapping, - unsigned long index, gfp_t gfp_mask); + pgoff_t index, gfp_t gfp_mask); unsigned find_get_pages(struct address_space *mapping, pgoff_t start, unsigned int nr_pages, struct page **pages); unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start, @@ -85,33 +96,47 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start, unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, int tag, unsigned int nr_pages, struct page **pages); +struct page *__grab_cache_page(struct address_space *mapping, pgoff_t index); + /* * Returns locked page at given index in given cache, creating it if needed. */ -static inline struct page *grab_cache_page(struct address_space *mapping, unsigned long index) +static inline struct page *grab_cache_page(struct address_space *mapping, + pgoff_t index) { return find_or_create_page(mapping, index, mapping_gfp_mask(mapping)); } extern struct page * grab_cache_page_nowait(struct address_space *mapping, - unsigned long index); + pgoff_t index); +extern struct page * read_cache_page_async(struct address_space *mapping, + pgoff_t index, filler_t *filler, + void *data); extern struct page * read_cache_page(struct address_space *mapping, - unsigned long index, filler_t *filler, + pgoff_t index, filler_t *filler, void *data); extern int read_cache_pages(struct address_space *mapping, struct list_head *pages, filler_t *filler, void *data); +static inline struct page *read_mapping_page_async( + struct address_space *mapping, + pgoff_t index, void *data) +{ + filler_t *filler = (filler_t *)mapping->a_ops->readpage; + return read_cache_page_async(mapping, index, filler, data); +} + static inline struct page *read_mapping_page(struct address_space *mapping, - unsigned long index, void *data) + pgoff_t index, void *data) { filler_t *filler = (filler_t *)mapping->a_ops->readpage; return read_cache_page(mapping, index, filler, data); } int add_to_page_cache(struct page *page, struct address_space *mapping, - unsigned long index, gfp_t gfp_mask); + pgoff_t index, gfp_t gfp_mask); int add_to_page_cache_lru(struct page *page, struct address_space *mapping, - unsigned long index, gfp_t gfp_mask); + pgoff_t index, gfp_t gfp_mask); extern void remove_from_page_cache(struct page *page); extern void __remove_from_page_cache(struct page *page); @@ -196,6 +221,9 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size) { int ret; + if (unlikely(size == 0)) + return 0; + /* * Writing zeroes into userspace here is OK, because we know that if * the zero gets there, we'll be overwriting it. @@ -215,19 +243,23 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size) return ret; } -static inline void fault_in_pages_readable(const char __user *uaddr, int size) +static inline int fault_in_pages_readable(const char __user *uaddr, int size) { volatile char c; int ret; + if (unlikely(size == 0)) + return 0; + ret = __get_user(c, uaddr); if (ret == 0) { const char __user *end = uaddr + size - 1; if (((unsigned long)uaddr & PAGE_MASK) != ((unsigned long)end & PAGE_MASK)) - __get_user(c, end); + ret = __get_user(c, end); } + return ret; } #endif /* _LINUX_PAGEMAP_H */