aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/inode.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-25 04:45:44 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:34 -0400
commit4d8d9293dce503eb0e083e17a02a328d397e7f00 (patch)
treeffa2dce7f100b1346131adc01cf93e280b225509 /fs/nilfs2/inode.c
parentba65ae4729bf81c58d9fc847f67d57eec525b042 (diff)
nilfs2: set pointer to root object in inodes
This puts a pointer to nilfs_root object in the private part of on-memory inode, and makes nilfs_iget function pick up the inode with the same root object. Non-root inodes inherit its nilfs_root object from parent inode. That of the root inode is allocated through nilfs_attach_checkpoint() function. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/inode.c')
-rw-r--r--fs/nilfs2/inode.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 82cfdbc43e1c..7306fc7c4962 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -37,6 +37,7 @@
37struct nilfs_iget_args { 37struct nilfs_iget_args {
38 u64 ino; 38 u64 ino;
39 __u64 cno; 39 __u64 cno;
40 struct nilfs_root *root;
40 int for_gc; 41 int for_gc;
41}; 42};
42 43
@@ -284,6 +285,7 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
284 struct nilfs_sb_info *sbi = NILFS_SB(sb); 285 struct nilfs_sb_info *sbi = NILFS_SB(sb);
285 struct inode *inode; 286 struct inode *inode;
286 struct nilfs_inode_info *ii; 287 struct nilfs_inode_info *ii;
288 struct nilfs_root *root;
287 int err = -ENOMEM; 289 int err = -ENOMEM;
288 ino_t ino; 290 ino_t ino;
289 291
@@ -294,8 +296,10 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
294 mapping_set_gfp_mask(inode->i_mapping, 296 mapping_set_gfp_mask(inode->i_mapping,
295 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 297 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
296 298
299 root = NILFS_I(dir)->i_root;
297 ii = NILFS_I(inode); 300 ii = NILFS_I(inode);
298 ii->i_state = 1 << NILFS_I_NEW; 301 ii->i_state = 1 << NILFS_I_NEW;
302 ii->i_root = root;
299 303
300 err = nilfs_ifile_create_inode(sbi->s_ifile, &ino, &ii->i_bh); 304 err = nilfs_ifile_create_inode(sbi->s_ifile, &ino, &ii->i_bh);
301 if (unlikely(err)) 305 if (unlikely(err))
@@ -484,7 +488,7 @@ static int nilfs_iget_test(struct inode *inode, void *opaque)
484 struct nilfs_iget_args *args = opaque; 488 struct nilfs_iget_args *args = opaque;
485 struct nilfs_inode_info *ii; 489 struct nilfs_inode_info *ii;
486 490
487 if (args->ino != inode->i_ino) 491 if (args->ino != inode->i_ino || args->root != NILFS_I(inode)->i_root)
488 return 0; 492 return 0;
489 493
490 ii = NILFS_I(inode); 494 ii = NILFS_I(inode);
@@ -502,13 +506,21 @@ static int nilfs_iget_set(struct inode *inode, void *opaque)
502 if (args->for_gc) { 506 if (args->for_gc) {
503 NILFS_I(inode)->i_state = 1 << NILFS_I_GCINODE; 507 NILFS_I(inode)->i_state = 1 << NILFS_I_GCINODE;
504 NILFS_I(inode)->i_cno = args->cno; 508 NILFS_I(inode)->i_cno = args->cno;
509 NILFS_I(inode)->i_root = NULL;
510 } else {
511 if (args->root && args->ino == NILFS_ROOT_INO)
512 nilfs_get_root(args->root);
513 NILFS_I(inode)->i_root = args->root;
505 } 514 }
506 return 0; 515 return 0;
507} 516}
508 517
509struct inode *nilfs_iget(struct super_block *sb, unsigned long ino) 518struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,
519 unsigned long ino)
510{ 520{
511 struct nilfs_iget_args args = { .ino = ino, .cno = 0, .for_gc = 0 }; 521 struct nilfs_iget_args args = {
522 .ino = ino, .root = root, .cno = 0, .for_gc = 0
523 };
512 struct inode *inode; 524 struct inode *inode;
513 int err; 525 int err;
514 526
@@ -530,7 +542,9 @@ struct inode *nilfs_iget(struct super_block *sb, unsigned long ino)
530struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino, 542struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino,
531 __u64 cno) 543 __u64 cno)
532{ 544{
533 struct nilfs_iget_args args = { .ino = ino, .cno = cno, .for_gc = 1 }; 545 struct nilfs_iget_args args = {
546 .ino = ino, .root = NULL, .cno = cno, .for_gc = 1
547 };
534 struct inode *inode; 548 struct inode *inode;
535 int err; 549 int err;
536 550
@@ -682,6 +696,9 @@ static void nilfs_clear_inode(struct inode *inode)
682 nilfs_bmap_clear(ii->i_bmap); 696 nilfs_bmap_clear(ii->i_bmap);
683 697
684 nilfs_btnode_cache_clear(&ii->i_btnode_cache); 698 nilfs_btnode_cache_clear(&ii->i_btnode_cache);
699
700 if (ii->i_root && inode->i_ino == NILFS_ROOT_INO)
701 nilfs_put_root(ii->i_root);
685} 702}
686 703
687void nilfs_evict_inode(struct inode *inode) 704void nilfs_evict_inode(struct inode *inode)
@@ -690,7 +707,7 @@ void nilfs_evict_inode(struct inode *inode)
690 struct super_block *sb = inode->i_sb; 707 struct super_block *sb = inode->i_sb;
691 struct nilfs_inode_info *ii = NILFS_I(inode); 708 struct nilfs_inode_info *ii = NILFS_I(inode);
692 709
693 if (inode->i_nlink || unlikely(is_bad_inode(inode))) { 710 if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) {
694 if (inode->i_data.nrpages) 711 if (inode->i_data.nrpages)
695 truncate_inode_pages(&inode->i_data, 0); 712 truncate_inode_pages(&inode->i_data, 0);
696 end_writeback(inode); 713 end_writeback(inode);