aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--fs/9p/v9fs.c9
-rw-r--r--fs/9p/v9fs.h1
-rw-r--r--fs/9p/v9fs_vfs.h2
-rw-r--r--fs/9p/vfs_addr.c7
-rw-r--r--fs/9p/vfs_file.c140
-rw-r--r--fs/9p/vfs_inode.c22
-rw-r--r--fs/9p/vfs_inode_dotl.c9
-rw-r--r--fs/9p/vfs_super.c8
8 files changed, 179 insertions, 19 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 08f2e1e9a7e6..14da82564f4e 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -56,7 +56,7 @@ enum {
56 /* Options that take no arguments */ 56 /* Options that take no arguments */
57 Opt_nodevmap, 57 Opt_nodevmap,
58 /* Cache options */ 58 /* Cache options */
59 Opt_cache_loose, Opt_fscache, 59 Opt_cache_loose, Opt_fscache, Opt_mmap,
60 /* Access options */ 60 /* Access options */
61 Opt_access, Opt_posixacl, 61 Opt_access, Opt_posixacl,
62 /* Error token */ 62 /* Error token */
@@ -74,6 +74,7 @@ static const match_table_t tokens = {
74 {Opt_cache, "cache=%s"}, 74 {Opt_cache, "cache=%s"},
75 {Opt_cache_loose, "loose"}, 75 {Opt_cache_loose, "loose"},
76 {Opt_fscache, "fscache"}, 76 {Opt_fscache, "fscache"},
77 {Opt_mmap, "mmap"},
77 {Opt_cachetag, "cachetag=%s"}, 78 {Opt_cachetag, "cachetag=%s"},
78 {Opt_access, "access=%s"}, 79 {Opt_access, "access=%s"},
79 {Opt_posixacl, "posixacl"}, 80 {Opt_posixacl, "posixacl"},
@@ -91,6 +92,9 @@ static int get_cache_mode(char *s)
91 } else if (!strcmp(s, "fscache")) { 92 } else if (!strcmp(s, "fscache")) {
92 version = CACHE_FSCACHE; 93 version = CACHE_FSCACHE;
93 p9_debug(P9_DEBUG_9P, "Cache mode: fscache\n"); 94 p9_debug(P9_DEBUG_9P, "Cache mode: fscache\n");
95 } else if (!strcmp(s, "mmap")) {
96 version = CACHE_MMAP;
97 p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n");
94 } else if (!strcmp(s, "none")) { 98 } else if (!strcmp(s, "none")) {
95 version = CACHE_NONE; 99 version = CACHE_NONE;
96 p9_debug(P9_DEBUG_9P, "Cache mode: none\n"); 100 p9_debug(P9_DEBUG_9P, "Cache mode: none\n");
@@ -220,6 +224,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
220 case Opt_fscache: 224 case Opt_fscache:
221 v9ses->cache = CACHE_FSCACHE; 225 v9ses->cache = CACHE_FSCACHE;
222 break; 226 break;
227 case Opt_mmap:
228 v9ses->cache = CACHE_MMAP;
229 break;
223 case Opt_cachetag: 230 case Opt_cachetag:
224#ifdef CONFIG_9P_FSCACHE 231#ifdef CONFIG_9P_FSCACHE
225 v9ses->cachetag = match_strdup(&args[0]); 232 v9ses->cachetag = match_strdup(&args[0]);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index a8e127c89627..099c7712631c 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -64,6 +64,7 @@ enum p9_session_flags {
64 64
65enum p9_cache_modes { 65enum p9_cache_modes {
66 CACHE_NONE, 66 CACHE_NONE,
67 CACHE_MMAP,
67 CACHE_LOOSE, 68 CACHE_LOOSE,
68 CACHE_FSCACHE, 69 CACHE_FSCACHE,
69}; 70};
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index dc95a252523d..b83ebfbf3fdc 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -50,6 +50,8 @@ extern const struct dentry_operations v9fs_dentry_operations;
50extern const struct dentry_operations v9fs_cached_dentry_operations; 50extern const struct dentry_operations v9fs_cached_dentry_operations;
51extern const struct file_operations v9fs_cached_file_operations; 51extern const struct file_operations v9fs_cached_file_operations;
52extern const struct file_operations v9fs_cached_file_operations_dotl; 52extern const struct file_operations v9fs_cached_file_operations_dotl;
53extern const struct file_operations v9fs_mmap_file_operations;
54extern const struct file_operations v9fs_mmap_file_operations_dotl;
53extern struct kmem_cache *v9fs_inode_cache; 55extern struct kmem_cache *v9fs_inode_cache;
54 56
55struct inode *v9fs_alloc_inode(struct super_block *sb); 57struct inode *v9fs_alloc_inode(struct super_block *sb);
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 9ff073f4090a..c71e88602ff4 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -202,6 +202,8 @@ static int v9fs_vfs_writepage(struct page *page, struct writeback_control *wbc)
202{ 202{
203 int retval; 203 int retval;
204 204
205 p9_debug(P9_DEBUG_VFS, "page %p\n", page);
206
205 retval = v9fs_vfs_writepage_locked(page); 207 retval = v9fs_vfs_writepage_locked(page);
206 if (retval < 0) { 208 if (retval < 0) {
207 if (retval == -EAGAIN) { 209 if (retval == -EAGAIN) {
@@ -282,6 +284,9 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
282 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 284 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
283 struct inode *inode = mapping->host; 285 struct inode *inode = mapping->host;
284 286
287
288 p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
289
285 v9inode = V9FS_I(inode); 290 v9inode = V9FS_I(inode);
286start: 291start:
287 page = grab_cache_page_write_begin(mapping, index, flags); 292 page = grab_cache_page_write_begin(mapping, index, flags);
@@ -312,6 +317,8 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
312 loff_t last_pos = pos + copied; 317 loff_t last_pos = pos + copied;
313 struct inode *inode = page->mapping->host; 318 struct inode *inode = page->mapping->host;
314 319
320 p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
321
315 if (unlikely(copied < len)) { 322 if (unlikely(copied < len)) {
316 /* 323 /*
317 * zero out the rest of the area 324 * zero out the rest of the area
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 27782bb7f4f9..a16b0ff497ca 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -45,6 +45,7 @@
45#include "cache.h" 45#include "cache.h"
46 46
47static const struct vm_operations_struct v9fs_file_vm_ops; 47static const struct vm_operations_struct v9fs_file_vm_ops;
48static const struct vm_operations_struct v9fs_mmap_file_vm_ops;
48 49
49/** 50/**
50 * v9fs_file_open - open a file (or directory) 51 * v9fs_file_open - open a file (or directory)
@@ -87,7 +88,8 @@ int v9fs_file_open(struct inode *inode, struct file *file)
87 88
88 file->private_data = fid; 89 file->private_data = fid;
89 mutex_lock(&v9inode->v_mutex); 90 mutex_lock(&v9inode->v_mutex);
90 if (v9ses->cache && !v9inode->writeback_fid && 91 if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
92 !v9inode->writeback_fid &&
91 ((file->f_flags & O_ACCMODE) != O_RDONLY)) { 93 ((file->f_flags & O_ACCMODE) != O_RDONLY)) {
92 /* 94 /*
93 * clone a fid and add it to writeback_fid 95 * clone a fid and add it to writeback_fid
@@ -105,7 +107,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
105 v9inode->writeback_fid = (void *) fid; 107 v9inode->writeback_fid = (void *) fid;
106 } 108 }
107 mutex_unlock(&v9inode->v_mutex); 109 mutex_unlock(&v9inode->v_mutex);
108 if (v9ses->cache) 110 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
109 v9fs_cache_inode_set_cookie(inode, file); 111 v9fs_cache_inode_set_cookie(inode, file);
110 return 0; 112 return 0;
111out_error: 113out_error:
@@ -579,11 +581,12 @@ int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
579} 581}
580 582
581static int 583static int
582v9fs_file_mmap(struct file *file, struct vm_area_struct *vma) 584v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
583{ 585{
584 int retval; 586 int retval;
585 587
586 retval = generic_file_mmap(file, vma); 588
589 retval = generic_file_mmap(filp, vma);
587 if (!retval) 590 if (!retval)
588 vma->vm_ops = &v9fs_file_vm_ops; 591 vma->vm_ops = &v9fs_file_vm_ops;
589 592
@@ -591,6 +594,43 @@ v9fs_file_mmap(struct file *file, struct vm_area_struct *vma)
591} 594}
592 595
593static int 596static int
597v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
598{
599 int retval;
600 struct inode *inode;
601 struct v9fs_inode *v9inode;
602 struct p9_fid *fid;
603
604 inode = file_inode(filp);
605 v9inode = V9FS_I(inode);
606 mutex_lock(&v9inode->v_mutex);
607 if (!v9inode->writeback_fid &&
608 (vma->vm_flags & VM_WRITE)) {
609 /*
610 * clone a fid and add it to writeback_fid
611 * we do it during mmap instead of
612 * page dirty time via write_begin/page_mkwrite
613 * because we want write after unlink usecase
614 * to work.
615 */
616 fid = v9fs_writeback_fid(filp->f_path.dentry);
617 if (IS_ERR(fid)) {
618 retval = PTR_ERR(fid);
619 mutex_unlock(&v9inode->v_mutex);
620 return retval;
621 }
622 v9inode->writeback_fid = (void *) fid;
623 }
624 mutex_unlock(&v9inode->v_mutex);
625
626 retval = generic_file_mmap(filp, vma);
627 if (!retval)
628 vma->vm_ops = &v9fs_mmap_file_vm_ops;
629
630 return retval;
631}
632
633static int
594v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 634v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
595{ 635{
596 struct v9fs_inode *v9inode; 636 struct v9fs_inode *v9inode;
@@ -658,6 +698,22 @@ v9fs_cached_file_read(struct file *filp, char __user *data, size_t count,
658 return do_sync_read(filp, data, count, offset); 698 return do_sync_read(filp, data, count, offset);
659} 699}
660 700
701/**
702 * v9fs_mmap_file_read - read from a file
703 * @filp: file pointer to read
704 * @udata: user data buffer to read data into
705 * @count: size of buffer
706 * @offset: offset at which to read data
707 *
708 */
709static ssize_t
710v9fs_mmap_file_read(struct file *filp, char __user *data, size_t count,
711 loff_t *offset)
712{
713 /* TODO: Check if there are dirty pages */
714 return v9fs_file_read(filp, data, count, offset);
715}
716
661static ssize_t 717static ssize_t
662v9fs_direct_write(struct file *filp, const char __user * data, 718v9fs_direct_write(struct file *filp, const char __user * data,
663 size_t count, loff_t *offsetp) 719 size_t count, loff_t *offsetp)
@@ -728,12 +784,65 @@ v9fs_cached_file_write(struct file *filp, const char __user * data,
728 return do_sync_write(filp, data, count, offset); 784 return do_sync_write(filp, data, count, offset);
729} 785}
730 786
787
788/**
789 * v9fs_mmap_file_write - write to a file
790 * @filp: file pointer to write
791 * @data: data buffer to write data from
792 * @count: size of buffer
793 * @offset: offset at which to write data
794 *
795 */
796static ssize_t
797v9fs_mmap_file_write(struct file *filp, const char __user *data,
798 size_t count, loff_t *offset)
799{
800 /*
801 * TODO: invalidate mmaps on filp's inode between
802 * offset and offset+count
803 */
804 return v9fs_file_write(filp, data, count, offset);
805}
806
807static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
808{
809 struct inode *inode;
810
811 struct writeback_control wbc = {
812 .nr_to_write = LONG_MAX,
813 .sync_mode = WB_SYNC_ALL,
814 .range_start = vma->vm_pgoff * PAGE_SIZE,
815 /* absolute end, byte at end included */
816 .range_end = vma->vm_pgoff * PAGE_SIZE +
817 (vma->vm_end - vma->vm_start - 1),
818 };
819
820
821 p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma);
822
823 inode = file_inode(vma->vm_file);
824
825 if (!mapping_cap_writeback_dirty(inode->i_mapping))
826 wbc.nr_to_write = 0;
827
828 might_sleep();
829 sync_inode(inode, &wbc);
830}
831
832
731static const struct vm_operations_struct v9fs_file_vm_ops = { 833static const struct vm_operations_struct v9fs_file_vm_ops = {
732 .fault = filemap_fault, 834 .fault = filemap_fault,
733 .page_mkwrite = v9fs_vm_page_mkwrite, 835 .page_mkwrite = v9fs_vm_page_mkwrite,
734 .remap_pages = generic_file_remap_pages, 836 .remap_pages = generic_file_remap_pages,
735}; 837};
736 838
839static const struct vm_operations_struct v9fs_mmap_file_vm_ops = {
840 .close = v9fs_mmap_vm_close,
841 .fault = filemap_fault,
842 .page_mkwrite = v9fs_vm_page_mkwrite,
843 .remap_pages = generic_file_remap_pages,
844};
845
737 846
738const struct file_operations v9fs_cached_file_operations = { 847const struct file_operations v9fs_cached_file_operations = {
739 .llseek = generic_file_llseek, 848 .llseek = generic_file_llseek,
@@ -784,3 +893,26 @@ const struct file_operations v9fs_file_operations_dotl = {
784 .mmap = generic_file_readonly_mmap, 893 .mmap = generic_file_readonly_mmap,
785 .fsync = v9fs_file_fsync_dotl, 894 .fsync = v9fs_file_fsync_dotl,
786}; 895};
896
897const struct file_operations v9fs_mmap_file_operations = {
898 .llseek = generic_file_llseek,
899 .read = v9fs_mmap_file_read,
900 .write = v9fs_mmap_file_write,
901 .open = v9fs_file_open,
902 .release = v9fs_dir_release,
903 .lock = v9fs_file_lock,
904 .mmap = v9fs_mmap_file_mmap,
905 .fsync = v9fs_file_fsync,
906};
907
908const struct file_operations v9fs_mmap_file_operations_dotl = {
909 .llseek = generic_file_llseek,
910 .read = v9fs_mmap_file_read,
911 .write = v9fs_mmap_file_write,
912 .open = v9fs_file_open,
913 .release = v9fs_dir_release,
914 .lock = v9fs_file_lock_dotl,
915 .flock = v9fs_file_flock_dotl,
916 .mmap = v9fs_mmap_file_mmap,
917 .fsync = v9fs_file_fsync_dotl,
918};
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:
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 98013068f35b..59dc8e87647f 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -330,7 +330,8 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
330 330
331 v9inode = V9FS_I(inode); 331 v9inode = V9FS_I(inode);
332 mutex_lock(&v9inode->v_mutex); 332 mutex_lock(&v9inode->v_mutex);
333 if (v9ses->cache && !v9inode->writeback_fid && 333 if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
334 !v9inode->writeback_fid &&
334 ((flags & O_ACCMODE) != O_RDONLY)) { 335 ((flags & O_ACCMODE) != O_RDONLY)) {
335 /* 336 /*
336 * clone a fid and add it to writeback_fid 337 * clone a fid and add it to writeback_fid
@@ -353,7 +354,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
353 if (err) 354 if (err)
354 goto err_clunk_old_fid; 355 goto err_clunk_old_fid;
355 file->private_data = ofid; 356 file->private_data = ofid;
356 if (v9ses->cache) 357 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
357 v9fs_cache_inode_set_cookie(inode, file); 358 v9fs_cache_inode_set_cookie(inode, file);
358 *opened |= FILE_CREATED; 359 *opened |= FILE_CREATED;
359out: 360out:
@@ -710,7 +711,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
710 } 711 }
711 712
712 v9fs_invalidate_inode_attr(dir); 713 v9fs_invalidate_inode_attr(dir);
713 if (v9ses->cache) { 714 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
714 /* Now walk from the parent so we can get an unopened fid. */ 715 /* Now walk from the parent so we can get an unopened fid. */
715 fid = p9_client_walk(dfid, 1, &name, 1); 716 fid = p9_client_walk(dfid, 1, &name, 1);
716 if (IS_ERR(fid)) { 717 if (IS_ERR(fid)) {
@@ -965,7 +966,7 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
965 */ 966 */
966 i_size = inode->i_size; 967 i_size = inode->i_size;
967 v9fs_stat2inode_dotl(st, inode); 968 v9fs_stat2inode_dotl(st, inode);
968 if (v9ses->cache) 969 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
969 inode->i_size = i_size; 970 inode->i_size = i_size;
970 spin_unlock(&inode->i_lock); 971 spin_unlock(&inode->i_lock);
971out: 972out:
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 2756dcd5de6e..0afd0382822b 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -144,7 +144,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
144 } 144 }
145 v9fs_fill_super(sb, v9ses, flags, data); 145 v9fs_fill_super(sb, v9ses, flags, data);
146 146
147 if (v9ses->cache) 147 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
148 sb->s_d_op = &v9fs_cached_dentry_operations; 148 sb->s_d_op = &v9fs_cached_dentry_operations;
149 else 149 else
150 sb->s_d_op = &v9fs_dentry_operations; 150 sb->s_d_op = &v9fs_dentry_operations;
@@ -282,7 +282,7 @@ static int v9fs_drop_inode(struct inode *inode)
282{ 282{
283 struct v9fs_session_info *v9ses; 283 struct v9fs_session_info *v9ses;
284 v9ses = v9fs_inode2v9ses(inode); 284 v9ses = v9fs_inode2v9ses(inode);
285 if (v9ses->cache) 285 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
286 return generic_drop_inode(inode); 286 return generic_drop_inode(inode);
287 /* 287 /*
288 * in case of non cached mode always drop the 288 * in case of non cached mode always drop the
@@ -325,10 +325,12 @@ static int v9fs_write_inode_dotl(struct inode *inode,
325 * send an fsync request to server irrespective of 325 * send an fsync request to server irrespective of
326 * wbc->sync_mode. 326 * wbc->sync_mode.
327 */ 327 */
328 p9_debug(P9_DEBUG_VFS, "%s: inode %p\n", __func__, inode);
329 v9inode = V9FS_I(inode); 328 v9inode = V9FS_I(inode);
329 p9_debug(P9_DEBUG_VFS, "%s: inode %p, writeback_fid %p\n",
330 __func__, inode, v9inode->writeback_fid);
330 if (!v9inode->writeback_fid) 331 if (!v9inode->writeback_fid)
331 return 0; 332 return 0;
333
332 ret = p9_client_fsync(v9inode->writeback_fid, 0); 334 ret = p9_client_fsync(v9inode->writeback_fid, 0);
333 if (ret < 0) { 335 if (ret < 0) {
334 __mark_inode_dirty(inode, I_DIRTY_DATASYNC); 336 __mark_inode_dirty(inode, I_DIRTY_DATASYNC);