aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-02-28 06:33:54 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2011-03-15 10:57:36 -0400
commit29236f4e18dde0c772968b6ce965d0365fe3fe4e (patch)
treeabbfd30756c96fbd3a318986b91738120ed058f8
parentf735195d51e10b2550097f7b0ac12219060e962b (diff)
fs/9p: set the cached file_operations struct during inode init
With the old code we were not setting the file->f_op with cached file operations during creat. (format correction by jvrao@linux.vnet.ibm.com) Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r--fs/9p/v9fs_vfs.h2
-rw-r--r--fs/9p/vfs_file.c18
-rw-r--r--fs/9p/vfs_inode.c11
3 files changed, 15 insertions, 16 deletions
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index b789f8e597ec..e4d5540cbb70 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -45,6 +45,8 @@ extern const struct file_operations v9fs_dir_operations;
45extern const struct file_operations v9fs_dir_operations_dotl; 45extern const struct file_operations v9fs_dir_operations_dotl;
46extern const struct dentry_operations v9fs_dentry_operations; 46extern const struct dentry_operations v9fs_dentry_operations;
47extern const struct dentry_operations v9fs_cached_dentry_operations; 47extern const struct dentry_operations v9fs_cached_dentry_operations;
48extern const struct file_operations v9fs_cached_file_operations;
49extern const struct file_operations v9fs_cached_file_operations_dotl;
48 50
49#ifdef CONFIG_9P_FSCACHE 51#ifdef CONFIG_9P_FSCACHE
50struct inode *v9fs_alloc_inode(struct super_block *sb); 52struct inode *v9fs_alloc_inode(struct super_block *sb);
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 240c30674396..6a671000263f 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -44,9 +44,6 @@
44#include "fid.h" 44#include "fid.h"
45#include "cache.h" 45#include "cache.h"
46 46
47static const struct file_operations v9fs_cached_file_operations;
48static const struct file_operations v9fs_cached_file_operations_dotl;
49
50/** 47/**
51 * v9fs_file_open - open a file (or directory) 48 * v9fs_file_open - open a file (or directory)
52 * @inode: inode to be opened 49 * @inode: inode to be opened
@@ -89,19 +86,12 @@ int v9fs_file_open(struct inode *inode, struct file *file)
89 } 86 }
90 87
91 file->private_data = fid; 88 file->private_data = fid;
89#ifdef CONFIG_9P_FSCACHE
92 if ((fid->qid.version) && (v9ses->cache)) { 90 if ((fid->qid.version) && (v9ses->cache)) {
93 P9_DPRINTK(P9_DEBUG_VFS, "cached"); 91 P9_DPRINTK(P9_DEBUG_VFS, "cached");
94 /* enable cached file options */
95 if(file->f_op == &v9fs_file_operations)
96 file->f_op = &v9fs_cached_file_operations;
97 else if (file->f_op == &v9fs_file_operations_dotl)
98 file->f_op = &v9fs_cached_file_operations_dotl;
99
100#ifdef CONFIG_9P_FSCACHE
101 v9fs_cache_inode_set_cookie(inode, file); 92 v9fs_cache_inode_set_cookie(inode, file);
102#endif
103 } 93 }
104 94#endif
105 return 0; 95 return 0;
106} 96}
107 97
@@ -505,7 +495,7 @@ int v9fs_file_fsync_dotl(struct file *filp, int datasync)
505 return retval; 495 return retval;
506} 496}
507 497
508static const struct file_operations v9fs_cached_file_operations = { 498const struct file_operations v9fs_cached_file_operations = {
509 .llseek = generic_file_llseek, 499 .llseek = generic_file_llseek,
510 .read = do_sync_read, 500 .read = do_sync_read,
511 .aio_read = generic_file_aio_read, 501 .aio_read = generic_file_aio_read,
@@ -517,7 +507,7 @@ static const struct file_operations v9fs_cached_file_operations = {
517 .fsync = v9fs_file_fsync, 507 .fsync = v9fs_file_fsync,
518}; 508};
519 509
520static const struct file_operations v9fs_cached_file_operations_dotl = { 510const struct file_operations v9fs_cached_file_operations_dotl = {
521 .llseek = generic_file_llseek, 511 .llseek = generic_file_llseek,
522 .read = do_sync_read, 512 .read = do_sync_read,
523 .aio_read = generic_file_aio_read, 513 .aio_read = generic_file_aio_read,
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index b76a40bdf4c2..83af2b7e65db 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -292,10 +292,17 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
292 case S_IFREG: 292 case S_IFREG:
293 if (v9fs_proto_dotl(v9ses)) { 293 if (v9fs_proto_dotl(v9ses)) {
294 inode->i_op = &v9fs_file_inode_operations_dotl; 294 inode->i_op = &v9fs_file_inode_operations_dotl;
295 inode->i_fop = &v9fs_file_operations_dotl; 295 if (v9ses->cache)
296 inode->i_fop =
297 &v9fs_cached_file_operations_dotl;
298 else
299 inode->i_fop = &v9fs_file_operations_dotl;
296 } else { 300 } else {
297 inode->i_op = &v9fs_file_inode_operations; 301 inode->i_op = &v9fs_file_inode_operations;
298 inode->i_fop = &v9fs_file_operations; 302 if (v9ses->cache)
303 inode->i_fop = &v9fs_cached_file_operations;
304 else
305 inode->i_fop = &v9fs_file_operations;
299 } 306 }
300 307
301 break; 308 break;