diff options
-rw-r--r-- | fs/9p/Makefile | 1 | ||||
-rw-r--r-- | fs/9p/v9fs_vfs.h | 1 | ||||
-rw-r--r-- | fs/9p/vfs_addr.c | 109 | ||||
-rw-r--r-- | fs/9p/vfs_file.c | 4 | ||||
-rw-r--r-- | fs/9p/vfs_inode.c | 1 |
5 files changed, 116 insertions, 0 deletions
diff --git a/fs/9p/Makefile b/fs/9p/Makefile index 3d023089707e..2f4ce43f7b6c 100644 --- a/fs/9p/Makefile +++ b/fs/9p/Makefile | |||
@@ -8,6 +8,7 @@ obj-$(CONFIG_9P_FS) := 9p2000.o | |||
8 | conv.o \ | 8 | conv.o \ |
9 | vfs_super.o \ | 9 | vfs_super.o \ |
10 | vfs_inode.o \ | 10 | vfs_inode.o \ |
11 | vfs_addr.o \ | ||
11 | vfs_file.o \ | 12 | vfs_file.o \ |
12 | vfs_dir.o \ | 13 | vfs_dir.o \ |
13 | vfs_dentry.o \ | 14 | vfs_dentry.o \ |
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index c78502ad00ed..69cf2905dc90 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -39,6 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | extern struct file_system_type v9fs_fs_type; | 41 | extern struct file_system_type v9fs_fs_type; |
42 | extern struct address_space_operations v9fs_addr_operations; | ||
42 | extern struct file_operations v9fs_file_operations; | 43 | extern struct file_operations v9fs_file_operations; |
43 | extern struct file_operations v9fs_dir_operations; | 44 | extern struct file_operations v9fs_dir_operations; |
44 | extern struct dentry_operations v9fs_dentry_operations; | 45 | extern struct dentry_operations v9fs_dentry_operations; |
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c new file mode 100644 index 000000000000..8100fb5171b7 --- /dev/null +++ b/fs/9p/vfs_addr.c | |||
@@ -0,0 +1,109 @@ | |||
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 | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to: | ||
21 | * Free Software Foundation | ||
22 | * 51 Franklin Street, Fifth Floor | ||
23 | * Boston, MA 02111-1301 USA | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include <linux/module.h> | ||
28 | #include <linux/errno.h> | ||
29 | #include <linux/fs.h> | ||
30 | #include <linux/file.h> | ||
31 | #include <linux/stat.h> | ||
32 | #include <linux/string.h> | ||
33 | #include <linux/smp_lock.h> | ||
34 | #include <linux/inet.h> | ||
35 | #include <linux/version.h> | ||
36 | #include <linux/pagemap.h> | ||
37 | #include <linux/idr.h> | ||
38 | |||
39 | #include "debug.h" | ||
40 | #include "v9fs.h" | ||
41 | #include "9p.h" | ||
42 | #include "v9fs_vfs.h" | ||
43 | #include "fid.h" | ||
44 | |||
45 | /** | ||
46 | * v9fs_vfs_readpage - read an entire page in from 9P | ||
47 | * | ||
48 | * @file: file being read | ||
49 | * @page: structure to page | ||
50 | * | ||
51 | */ | ||
52 | |||
53 | static int v9fs_vfs_readpage(struct file *filp, struct page *page) | ||
54 | { | ||
55 | char *buffer = NULL; | ||
56 | int retval = -EIO; | ||
57 | loff_t offset = page_offset(page); | ||
58 | int count = PAGE_CACHE_SIZE; | ||
59 | struct inode *inode = filp->f_dentry->d_inode; | ||
60 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); | ||
61 | int rsize = v9ses->maxdata - V9FS_IOHDRSZ; | ||
62 | struct v9fs_fid *v9f = filp->private_data; | ||
63 | struct v9fs_fcall *fcall = NULL; | ||
64 | int fid = v9f->fid; | ||
65 | int total = 0; | ||
66 | int result = 0; | ||
67 | |||
68 | buffer = kmap(page); | ||
69 | do { | ||
70 | if (count < rsize) | ||
71 | rsize = count; | ||
72 | |||
73 | result = v9fs_t_read(v9ses, fid, offset, rsize, &fcall); | ||
74 | |||
75 | if (result < 0) { | ||
76 | printk(KERN_ERR "v9fs_t_read returned %d\n", | ||
77 | result); | ||
78 | |||
79 | kfree(fcall); | ||
80 | goto UnmapAndUnlock; | ||
81 | } else | ||
82 | offset += result; | ||
83 | |||
84 | memcpy(buffer, fcall->params.rread.data, result); | ||
85 | |||
86 | count -= result; | ||
87 | buffer += result; | ||
88 | total += result; | ||
89 | |||
90 | kfree(fcall); | ||
91 | |||
92 | if (result < rsize) | ||
93 | break; | ||
94 | } while (count); | ||
95 | |||
96 | memset(buffer, 0, count); | ||
97 | flush_dcache_page(page); | ||
98 | SetPageUptodate(page); | ||
99 | retval = 0; | ||
100 | |||
101 | UnmapAndUnlock: | ||
102 | kunmap(page); | ||
103 | unlock_page(page); | ||
104 | return retval; | ||
105 | } | ||
106 | |||
107 | struct address_space_operations v9fs_addr_operations = { | ||
108 | .readpage = v9fs_vfs_readpage, | ||
109 | }; | ||
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 6852f0eb96ed..c7e14d917215 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -289,6 +289,9 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
289 | total += result; | 289 | total += result; |
290 | } while (count); | 290 | } while (count); |
291 | 291 | ||
292 | if(inode->i_mapping->nrpages) | ||
293 | invalidate_inode_pages2(inode->i_mapping); | ||
294 | |||
292 | return total; | 295 | return total; |
293 | } | 296 | } |
294 | 297 | ||
@@ -299,4 +302,5 @@ struct file_operations v9fs_file_operations = { | |||
299 | .open = v9fs_file_open, | 302 | .open = v9fs_file_open, |
300 | .release = v9fs_dir_release, | 303 | .release = v9fs_dir_release, |
301 | .lock = v9fs_file_lock, | 304 | .lock = v9fs_file_lock, |
305 | .mmap = generic_file_mmap, | ||
302 | }; | 306 | }; |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index a17b28854288..91f552454c76 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -177,6 +177,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
177 | inode->i_blocks = 0; | 177 | inode->i_blocks = 0; |
178 | inode->i_rdev = 0; | 178 | inode->i_rdev = 0; |
179 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 179 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
180 | inode->i_mapping->a_ops = &v9fs_addr_operations; | ||
180 | 181 | ||
181 | switch (mode & S_IFMT) { | 182 | switch (mode & S_IFMT) { |
182 | case S_IFIFO: | 183 | case S_IFIFO: |