Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/9p/vfs_addr.c |
| 3 | * |
| 4 | * This file contians vfs address (mmap) ops for 9P2000. |
| 5 | * |
| 6 | * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com> |
| 7 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
Eric Van Hensbergen | 42e8c50 | 2006-03-25 03:07:28 -0800 | [diff] [blame] | 10 | * it under the terms of the GNU General Public License version 2 |
| 11 | * as published by the Free Software Foundation. |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to: |
| 20 | * Free Software Foundation |
| 21 | * 51 Franklin Street, Fifth Floor |
| 22 | * Boston, MA 02111-1301 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/errno.h> |
| 28 | #include <linux/fs.h> |
| 29 | #include <linux/file.h> |
| 30 | #include <linux/stat.h> |
| 31 | #include <linux/string.h> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 32 | #include <linux/inet.h> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 33 | #include <linux/pagemap.h> |
| 34 | #include <linux/idr.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 35 | #include <linux/sched.h> |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 36 | #include <net/9p/9p.h> |
| 37 | #include <net/9p/client.h> |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 38 | |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 39 | #include "v9fs.h" |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 40 | #include "v9fs_vfs.h" |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * v9fs_vfs_readpage - read an entire page in from 9P |
| 44 | * |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 45 | * @filp: file being read |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 46 | * @page: structure to page |
| 47 | * |
| 48 | */ |
| 49 | |
| 50 | static int v9fs_vfs_readpage(struct file *filp, struct page *page) |
| 51 | { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 52 | int retval; |
| 53 | loff_t offset; |
| 54 | char *buffer; |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 55 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 56 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 57 | buffer = kmap(page); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 58 | offset = page_offset(page); |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 59 | |
Eric Van Hensbergen | fbedadc | 2008-10-13 20:36:16 -0500 | [diff] [blame] | 60 | retval = v9fs_file_readn(filp, buffer, NULL, offset, PAGE_CACHE_SIZE); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 61 | if (retval < 0) |
| 62 | goto done; |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 63 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 64 | memset(buffer + retval, 0, PAGE_CACHE_SIZE - retval); |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 65 | flush_dcache_page(page); |
| 66 | SetPageUptodate(page); |
| 67 | retval = 0; |
| 68 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 69 | done: |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 70 | kunmap(page); |
| 71 | unlock_page(page); |
| 72 | return retval; |
| 73 | } |
| 74 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 75 | const struct address_space_operations v9fs_addr_operations = { |
Eric Van Hensbergen | 147b31c | 2006-01-18 17:43:02 -0800 | [diff] [blame] | 76 | .readpage = v9fs_vfs_readpage, |
| 77 | }; |