aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_inode.c
diff options
context:
space:
mode:
authorDominique Martinet <dominique.martinet@cea.fr>2014-01-10 07:44:09 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2014-01-10 10:20:51 -0500
commitfb89b45cdfdc8bdab93986f1bc1474e313295c31 (patch)
treec19ec0f84315c6dc77ca2447f58e2508b76ce88a /fs/9p/vfs_inode.c
parentf94741fd2832e7abc30fbf6dc13ed627c1fcc01a (diff)
9P: introduction of a new cache=mmap model.
- Add cache=mmap option - Make mmap read-write while keeping it as synchronous as possible - Build writeback fid on mmap creation if it is writable Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p/vfs_inode.c')
-rw-r--r--fs/9p/vfs_inode.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index af7d531bdecd..bb7991c7e5c7 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -299,15 +299,22 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
299 case S_IFREG: 299 case S_IFREG:
300 if (v9fs_proto_dotl(v9ses)) { 300 if (v9fs_proto_dotl(v9ses)) {
301 inode->i_op = &v9fs_file_inode_operations_dotl; 301 inode->i_op = &v9fs_file_inode_operations_dotl;
302 if (v9ses->cache) 302 if (v9ses->cache == CACHE_LOOSE ||
303 v9ses->cache == CACHE_FSCACHE)
303 inode->i_fop = 304 inode->i_fop =
304 &v9fs_cached_file_operations_dotl; 305 &v9fs_cached_file_operations_dotl;
306 else if (v9ses->cache == CACHE_MMAP)
307 inode->i_fop = &v9fs_mmap_file_operations_dotl;
305 else 308 else
306 inode->i_fop = &v9fs_file_operations_dotl; 309 inode->i_fop = &v9fs_file_operations_dotl;
307 } else { 310 } else {
308 inode->i_op = &v9fs_file_inode_operations; 311 inode->i_op = &v9fs_file_inode_operations;
309 if (v9ses->cache) 312 if (v9ses->cache == CACHE_LOOSE ||
310 inode->i_fop = &v9fs_cached_file_operations; 313 v9ses->cache == CACHE_FSCACHE)
314 inode->i_fop =
315 &v9fs_cached_file_operations;
316 else if (v9ses->cache == CACHE_MMAP)
317 inode->i_fop = &v9fs_mmap_file_operations;
311 else 318 else
312 inode->i_fop = &v9fs_file_operations; 319 inode->i_fop = &v9fs_file_operations;
313 } 320 }
@@ -810,7 +817,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
810 * unlink. For cached mode create calls request for new 817 * unlink. For cached mode create calls request for new
811 * inode. But with cache disabled, lookup should do this. 818 * inode. But with cache disabled, lookup should do this.
812 */ 819 */
813 if (v9ses->cache) 820 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
814 inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); 821 inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
815 else 822 else
816 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 823 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
@@ -876,7 +883,8 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
876 v9fs_invalidate_inode_attr(dir); 883 v9fs_invalidate_inode_attr(dir);
877 v9inode = V9FS_I(dentry->d_inode); 884 v9inode = V9FS_I(dentry->d_inode);
878 mutex_lock(&v9inode->v_mutex); 885 mutex_lock(&v9inode->v_mutex);
879 if (v9ses->cache && !v9inode->writeback_fid && 886 if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
887 !v9inode->writeback_fid &&
880 ((flags & O_ACCMODE) != O_RDONLY)) { 888 ((flags & O_ACCMODE) != O_RDONLY)) {
881 /* 889 /*
882 * clone a fid and add it to writeback_fid 890 * clone a fid and add it to writeback_fid
@@ -899,7 +907,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
899 goto error; 907 goto error;
900 908
901 file->private_data = fid; 909 file->private_data = fid;
902 if (v9ses->cache) 910 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
903 v9fs_cache_inode_set_cookie(dentry->d_inode, file); 911 v9fs_cache_inode_set_cookie(dentry->d_inode, file);
904 912
905 *opened |= FILE_CREATED; 913 *opened |= FILE_CREATED;
@@ -1477,7 +1485,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
1477 */ 1485 */
1478 i_size = inode->i_size; 1486 i_size = inode->i_size;
1479 v9fs_stat2inode(st, inode, inode->i_sb); 1487 v9fs_stat2inode(st, inode, inode->i_sb);
1480 if (v9ses->cache) 1488 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
1481 inode->i_size = i_size; 1489 inode->i_size = i_size;
1482 spin_unlock(&inode->i_lock); 1490 spin_unlock(&inode->i_lock);
1483out: 1491out: