diff options
Diffstat (limited to 'fs/9p/vfs_inode.c')
-rw-r--r-- | fs/9p/vfs_inode.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index f3bfa87926bd..5947628aefef 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 | ||
44 | static const struct inode_operations v9fs_dir_inode_operations; | 45 | static const struct inode_operations v9fs_dir_inode_operations; |
45 | static const struct inode_operations v9fs_dir_inode_operations_ext; | 46 | static 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 | |||
209 | struct 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 | |||
228 | void 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 | */ | ||
369 | void 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 | ||
363 | error: | 418 | error: |
@@ -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); |