Patch from Oleg Drokin Move these already-inline functions to a header file so that filesystems can reuse them. For the reiserfs_file_write patch. reiserfs/file.c | 0 linux/pagemap.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ filemap.c | 44 -------------------------------------------- 3 files changed, 46 insertions(+), 44 deletions(-) diff -puN fs/reiserfs/file.c~fault_in_pages-move fs/reiserfs/file.c diff -puN include/linux/pagemap.h~fault_in_pages-move include/linux/pagemap.h --- 25/include/linux/pagemap.h~fault_in_pages-move 2003-02-14 18:23:56.000000000 -0800 +++ 25-akpm/include/linux/pagemap.h 2003-02-14 18:23:56.000000000 -0800 @@ -8,6 +8,7 @@ #include #include #include +#include /* * The page cache can done in larger chunks than @@ -122,4 +123,49 @@ static inline void wait_on_page_writebac } extern void end_page_writeback(struct page *page); + +/* + * Fault a userspace page into pagetables. Return non-zero on a fault. + * + * FIXME: this assumes that two userspace pages are always sufficient. That's + * not true if PAGE_CACHE_SIZE > PAGE_SIZE. + */ +static inline int fault_in_pages_writeable(char *uaddr, int size) +{ + int ret; + + /* + * Writing zeroes into userspace here is OK, because we know that if + * the zero gets there, we'll be overwriting it. + */ + ret = __put_user(0, uaddr); + if (ret == 0) { + char *end = uaddr + size - 1; + + /* + * If the page was already mapped, this will get a cache miss + * for sure, so try to avoid doing it. + */ + if (((unsigned long)uaddr & PAGE_MASK) != + ((unsigned long)end & PAGE_MASK)) + ret = __put_user(0, end); + } + return ret; +} + +static inline void fault_in_pages_readable(const char *uaddr, int size) +{ + volatile char c; + int ret; + + ret = __get_user(c, (char *)uaddr); + if (ret == 0) { + const char *end = uaddr + size - 1; + + if (((unsigned long)uaddr & PAGE_MASK) != + ((unsigned long)end & PAGE_MASK)) + __get_user(c, (char *)end); + } +} + #endif /* _LINUX_PAGEMAP_H */ diff -puN mm/filemap.c~fault_in_pages-move mm/filemap.c --- 25/mm/filemap.c~fault_in_pages-move 2003-02-14 18:23:56.000000000 -0800 +++ 25-akpm/mm/filemap.c 2003-02-14 18:23:56.000000000 -0800 @@ -678,50 +678,6 @@ no_cached_page: UPDATE_ATIME(inode); } -/* - * Fault a userspace page into pagetables. Return non-zero on a fault. - * - * FIXME: this assumes that two userspace pages are always sufficient. That's - * not true if PAGE_CACHE_SIZE > PAGE_SIZE. - */ -static inline int fault_in_pages_writeable(char *uaddr, int size) -{ - int ret; - - /* - * Writing zeroes into userspace here is OK, because we know that if - * the zero gets there, we'll be overwriting it. - */ - ret = __put_user(0, uaddr); - if (ret == 0) { - char *end = uaddr + size - 1; - - /* - * If the page was already mapped, this will get a cache miss - * for sure, so try to avoid doing it. - */ - if (((unsigned long)uaddr & PAGE_MASK) != - ((unsigned long)end & PAGE_MASK)) - ret = __put_user(0, end); - } - return ret; -} - -static void fault_in_pages_readable(const char *uaddr, int size) -{ - volatile char c; - int ret; - - ret = __get_user(c, (char *)uaddr); - if (ret == 0) { - const char *end = uaddr + size - 1; - - if (((unsigned long)uaddr & PAGE_MASK) != - ((unsigned long)end & PAGE_MASK)) - __get_user(c, (char *)end); - } -} - int file_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset, unsigned long size) { _