aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_inode.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-02-28 06:34:01 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2011-03-15 10:57:39 -0400
commit5ffc0cb308f69cea36058d308d911f26ee59316e (patch)
tree3419cbaeab2d8f20d96123ba20604d82b9129a80 /fs/9p/vfs_inode.c
parent62d810b424e434a38ad6b17fb93cd5748692a026 (diff)
fs/9p: Add inode hashing
We didn't add the inode to inode hash in 9p. We need to do that to get sync to work, otherwise __mark_inode_dirty will not add the inode to super block's dirty list. 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/9p/vfs_inode.c')
-rw-r--r--fs/9p/vfs_inode.c121
1 files changed, 75 insertions, 46 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index a0d65a398729..445dd283dc15 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -243,26 +243,10 @@ void v9fs_destroy_inode(struct inode *inode)
243} 243}
244#endif 244#endif
245 245
246/** 246int v9fs_init_inode(struct v9fs_session_info *v9ses,
247 * v9fs_get_inode - helper function to setup an inode 247 struct inode *inode, int mode)
248 * @sb: superblock
249 * @mode: mode to setup inode with
250 *
251 */
252
253struct inode *v9fs_get_inode(struct super_block *sb, int mode)
254{ 248{
255 int err; 249 int err = 0;
256 struct inode *inode;
257 struct v9fs_session_info *v9ses = sb->s_fs_info;
258
259 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
260
261 inode = new_inode(sb);
262 if (!inode) {
263 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
264 return ERR_PTR(-ENOMEM);
265 }
266 250
267 inode_init_owner(inode, NULL, mode); 251 inode_init_owner(inode, NULL, mode);
268 inode->i_blocks = 0; 252 inode->i_blocks = 0;
@@ -306,7 +290,6 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
306 } 290 }
307 291
308 break; 292 break;
309
310 case S_IFLNK: 293 case S_IFLNK:
311 if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) { 294 if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) {
312 P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with " 295 P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with "
@@ -342,12 +325,37 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
342 err = -EINVAL; 325 err = -EINVAL;
343 goto error; 326 goto error;
344 } 327 }
328error:
329 return err;
345 330
346 return inode; 331}
347 332
348error: 333/**
349 iput(inode); 334 * v9fs_get_inode - helper function to setup an inode
350 return ERR_PTR(err); 335 * @sb: superblock
336 * @mode: mode to setup inode with
337 *
338 */
339
340struct inode *v9fs_get_inode(struct super_block *sb, int mode)
341{
342 int err;
343 struct inode *inode;
344 struct v9fs_session_info *v9ses = sb->s_fs_info;
345
346 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
347
348 inode = new_inode(sb);
349 if (!inode) {
350 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
351 return ERR_PTR(-ENOMEM);
352 }
353 err = v9fs_init_inode(v9ses, inode, mode);
354 if (err) {
355 iput(inode);
356 return ERR_PTR(err);
357 }
358 return inode;
351} 359}
352 360
353/* 361/*
@@ -424,39 +432,60 @@ void v9fs_evict_inode(struct inode *inode)
424 } 432 }
425} 433}
426 434
427struct inode * 435static struct inode *v9fs_qid_iget(struct super_block *sb,
428v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid, 436 struct p9_qid *qid,
429 struct super_block *sb) 437 struct p9_wstat *st)
430{ 438{
431 int err, umode; 439 int retval, umode;
432 struct inode *ret = NULL; 440 unsigned long i_ino;
433 struct p9_wstat *st; 441 struct inode *inode;
434 442 struct v9fs_session_info *v9ses = sb->s_fs_info;
435 st = p9_client_stat(fid);
436 if (IS_ERR(st))
437 return ERR_CAST(st);
438 443
444 i_ino = v9fs_qid2ino(qid);
445 inode = iget_locked(sb, i_ino);
446 if (!inode)
447 return ERR_PTR(-ENOMEM);
448 if (!(inode->i_state & I_NEW))
449 return inode;
450 /*
451 * initialize the inode with the stat info
452 * FIXME!! we may need support for stale inodes
453 * later.
454 */
439 umode = p9mode2unixmode(v9ses, st->mode); 455 umode = p9mode2unixmode(v9ses, st->mode);
440 ret = v9fs_get_inode(sb, umode); 456 retval = v9fs_init_inode(v9ses, inode, umode);
441 if (IS_ERR(ret)) { 457 if (retval)
442 err = PTR_ERR(ret);
443 goto error; 458 goto error;
444 }
445
446 v9fs_stat2inode(st, ret, sb);
447 ret->i_ino = v9fs_qid2ino(&st->qid);
448 459
460 v9fs_stat2inode(st, inode, sb);
449#ifdef CONFIG_9P_FSCACHE 461#ifdef CONFIG_9P_FSCACHE
450 v9fs_vcookie_set_qid(ret, &st->qid); 462 v9fs_vcookie_set_qid(ret, &st->qid);
451 v9fs_cache_inode_get_cookie(ret); 463 v9fs_cache_inode_get_cookie(inode);
452#endif 464#endif
453 p9stat_free(st); 465 unlock_new_inode(inode);
454 kfree(st); 466 return inode;
455 return ret;
456error: 467error:
468 unlock_new_inode(inode);
469 iput(inode);
470 return ERR_PTR(retval);
471
472}
473
474struct inode *
475v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid,
476 struct super_block *sb)
477{
478 struct p9_wstat *st;
479 struct inode *inode = NULL;
480
481 st = p9_client_stat(fid);
482 if (IS_ERR(st))
483 return ERR_CAST(st);
484
485 inode = v9fs_qid_iget(sb, &st->qid, st);
457 p9stat_free(st); 486 p9stat_free(st);
458 kfree(st); 487 kfree(st);
459 return ERR_PTR(err); 488 return inode;
460} 489}
461 490
462/** 491/**