aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/9p/vfs_inode.c')
-rw-r--r--fs/9p/vfs_inode.c66
1 files changed, 60 insertions, 6 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 06a223d50a81..18f74ec4dce9 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -40,6 +40,7 @@
40#include "v9fs.h" 40#include "v9fs.h"
41#include "v9fs_vfs.h" 41#include "v9fs_vfs.h"
42#include "fid.h" 42#include "fid.h"
43#include "cache.h"
43 44
44static const struct inode_operations v9fs_dir_inode_operations; 45static const struct inode_operations v9fs_dir_inode_operations;
45static const struct inode_operations v9fs_dir_inode_operations_ext; 46static const struct inode_operations v9fs_dir_inode_operations_ext;
@@ -197,6 +198,39 @@ v9fs_blank_wstat(struct p9_wstat *wstat)
197 wstat->extension = NULL; 198 wstat->extension = NULL;
198} 199}
199 200
201#ifdef CONFIG_9P_FSCACHE
202/**
203 * v9fs_alloc_inode - helper function to allocate an inode
204 * This callback is executed before setting up the inode so that we
205 * can associate a vcookie with each inode.
206 *
207 */
208
209struct inode *v9fs_alloc_inode(struct super_block *sb)
210{
211 struct v9fs_cookie *vcookie;
212 vcookie = (struct v9fs_cookie *)kmem_cache_alloc(vcookie_cache,
213 GFP_KERNEL);
214 if (!vcookie)
215 return NULL;
216
217 vcookie->fscache = NULL;
218 vcookie->qid = NULL;
219 spin_lock_init(&vcookie->lock);
220 return &vcookie->inode;
221}
222
223/**
224 * v9fs_destroy_inode - destroy an inode
225 *
226 */
227
228void v9fs_destroy_inode(struct inode *inode)
229{
230 kmem_cache_free(vcookie_cache, v9fs_inode2cookie(inode));
231}
232#endif
233
200/** 234/**
201 * v9fs_get_inode - helper function to setup an inode 235 * v9fs_get_inode - helper function to setup an inode
202 * @sb: superblock 236 * @sb: superblock
@@ -326,6 +360,21 @@ error:
326} 360}
327*/ 361*/
328 362
363
364/**
365 * v9fs_clear_inode - release an inode
366 * @inode: inode to release
367 *
368 */
369void v9fs_clear_inode(struct inode *inode)
370{
371 filemap_fdatawrite(inode->i_mapping);
372
373#ifdef CONFIG_9P_FSCACHE
374 v9fs_cache_inode_put_cookie(inode);
375#endif
376}
377
329/** 378/**
330 * v9fs_inode_from_fid - populate an inode by issuing a attribute request 379 * v9fs_inode_from_fid - populate an inode by issuing a attribute request
331 * @v9ses: session information 380 * @v9ses: session information
@@ -356,8 +405,14 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
356 405
357 v9fs_stat2inode(st, ret, sb); 406 v9fs_stat2inode(st, ret, sb);
358 ret->i_ino = v9fs_qid2ino(&st->qid); 407 ret->i_ino = v9fs_qid2ino(&st->qid);
408
409#ifdef CONFIG_9P_FSCACHE
410 v9fs_vcookie_set_qid(ret, &st->qid);
411 v9fs_cache_inode_get_cookie(ret);
412#endif
359 p9stat_free(st); 413 p9stat_free(st);
360 kfree(st); 414 kfree(st);
415
361 return ret; 416 return ret;
362 417
363error: 418error:
@@ -751,7 +806,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
751 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); 806 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
752 err = -EPERM; 807 err = -EPERM;
753 v9ses = v9fs_inode2v9ses(dentry->d_inode); 808 v9ses = v9fs_inode2v9ses(dentry->d_inode);
754 if (v9ses->cache == CACHE_LOOSE) 809 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
755 return simple_getattr(mnt, dentry, stat); 810 return simple_getattr(mnt, dentry, stat);
756 811
757 fid = v9fs_fid_lookup(dentry); 812 fid = v9fs_fid_lookup(dentry);
@@ -872,10 +927,10 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
872 } else 927 } else
873 inode->i_rdev = 0; 928 inode->i_rdev = 0;
874 929
875 inode->i_size = stat->length; 930 i_size_write(inode, stat->length);
876 931
877 /* not real number of blocks, but 512 byte ones ... */ 932 /* not real number of blocks, but 512 byte ones ... */
878 inode->i_blocks = (inode->i_size + 512 - 1) >> 9; 933 inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
879} 934}
880 935
881/** 936/**
@@ -939,8 +994,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
939 P9_DPRINTK(P9_DEBUG_VFS, 994 P9_DPRINTK(P9_DEBUG_VFS,
940 "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer); 995 "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);
941 996
942 retval = buflen; 997 retval = strnlen(buffer, buflen);
943
944done: 998done:
945 kfree(st); 999 kfree(st);
946 return retval; 1000 return retval;
@@ -1007,7 +1061,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
1007 __putname(link); 1061 __putname(link);
1008 link = ERR_PTR(len); 1062 link = ERR_PTR(len);
1009 } else 1063 } else
1010 link[len] = 0; 1064 link[min(len, PATH_MAX-1)] = 0;
1011 } 1065 }
1012 nd_set_link(nd, link); 1066 nd_set_link(nd, link);
1013 1067