diff options
author | Abhishek Kulkarni <adkulkar@umail.iu.edu> | 2009-09-23 14:00:27 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@strongmad.austin.ibm.com> | 2009-09-23 14:03:46 -0400 |
commit | 60e78d2c993e58d890596d951fff77d5965adcd6 (patch) | |
tree | 3d53ed7254c613ef8d8de36fdceda25bc493f4f7 /fs/9p/vfs_file.c | |
parent | 637d020a02cd734bf27acfc56c6d942cddd9eb80 (diff) |
9p: Add fscache support to 9p
This patch adds a persistent, read-only caching facility for
9p clients using the FS-Cache caching backend.
When the fscache facility is enabled, each inode is associated
with a corresponding vcookie which is an index into the FS-Cache
indexing tree. The FS-Cache indexing tree is indexed at 3 levels:
- session object associated with each mount.
- inode/vcookie
- actual data (pages)
A cache tag is chosen randomly for each session. These tags can
be read off /sys/fs/9p/caches and can be passed as a mount-time
parameter to re-attach to the specified caching session.
Signed-off-by: Abhishek Kulkarni <adkulkar@umail.iu.edu>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p/vfs_file.c')
-rw-r--r-- | fs/9p/vfs_file.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index cafaa46434ba..3902bf43a088 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include "v9fs.h" | 41 | #include "v9fs.h" |
42 | #include "v9fs_vfs.h" | 42 | #include "v9fs_vfs.h" |
43 | #include "fid.h" | 43 | #include "fid.h" |
44 | #include "cache.h" | ||
44 | 45 | ||
45 | static const struct file_operations v9fs_cached_file_operations; | 46 | static const struct file_operations v9fs_cached_file_operations; |
46 | 47 | ||
@@ -86,6 +87,10 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
86 | /* enable cached file options */ | 87 | /* enable cached file options */ |
87 | if(file->f_op == &v9fs_file_operations) | 88 | if(file->f_op == &v9fs_file_operations) |
88 | 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 | ||
89 | } | 94 | } |
90 | 95 | ||
91 | return 0; | 96 | return 0; |
@@ -238,8 +243,9 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
238 | if (total > 0) { | 243 | if (total > 0) { |
239 | pg_start = origin >> PAGE_CACHE_SHIFT; | 244 | pg_start = origin >> PAGE_CACHE_SHIFT; |
240 | pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT; | 245 | pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT; |
241 | invalidate_inode_pages2_range(inode->i_mapping, pg_start, | 246 | if (inode->i_mapping && inode->i_mapping->nrpages) |
242 | pg_end); | 247 | invalidate_inode_pages2_range(inode->i_mapping, |
248 | pg_start, pg_end); | ||
243 | *offset += total; | 249 | *offset += total; |
244 | i_size_write(inode, i_size_read(inode) + total); | 250 | i_size_write(inode, i_size_read(inode) + total); |
245 | inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9; | 251 | inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9; |