aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-26 13:55:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-26 13:55:41 -0500
commit1c2948380b699dfdbb25a7de740392dd9e6f0613 (patch)
treef1a9fc2903c0cc85b24dd2fb279f89597976670d
parentb2e448eca1a52fea181905845728ae00a138d84e (diff)
parentb871866e4aa3f44b10f0f0ce004cc4635c2e58a5 (diff)
Merge tag 'for-3.14-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
Pull 9p changes from Eric Van Hensbergen: "Included are a new cache model for support of mmap, and several cleanups across the filesystem and networking portions of the code" * tag 'for-3.14-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: 9p: update documentation 9P: introduction of a new cache=mmap model. net/9p: remove virtio default hack and set appropriate bits instead 9p: remove useless 'name' variable and assignment 9p: fix return value in case in v9fs_fid_xattr_set() 9p: remove useless variable and assignment 9p: remove useless assignment 9p: remove unused 'super_block' struct pointer 9p: remove never used return variable 9p: remove unused 'p9_fid' struct pointer 9p: remove unused 'p9_client' struct pointer
-rw-r--r--Documentation/filesystems/9p.txt17
-rw-r--r--fs/9p/cache.c3
-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.c142
-rw-r--r--fs/9p/vfs_inode.c26
-rw-r--r--fs/9p/vfs_inode_dotl.c17
-rw-r--r--fs/9p/vfs_super.c8
-rw-r--r--fs/9p/xattr.c10
-rw-r--r--net/9p/client.c3
-rw-r--r--net/9p/trans_fd.c2
-rw-r--r--net/9p/trans_virtio.c2
14 files changed, 195 insertions, 54 deletions
diff --git a/Documentation/filesystems/9p.txt b/Documentation/filesystems/9p.txt
index 2c0321442845..fec7144e817c 100644
--- a/Documentation/filesystems/9p.txt
+++ b/Documentation/filesystems/9p.txt
@@ -69,10 +69,14 @@ OPTIONS
69 offering several exported file systems. 69 offering several exported file systems.
70 70
71 cache=mode specifies a caching policy. By default, no caches are used. 71 cache=mode specifies a caching policy. By default, no caches are used.
72 none = default no cache policy, metadata and data
73 alike are synchronous.
72 loose = no attempts are made at consistency, 74 loose = no attempts are made at consistency,
73 intended for exclusive, read-only mounts 75 intended for exclusive, read-only mounts
74 fscache = use FS-Cache for a persistent, read-only 76 fscache = use FS-Cache for a persistent, read-only
75 cache backend. 77 cache backend.
78 mmap = minimal cache that is only used for read-write
79 mmap. Northing else is cached, like cache=none
76 80
77 debug=n specifies debug level. The debug level is a bitmask. 81 debug=n specifies debug level. The debug level is a bitmask.
78 0x01 = display verbose error messages 82 0x01 = display verbose error messages
@@ -147,8 +151,7 @@ on sourceforge (http://sourceforge.net/projects/v9fs).
147News and other information is maintained on a Wiki. 151News and other information is maintained on a Wiki.
148(http://sf.net/apps/mediawiki/v9fs/index.php). 152(http://sf.net/apps/mediawiki/v9fs/index.php).
149 153
150Bug reports may be issued through the kernel.org bugzilla 154Bug reports are best issued via the mailing list.
151(http://bugzilla.kernel.org)
152 155
153For more information on the Plan 9 Operating System check out 156For more information on the Plan 9 Operating System check out
154http://plan9.bell-labs.com/plan9 157http://plan9.bell-labs.com/plan9
@@ -156,11 +159,3 @@ http://plan9.bell-labs.com/plan9
156For information on Plan 9 from User Space (Plan 9 applications and libraries 159For information on Plan 9 from User Space (Plan 9 applications and libraries
157ported to Linux/BSD/OSX/etc) check out http://swtch.com/plan9 160ported to Linux/BSD/OSX/etc) check out http://swtch.com/plan9
158 161
159
160STATUS
161======
162
163The 2.6 kernel support is working on PPC and x86.
164
165PLEASE USE THE KERNEL BUGZILLA TO REPORT PROBLEMS. (http://bugzilla.kernel.org)
166
diff --git a/fs/9p/cache.c b/fs/9p/cache.c
index 2b7a032c37bc..a69260f27555 100644
--- a/fs/9p/cache.c
+++ b/fs/9p/cache.c
@@ -239,13 +239,12 @@ void v9fs_cache_inode_flush_cookie(struct inode *inode)
239void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp) 239void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp)
240{ 240{
241 struct v9fs_inode *v9inode = V9FS_I(inode); 241 struct v9fs_inode *v9inode = V9FS_I(inode);
242 struct p9_fid *fid;
243 242
244 if (!v9inode->fscache) 243 if (!v9inode->fscache)
245 return; 244 return;
246 245
247 spin_lock(&v9inode->fscache_lock); 246 spin_lock(&v9inode->fscache_lock);
248 fid = filp->private_data; 247
249 if ((filp->f_flags & O_ACCMODE) != O_RDONLY) 248 if ((filp->f_flags & O_ACCMODE) != O_RDONLY)
250 v9fs_cache_inode_flush_cookie(inode); 249 v9fs_cache_inode_flush_cookie(inode);
251 else 250 else
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 a0df3e73c2b1..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:
@@ -461,14 +463,12 @@ v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid,
461 int n; 463 int n;
462 loff_t i_size; 464 loff_t i_size;
463 size_t total = 0; 465 size_t total = 0;
464 struct p9_client *clnt;
465 loff_t origin = *offset; 466 loff_t origin = *offset;
466 unsigned long pg_start, pg_end; 467 unsigned long pg_start, pg_end;
467 468
468 p9_debug(P9_DEBUG_VFS, "data %p count %d offset %x\n", 469 p9_debug(P9_DEBUG_VFS, "data %p count %d offset %x\n",
469 data, (int)count, (int)*offset); 470 data, (int)count, (int)*offset);
470 471
471 clnt = fid->clnt;
472 do { 472 do {
473 n = p9_client_write(fid, NULL, data+total, origin+total, count); 473 n = p9_client_write(fid, NULL, data+total, origin+total, count);
474 if (n <= 0) 474 if (n <= 0)
@@ -581,11 +581,12 @@ int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
581} 581}
582 582
583static int 583static int
584v9fs_file_mmap(struct file *file, struct vm_area_struct *vma) 584v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
585{ 585{
586 int retval; 586 int retval;
587 587
588 retval = generic_file_mmap(file, vma); 588
589 retval = generic_file_mmap(filp, vma);
589 if (!retval) 590 if (!retval)
590 vma->vm_ops = &v9fs_file_vm_ops; 591 vma->vm_ops = &v9fs_file_vm_ops;
591 592
@@ -593,6 +594,43 @@ v9fs_file_mmap(struct file *file, struct vm_area_struct *vma)
593} 594}
594 595
595static 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
596v9fs_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)
597{ 635{
598 struct v9fs_inode *v9inode; 636 struct v9fs_inode *v9inode;
@@ -660,6 +698,22 @@ v9fs_cached_file_read(struct file *filp, char __user *data, size_t count,
660 return do_sync_read(filp, data, count, offset); 698 return do_sync_read(filp, data, count, offset);
661} 699}
662 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
663static ssize_t 717static ssize_t
664v9fs_direct_write(struct file *filp, const char __user * data, 718v9fs_direct_write(struct file *filp, const char __user * data,
665 size_t count, loff_t *offsetp) 719 size_t count, loff_t *offsetp)
@@ -730,12 +784,65 @@ v9fs_cached_file_write(struct file *filp, const char __user * data,
730 return do_sync_write(filp, data, count, offset); 784 return do_sync_write(filp, data, count, offset);
731} 785}
732 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
733static const struct vm_operations_struct v9fs_file_vm_ops = { 833static const struct vm_operations_struct v9fs_file_vm_ops = {
734 .fault = filemap_fault, 834 .fault = filemap_fault,
735 .page_mkwrite = v9fs_vm_page_mkwrite, 835 .page_mkwrite = v9fs_vm_page_mkwrite,
736 .remap_pages = generic_file_remap_pages, 836 .remap_pages = generic_file_remap_pages,
737}; 837};
738 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
739 846
740const struct file_operations v9fs_cached_file_operations = { 847const struct file_operations v9fs_cached_file_operations = {
741 .llseek = generic_file_llseek, 848 .llseek = generic_file_llseek,
@@ -786,3 +893,26 @@ const struct file_operations v9fs_file_operations_dotl = {
786 .mmap = generic_file_readonly_mmap, 893 .mmap = generic_file_readonly_mmap,
787 .fsync = v9fs_file_fsync_dotl, 894 .fsync = v9fs_file_fsync_dotl,
788}; 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 4e65aa903345..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 }
@@ -779,7 +786,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
779 unsigned int flags) 786 unsigned int flags)
780{ 787{
781 struct dentry *res; 788 struct dentry *res;
782 struct super_block *sb;
783 struct v9fs_session_info *v9ses; 789 struct v9fs_session_info *v9ses;
784 struct p9_fid *dfid, *fid; 790 struct p9_fid *dfid, *fid;
785 struct inode *inode; 791 struct inode *inode;
@@ -791,7 +797,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
791 if (dentry->d_name.len > NAME_MAX) 797 if (dentry->d_name.len > NAME_MAX)
792 return ERR_PTR(-ENAMETOOLONG); 798 return ERR_PTR(-ENAMETOOLONG);
793 799
794 sb = dir->i_sb;
795 v9ses = v9fs_inode2v9ses(dir); 800 v9ses = v9fs_inode2v9ses(dir);
796 /* We can walk d_parent because we hold the dir->i_mutex */ 801 /* We can walk d_parent because we hold the dir->i_mutex */
797 dfid = v9fs_fid_lookup(dentry->d_parent); 802 dfid = v9fs_fid_lookup(dentry->d_parent);
@@ -812,7 +817,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
812 * unlink. For cached mode create calls request for new 817 * unlink. For cached mode create calls request for new
813 * inode. But with cache disabled, lookup should do this. 818 * inode. But with cache disabled, lookup should do this.
814 */ 819 */
815 if (v9ses->cache) 820 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
816 inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); 821 inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
817 else 822 else
818 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);
@@ -863,7 +868,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
863 return finish_no_open(file, res); 868 return finish_no_open(file, res);
864 869
865 err = 0; 870 err = 0;
866 fid = NULL; 871
867 v9ses = v9fs_inode2v9ses(dir); 872 v9ses = v9fs_inode2v9ses(dir);
868 perm = unixmode2p9mode(v9ses, mode); 873 perm = unixmode2p9mode(v9ses, mode);
869 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, 874 fid = v9fs_create(v9ses, dir, dentry, NULL, perm,
@@ -878,7 +883,8 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
878 v9fs_invalidate_inode_attr(dir); 883 v9fs_invalidate_inode_attr(dir);
879 v9inode = V9FS_I(dentry->d_inode); 884 v9inode = V9FS_I(dentry->d_inode);
880 mutex_lock(&v9inode->v_mutex); 885 mutex_lock(&v9inode->v_mutex);
881 if (v9ses->cache && !v9inode->writeback_fid && 886 if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
887 !v9inode->writeback_fid &&
882 ((flags & O_ACCMODE) != O_RDONLY)) { 888 ((flags & O_ACCMODE) != O_RDONLY)) {
883 /* 889 /*
884 * clone a fid and add it to writeback_fid 890 * clone a fid and add it to writeback_fid
@@ -901,7 +907,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
901 goto error; 907 goto error;
902 908
903 file->private_data = fid; 909 file->private_data = fid;
904 if (v9ses->cache) 910 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
905 v9fs_cache_inode_set_cookie(dentry->d_inode, file); 911 v9fs_cache_inode_set_cookie(dentry->d_inode, file);
906 912
907 *opened |= FILE_CREATED; 913 *opened |= FILE_CREATED;
@@ -1479,7 +1485,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
1479 */ 1485 */
1480 i_size = inode->i_size; 1486 i_size = inode->i_size;
1481 v9fs_stat2inode(st, inode, inode->i_sb); 1487 v9fs_stat2inode(st, inode, inode->i_sb);
1482 if (v9ses->cache) 1488 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
1483 inode->i_size = i_size; 1489 inode->i_size = i_size;
1484 spin_unlock(&inode->i_lock); 1490 spin_unlock(&inode->i_lock);
1485out: 1491out:
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 4c10edec26a0..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:
@@ -473,13 +474,11 @@ static int
473v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry, 474v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry,
474 struct kstat *stat) 475 struct kstat *stat)
475{ 476{
476 int err;
477 struct v9fs_session_info *v9ses; 477 struct v9fs_session_info *v9ses;
478 struct p9_fid *fid; 478 struct p9_fid *fid;
479 struct p9_stat_dotl *st; 479 struct p9_stat_dotl *st;
480 480
481 p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); 481 p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
482 err = -EPERM;
483 v9ses = v9fs_dentry2v9ses(dentry); 482 v9ses = v9fs_dentry2v9ses(dentry);
484 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { 483 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
485 generic_fillattr(dentry->d_inode, stat); 484 generic_fillattr(dentry->d_inode, stat);
@@ -556,7 +555,6 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)
556int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) 555int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
557{ 556{
558 int retval; 557 int retval;
559 struct v9fs_session_info *v9ses;
560 struct p9_fid *fid; 558 struct p9_fid *fid;
561 struct p9_iattr_dotl p9attr; 559 struct p9_iattr_dotl p9attr;
562 struct inode *inode = dentry->d_inode; 560 struct inode *inode = dentry->d_inode;
@@ -577,8 +575,6 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
577 p9attr.mtime_sec = iattr->ia_mtime.tv_sec; 575 p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
578 p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; 576 p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
579 577
580 retval = -EPERM;
581 v9ses = v9fs_dentry2v9ses(dentry);
582 fid = v9fs_fid_lookup(dentry); 578 fid = v9fs_fid_lookup(dentry);
583 if (IS_ERR(fid)) 579 if (IS_ERR(fid))
584 return PTR_ERR(fid); 580 return PTR_ERR(fid);
@@ -715,7 +711,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
715 } 711 }
716 712
717 v9fs_invalidate_inode_attr(dir); 713 v9fs_invalidate_inode_attr(dir);
718 if (v9ses->cache) { 714 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
719 /* 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. */
720 fid = p9_client_walk(dfid, 1, &name, 1); 716 fid = p9_client_walk(dfid, 1, &name, 1);
721 if (IS_ERR(fid)) { 717 if (IS_ERR(fid)) {
@@ -768,7 +764,6 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
768 struct dentry *dentry) 764 struct dentry *dentry)
769{ 765{
770 int err; 766 int err;
771 char *name;
772 struct dentry *dir_dentry; 767 struct dentry *dir_dentry;
773 struct p9_fid *dfid, *oldfid; 768 struct p9_fid *dfid, *oldfid;
774 struct v9fs_session_info *v9ses; 769 struct v9fs_session_info *v9ses;
@@ -786,8 +781,6 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
786 if (IS_ERR(oldfid)) 781 if (IS_ERR(oldfid))
787 return PTR_ERR(oldfid); 782 return PTR_ERR(oldfid);
788 783
789 name = (char *) dentry->d_name.name;
790
791 err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name); 784 err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name);
792 785
793 if (err < 0) { 786 if (err < 0) {
@@ -973,7 +966,7 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
973 */ 966 */
974 i_size = inode->i_size; 967 i_size = inode->i_size;
975 v9fs_stat2inode_dotl(st, inode); 968 v9fs_stat2inode_dotl(st, inode);
976 if (v9ses->cache) 969 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
977 inode->i_size = i_size; 970 inode->i_size = i_size;
978 spin_unlock(&inode->i_lock); 971 spin_unlock(&inode->i_lock);
979out: 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);
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index 3c28cdfb8c47..04133a1fd9cb 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -138,8 +138,7 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
138 if (retval < 0) { 138 if (retval < 0) {
139 p9_debug(P9_DEBUG_VFS, "p9_client_xattrcreate failed %d\n", 139 p9_debug(P9_DEBUG_VFS, "p9_client_xattrcreate failed %d\n",
140 retval); 140 retval);
141 p9_client_clunk(fid); 141 goto err;
142 return retval;
143 } 142 }
144 msize = fid->clnt->msize; 143 msize = fid->clnt->msize;
145 while (value_len) { 144 while (value_len) {
@@ -152,12 +151,15 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
152 if (write_count < 0) { 151 if (write_count < 0) {
153 /* error in xattr write */ 152 /* error in xattr write */
154 retval = write_count; 153 retval = write_count;
155 break; 154 goto err;
156 } 155 }
157 offset += write_count; 156 offset += write_count;
158 value_len -= write_count; 157 value_len -= write_count;
159 } 158 }
160 return p9_client_clunk(fid); 159 retval = offset;
160err:
161 p9_client_clunk(fid);
162 return retval;
161} 163}
162 164
163ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) 165ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
diff --git a/net/9p/client.c b/net/9p/client.c
index ee8fd6bd4035..a5e4d2dcb03e 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1012,9 +1012,6 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
1012 goto destroy_tagpool; 1012 goto destroy_tagpool;
1013 1013
1014 if (!clnt->trans_mod) 1014 if (!clnt->trans_mod)
1015 clnt->trans_mod = v9fs_get_trans_by_name("virtio");
1016
1017 if (!clnt->trans_mod)
1018 clnt->trans_mod = v9fs_get_default_trans(); 1015 clnt->trans_mod = v9fs_get_default_trans();
1019 1016
1020 if (clnt->trans_mod == NULL) { 1017 if (clnt->trans_mod == NULL) {
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 9321a7763067..b7bd7f2961bf 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -1048,7 +1048,7 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
1048static struct p9_trans_module p9_tcp_trans = { 1048static struct p9_trans_module p9_tcp_trans = {
1049 .name = "tcp", 1049 .name = "tcp",
1050 .maxsize = MAX_SOCK_BUF, 1050 .maxsize = MAX_SOCK_BUF,
1051 .def = 1, 1051 .def = 0,
1052 .create = p9_fd_create_tcp, 1052 .create = p9_fd_create_tcp,
1053 .close = p9_fd_close, 1053 .close = p9_fd_close,
1054 .request = p9_fd_request, 1054 .request = p9_fd_request,
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 9c5a1aa34d12..cd1e1ede73a4 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -698,7 +698,7 @@ static struct p9_trans_module p9_virtio_trans = {
698 * page in zero copy. 698 * page in zero copy.
699 */ 699 */
700 .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3), 700 .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3),
701 .def = 0, 701 .def = 1,
702 .owner = THIS_MODULE, 702 .owner = THIS_MODULE,
703}; 703};
704 704