aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/9p/vfs_file.c')
-rw-r--r--fs/9p/vfs_file.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 68bf2af6c389..3902bf43a088 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -32,6 +32,7 @@
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/inet.h> 33#include <linux/inet.h>
34#include <linux/list.h> 34#include <linux/list.h>
35#include <linux/pagemap.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36#include <linux/idr.h> 37#include <linux/idr.h>
37#include <net/9p/9p.h> 38#include <net/9p/9p.h>
@@ -40,6 +41,7 @@
40#include "v9fs.h" 41#include "v9fs.h"
41#include "v9fs_vfs.h" 42#include "v9fs_vfs.h"
42#include "fid.h" 43#include "fid.h"
44#include "cache.h"
43 45
44static const struct file_operations v9fs_cached_file_operations; 46static const struct file_operations v9fs_cached_file_operations;
45 47
@@ -72,7 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
72 return err; 74 return err;
73 } 75 }
74 if (omode & P9_OTRUNC) { 76 if (omode & P9_OTRUNC) {
75 inode->i_size = 0; 77 i_size_write(inode, 0);
76 inode->i_blocks = 0; 78 inode->i_blocks = 0;
77 } 79 }
78 if ((file->f_flags & O_APPEND) && (!v9fs_extended(v9ses))) 80 if ((file->f_flags & O_APPEND) && (!v9fs_extended(v9ses)))
@@ -85,6 +87,10 @@ int v9fs_file_open(struct inode *inode, struct file *file)
85 /* enable cached file options */ 87 /* enable cached file options */
86 if(file->f_op == &v9fs_file_operations) 88 if(file->f_op == &v9fs_file_operations)
87 file->f_op = &v9fs_cached_file_operations; 89 file->f_op = &v9fs_cached_file_operations;
90
91#ifdef CONFIG_9P_FSCACHE
92 v9fs_cache_inode_set_cookie(inode, file);
93#endif
88 } 94 }
89 95
90 return 0; 96 return 0;
@@ -210,6 +216,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
210 struct p9_client *clnt; 216 struct p9_client *clnt;
211 struct inode *inode = filp->f_path.dentry->d_inode; 217 struct inode *inode = filp->f_path.dentry->d_inode;
212 int origin = *offset; 218 int origin = *offset;
219 unsigned long pg_start, pg_end;
213 220
214 P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data, 221 P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data,
215 (int)count, (int)*offset); 222 (int)count, (int)*offset);
@@ -225,7 +232,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
225 if (count < rsize) 232 if (count < rsize)
226 rsize = count; 233 rsize = count;
227 234
228 n = p9_client_write(fid, NULL, data+total, *offset+total, 235 n = p9_client_write(fid, NULL, data+total, origin+total,
229 rsize); 236 rsize);
230 if (n <= 0) 237 if (n <= 0)
231 break; 238 break;
@@ -234,14 +241,14 @@ v9fs_file_write(struct file *filp, const char __user * data,
234 } while (count > 0); 241 } while (count > 0);
235 242
236 if (total > 0) { 243 if (total > 0) {
237 invalidate_inode_pages2_range(inode->i_mapping, origin, 244 pg_start = origin >> PAGE_CACHE_SHIFT;
238 origin+total); 245 pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT;
246 if (inode->i_mapping && inode->i_mapping->nrpages)
247 invalidate_inode_pages2_range(inode->i_mapping,
248 pg_start, pg_end);
239 *offset += total; 249 *offset += total;
240 } 250 i_size_write(inode, i_size_read(inode) + total);
241 251 inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
242 if (*offset > inode->i_size) {
243 inode->i_size = *offset;
244 inode->i_blocks = (inode->i_size + 512 - 1) >> 9;
245 } 252 }
246 253
247 if (n < 0) 254 if (n < 0)