aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-02-28 06:34:03 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2011-03-15 10:57:39 -0400
commit6b39f6d22fbf67cf795c105b4d67c64e9c352ca4 (patch)
tree0d0926901486e334feb5422ee2b0e56b45e9a970 /fs
parenta78ce05d5d342297b66122eda8add4eefa21f8a8 (diff)
fs/9p: Move writeback fid to v9fs_inode
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/v9fs.h1
-rw-r--r--fs/9p/vfs_addr.c14
-rw-r--r--fs/9p/vfs_file.c12
-rw-r--r--fs/9p/vfs_inode.c21
-rw-r--r--fs/9p/vfs_inode_dotl.c17
5 files changed, 41 insertions, 24 deletions
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index ce59d1512062..71cab8e3a570 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -122,6 +122,7 @@ struct v9fs_inode {
122 struct fscache_cookie *fscache; 122 struct fscache_cookie *fscache;
123 struct p9_qid *fscache_key; 123 struct p9_qid *fscache_key;
124#endif 124#endif
125 struct p9_fid *writeback_fid;
125 struct inode vfs_inode; 126 struct inode vfs_inode;
126}; 127};
127 128
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 566684ce55e2..ee455526ca5b 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -163,8 +163,10 @@ static int v9fs_vfs_writepage_locked(struct page *page)
163 int retval, len; 163 int retval, len;
164 loff_t offset, size; 164 loff_t offset, size;
165 mm_segment_t old_fs; 165 mm_segment_t old_fs;
166 struct v9fs_inode *v9inode;
166 struct inode *inode = page->mapping->host; 167 struct inode *inode = page->mapping->host;
167 168
169 v9inode = V9FS_I(inode);
168 size = i_size_read(inode); 170 size = i_size_read(inode);
169 if (page->index == size >> PAGE_CACHE_SHIFT) 171 if (page->index == size >> PAGE_CACHE_SHIFT)
170 len = size & ~PAGE_CACHE_MASK; 172 len = size & ~PAGE_CACHE_MASK;
@@ -178,11 +180,11 @@ static int v9fs_vfs_writepage_locked(struct page *page)
178 180
179 old_fs = get_fs(); 181 old_fs = get_fs();
180 set_fs(get_ds()); 182 set_fs(get_ds());
181 /* We should have i_private always set */ 183 /* We should have writeback_fid always set */
182 BUG_ON(!inode->i_private); 184 BUG_ON(!v9inode->writeback_fid);
183 185
184 retval = v9fs_file_write_internal(inode, 186 retval = v9fs_file_write_internal(inode,
185 (struct p9_fid *)inode->i_private, 187 v9inode->writeback_fid,
186 (__force const char __user *)buffer, 188 (__force const char __user *)buffer,
187 len, &offset, 0); 189 len, &offset, 0);
188 if (retval > 0) 190 if (retval > 0)
@@ -274,23 +276,25 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
274{ 276{
275 int retval = 0; 277 int retval = 0;
276 struct page *page; 278 struct page *page;
279 struct v9fs_inode *v9inode;
277 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 280 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
278 struct inode *inode = mapping->host; 281 struct inode *inode = mapping->host;
279 282
283 v9inode = V9FS_I(inode);
280start: 284start:
281 page = grab_cache_page_write_begin(mapping, index, flags); 285 page = grab_cache_page_write_begin(mapping, index, flags);
282 if (!page) { 286 if (!page) {
283 retval = -ENOMEM; 287 retval = -ENOMEM;
284 goto out; 288 goto out;
285 } 289 }
286 BUG_ON(!inode->i_private); 290 BUG_ON(!v9inode->writeback_fid);
287 if (PageUptodate(page)) 291 if (PageUptodate(page))
288 goto out; 292 goto out;
289 293
290 if (len == PAGE_CACHE_SIZE) 294 if (len == PAGE_CACHE_SIZE)
291 goto out; 295 goto out;
292 296
293 retval = v9fs_fid_readpage(inode->i_private, page); 297 retval = v9fs_fid_readpage(v9inode->writeback_fid, page);
294 page_cache_release(page); 298 page_cache_release(page);
295 if (!retval) 299 if (!retval)
296 goto start; 300 goto start;
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index f7b571ddf99e..98c4307a1f03 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -56,11 +56,13 @@ static const struct vm_operations_struct v9fs_file_vm_ops;
56int v9fs_file_open(struct inode *inode, struct file *file) 56int v9fs_file_open(struct inode *inode, struct file *file)
57{ 57{
58 int err; 58 int err;
59 struct v9fs_inode *v9inode;
59 struct v9fs_session_info *v9ses; 60 struct v9fs_session_info *v9ses;
60 struct p9_fid *fid; 61 struct p9_fid *fid;
61 int omode; 62 int omode;
62 63
63 P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file); 64 P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
65 v9inode = V9FS_I(inode);
64 v9ses = v9fs_inode2v9ses(inode); 66 v9ses = v9fs_inode2v9ses(inode);
65 if (v9fs_proto_dotl(v9ses)) 67 if (v9fs_proto_dotl(v9ses))
66 omode = file->f_flags; 68 omode = file->f_flags;
@@ -88,9 +90,9 @@ int v9fs_file_open(struct inode *inode, struct file *file)
88 } 90 }
89 91
90 file->private_data = fid; 92 file->private_data = fid;
91 if (v9ses->cache && !inode->i_private) { 93 if (v9ses->cache && !v9inode->writeback_fid) {
92 /* 94 /*
93 * clone a fid and add it to inode->i_private 95 * clone a fid and add it to writeback_fid
94 * we do it during open time instead of 96 * we do it during open time instead of
95 * page dirty time via write_begin/page_mkwrite 97 * page dirty time via write_begin/page_mkwrite
96 * because we want write after unlink usecase 98 * because we want write after unlink usecase
@@ -101,7 +103,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
101 err = PTR_ERR(fid); 103 err = PTR_ERR(fid);
102 goto out_error; 104 goto out_error;
103 } 105 }
104 inode->i_private = (void *) fid; 106 v9inode->writeback_fid = (void *) fid;
105 } 107 }
106#ifdef CONFIG_9P_FSCACHE 108#ifdef CONFIG_9P_FSCACHE
107 if (v9ses->cache) 109 if (v9ses->cache)
@@ -550,6 +552,7 @@ v9fs_file_mmap(struct file *file, struct vm_area_struct *vma)
550static int 552static int
551v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 553v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
552{ 554{
555 struct v9fs_inode *v9inode;
553 struct page *page = vmf->page; 556 struct page *page = vmf->page;
554 struct file *filp = vma->vm_file; 557 struct file *filp = vma->vm_file;
555 struct inode *inode = filp->f_path.dentry->d_inode; 558 struct inode *inode = filp->f_path.dentry->d_inode;
@@ -558,9 +561,10 @@ v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
558 P9_DPRINTK(P9_DEBUG_VFS, "page %p fid %lx\n", 561 P9_DPRINTK(P9_DEBUG_VFS, "page %p fid %lx\n",
559 page, (unsigned long)filp->private_data); 562 page, (unsigned long)filp->private_data);
560 563
564 v9inode = V9FS_I(inode);
561 /* make sure the cache has finished storing the page */ 565 /* make sure the cache has finished storing the page */
562 v9fs_fscache_wait_on_page_write(inode, page); 566 v9fs_fscache_wait_on_page_write(inode, page);
563 BUG_ON(!inode->i_private); 567 BUG_ON(!v9inode->writeback_fid);
564 lock_page(page); 568 lock_page(page);
565 if (page->mapping != inode->i_mapping) 569 if (page->mapping != inode->i_mapping)
566 goto out_unlock; 570 goto out_unlock;
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 411c70a88b36..fdc086d07447 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -219,6 +219,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb)
219 v9inode->fscache_key = NULL; 219 v9inode->fscache_key = NULL;
220 spin_lock_init(&v9inode->fscache_lock); 220 spin_lock_init(&v9inode->fscache_lock);
221#endif 221#endif
222 v9inode->writeback_fid = NULL;
222 return &v9inode->vfs_inode; 223 return &v9inode->vfs_inode;
223} 224}
224 225
@@ -414,6 +415,8 @@ error:
414 */ 415 */
415void v9fs_evict_inode(struct inode *inode) 416void v9fs_evict_inode(struct inode *inode)
416{ 417{
418 struct v9fs_inode *v9inode = V9FS_I(inode);
419
417 truncate_inode_pages(inode->i_mapping, 0); 420 truncate_inode_pages(inode->i_mapping, 0);
418 end_writeback(inode); 421 end_writeback(inode);
419 filemap_fdatawrite(inode->i_mapping); 422 filemap_fdatawrite(inode->i_mapping);
@@ -421,10 +424,10 @@ void v9fs_evict_inode(struct inode *inode)
421#ifdef CONFIG_9P_FSCACHE 424#ifdef CONFIG_9P_FSCACHE
422 v9fs_cache_inode_put_cookie(inode); 425 v9fs_cache_inode_put_cookie(inode);
423#endif 426#endif
424 /* clunk the fid stashed in inode->i_private */ 427 /* clunk the fid stashed in writeback_fid */
425 if (inode->i_private) { 428 if (v9inode->writeback_fid) {
426 p9_client_clunk((struct p9_fid *)inode->i_private); 429 p9_client_clunk(v9inode->writeback_fid);
427 inode->i_private = NULL; 430 v9inode->writeback_fid = NULL;
428 } 431 }
429} 432}
430 433
@@ -607,9 +610,10 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
607 int err; 610 int err;
608 u32 perm; 611 u32 perm;
609 int flags; 612 int flags;
613 struct file *filp;
614 struct v9fs_inode *v9inode;
610 struct v9fs_session_info *v9ses; 615 struct v9fs_session_info *v9ses;
611 struct p9_fid *fid, *inode_fid; 616 struct p9_fid *fid, *inode_fid;
612 struct file *filp;
613 617
614 err = 0; 618 err = 0;
615 fid = NULL; 619 fid = NULL;
@@ -631,9 +635,10 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
631 635
632 /* if we are opening a file, assign the open fid to the file */ 636 /* if we are opening a file, assign the open fid to the file */
633 if (nd && nd->flags & LOOKUP_OPEN) { 637 if (nd && nd->flags & LOOKUP_OPEN) {
634 if (v9ses->cache && !dentry->d_inode->i_private) { 638 v9inode = V9FS_I(dentry->d_inode);
639 if (v9ses->cache && !v9inode->writeback_fid) {
635 /* 640 /*
636 * clone a fid and add it to inode->i_private 641 * clone a fid and add it to writeback_fid
637 * we do it during open time instead of 642 * we do it during open time instead of
638 * page dirty time via write_begin/page_mkwrite 643 * page dirty time via write_begin/page_mkwrite
639 * because we want write after unlink usecase 644 * because we want write after unlink usecase
@@ -644,7 +649,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
644 err = PTR_ERR(inode_fid); 649 err = PTR_ERR(inode_fid);
645 goto error; 650 goto error;
646 } 651 }
647 dentry->d_inode->i_private = (void *) inode_fid; 652 v9inode->writeback_fid = (void *) inode_fid;
648 } 653 }
649 filp = lookup_instantiate_filp(nd, dentry, generic_file_open); 654 filp = lookup_instantiate_filp(nd, dentry, generic_file_open);
650 if (IS_ERR(filp)) { 655 if (IS_ERR(filp)) {
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 21523f27f5d1..984594123abe 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -159,16 +159,17 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
159 struct nameidata *nd) 159 struct nameidata *nd)
160{ 160{
161 int err = 0; 161 int err = 0;
162 char *name = NULL;
163 gid_t gid; 162 gid_t gid;
164 int flags; 163 int flags;
165 mode_t mode; 164 mode_t mode;
166 struct v9fs_session_info *v9ses; 165 char *name = NULL;
167 struct p9_fid *fid = NULL;
168 struct p9_fid *dfid, *ofid, *inode_fid;
169 struct file *filp; 166 struct file *filp;
170 struct p9_qid qid; 167 struct p9_qid qid;
171 struct inode *inode; 168 struct inode *inode;
169 struct p9_fid *fid = NULL;
170 struct v9fs_inode *v9inode;
171 struct p9_fid *dfid, *ofid, *inode_fid;
172 struct v9fs_session_info *v9ses;
172 struct posix_acl *pacl = NULL, *dacl = NULL; 173 struct posix_acl *pacl = NULL, *dacl = NULL;
173 174
174 v9ses = v9fs_inode2v9ses(dir); 175 v9ses = v9fs_inode2v9ses(dir);
@@ -241,9 +242,11 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
241 242
242 /* Now set the ACL based on the default value */ 243 /* Now set the ACL based on the default value */
243 v9fs_set_create_acl(dentry, dacl, pacl); 244 v9fs_set_create_acl(dentry, dacl, pacl);
244 if (v9ses->cache && !inode->i_private) { 245
246 v9inode = V9FS_I(inode);
247 if (v9ses->cache && !v9inode->writeback_fid) {
245 /* 248 /*
246 * clone a fid and add it to inode->i_private 249 * clone a fid and add it to writeback_fid
247 * we do it during open time instead of 250 * we do it during open time instead of
248 * page dirty time via write_begin/page_mkwrite 251 * page dirty time via write_begin/page_mkwrite
249 * because we want write after unlink usecase 252 * because we want write after unlink usecase
@@ -254,7 +257,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
254 err = PTR_ERR(inode_fid); 257 err = PTR_ERR(inode_fid);
255 goto error; 258 goto error;
256 } 259 }
257 inode->i_private = (void *) inode_fid; 260 v9inode->writeback_fid = (void *) inode_fid;
258 } 261 }
259 /* Since we are opening a file, assign the open fid to the file */ 262 /* Since we are opening a file, assign the open fid to the file */
260 filp = lookup_instantiate_filp(nd, dentry, generic_file_open); 263 filp = lookup_instantiate_filp(nd, dentry, generic_file_open);