aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/inode.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-14 00:07:15 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:35 -0400
commite912a5b66837ee89fb025e67b5efeaa11930c2ce (patch)
tree46209cdf7417863024131ff54f56120e43ae7a7b /fs/nilfs2/inode.c
parent8e656fd518784b49453f60c5f78b78703bc85cb2 (diff)
nilfs2: use root object to get ifile
This rewrites functions using ifile so that they get ifile from nilfs_root object, and will remove sbi->s_ifile. Some functions that don't know the root object are extended to receive it from caller. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/inode.c')
-rw-r--r--fs/nilfs2/inode.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 7306fc7c4962..7e883d5a5033 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -301,7 +301,7 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
301 ii->i_state = 1 << NILFS_I_NEW; 301 ii->i_state = 1 << NILFS_I_NEW;
302 ii->i_root = root; 302 ii->i_root = root;
303 303
304 err = nilfs_ifile_create_inode(sbi->s_ifile, &ino, &ii->i_bh); 304 err = nilfs_ifile_create_inode(root->ifile, &ino, &ii->i_bh);
305 if (unlikely(err)) 305 if (unlikely(err))
306 goto failed_ifile_create_inode; 306 goto failed_ifile_create_inode;
307 /* reference count of i_bh inherits from nilfs_mdt_read_block() */ 307 /* reference count of i_bh inherits from nilfs_mdt_read_block() */
@@ -358,16 +358,6 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
358 return ERR_PTR(err); 358 return ERR_PTR(err);
359} 359}
360 360
361void nilfs_free_inode(struct inode *inode)
362{
363 struct super_block *sb = inode->i_sb;
364 struct nilfs_sb_info *sbi = NILFS_SB(sb);
365
366 /* XXX: check error code? Is there any thing I can do? */
367 (void) nilfs_ifile_delete_inode(sbi->s_ifile, inode->i_ino);
368 atomic_dec(&sbi->s_inodes_count);
369}
370
371void nilfs_set_inode_flags(struct inode *inode) 361void nilfs_set_inode_flags(struct inode *inode)
372{ 362{
373 unsigned int flags = NILFS_I(inode)->i_flags; 363 unsigned int flags = NILFS_I(inode)->i_flags;
@@ -431,7 +421,8 @@ int nilfs_read_inode_common(struct inode *inode,
431 return 0; 421 return 0;
432} 422}
433 423
434static int __nilfs_read_inode(struct super_block *sb, unsigned long ino, 424static int __nilfs_read_inode(struct super_block *sb,
425 struct nilfs_root *root, unsigned long ino,
435 struct inode *inode) 426 struct inode *inode)
436{ 427{
437 struct nilfs_sb_info *sbi = NILFS_SB(sb); 428 struct nilfs_sb_info *sbi = NILFS_SB(sb);
@@ -441,11 +432,11 @@ static int __nilfs_read_inode(struct super_block *sb, unsigned long ino,
441 int err; 432 int err;
442 433
443 down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */ 434 down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
444 err = nilfs_ifile_get_inode_block(sbi->s_ifile, ino, &bh); 435 err = nilfs_ifile_get_inode_block(root->ifile, ino, &bh);
445 if (unlikely(err)) 436 if (unlikely(err))
446 goto bad_inode; 437 goto bad_inode;
447 438
448 raw_inode = nilfs_ifile_map_inode(sbi->s_ifile, ino, bh); 439 raw_inode = nilfs_ifile_map_inode(root->ifile, ino, bh);
449 440
450 err = nilfs_read_inode_common(inode, raw_inode); 441 err = nilfs_read_inode_common(inode, raw_inode);
451 if (err) 442 if (err)
@@ -468,14 +459,14 @@ static int __nilfs_read_inode(struct super_block *sb, unsigned long ino,
468 inode, inode->i_mode, 459 inode, inode->i_mode,
469 huge_decode_dev(le64_to_cpu(raw_inode->i_device_code))); 460 huge_decode_dev(le64_to_cpu(raw_inode->i_device_code)));
470 } 461 }
471 nilfs_ifile_unmap_inode(sbi->s_ifile, ino, bh); 462 nilfs_ifile_unmap_inode(root->ifile, ino, bh);
472 brelse(bh); 463 brelse(bh);
473 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */ 464 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
474 nilfs_set_inode_flags(inode); 465 nilfs_set_inode_flags(inode);
475 return 0; 466 return 0;
476 467
477 failed_unmap: 468 failed_unmap:
478 nilfs_ifile_unmap_inode(sbi->s_ifile, ino, bh); 469 nilfs_ifile_unmap_inode(root->ifile, ino, bh);
479 brelse(bh); 470 brelse(bh);
480 471
481 bad_inode: 472 bad_inode:
@@ -530,7 +521,7 @@ struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,
530 if (!(inode->i_state & I_NEW)) 521 if (!(inode->i_state & I_NEW))
531 return inode; 522 return inode;
532 523
533 err = __nilfs_read_inode(sb, ino, inode); 524 err = __nilfs_read_inode(sb, root, ino, inode);
534 if (unlikely(err)) { 525 if (unlikely(err)) {
535 iget_failed(inode); 526 iget_failed(inode);
536 return ERR_PTR(err); 527 return ERR_PTR(err);
@@ -595,21 +586,20 @@ void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh)
595{ 586{
596 ino_t ino = inode->i_ino; 587 ino_t ino = inode->i_ino;
597 struct nilfs_inode_info *ii = NILFS_I(inode); 588 struct nilfs_inode_info *ii = NILFS_I(inode);
598 struct super_block *sb = inode->i_sb; 589 struct inode *ifile = ii->i_root->ifile;
599 struct nilfs_sb_info *sbi = NILFS_SB(sb);
600 struct nilfs_inode *raw_inode; 590 struct nilfs_inode *raw_inode;
601 591
602 raw_inode = nilfs_ifile_map_inode(sbi->s_ifile, ino, ibh); 592 raw_inode = nilfs_ifile_map_inode(ifile, ino, ibh);
603 593
604 if (test_and_clear_bit(NILFS_I_NEW, &ii->i_state)) 594 if (test_and_clear_bit(NILFS_I_NEW, &ii->i_state))
605 memset(raw_inode, 0, NILFS_MDT(sbi->s_ifile)->mi_entry_size); 595 memset(raw_inode, 0, NILFS_MDT(ifile)->mi_entry_size);
606 set_bit(NILFS_I_INODE_DIRTY, &ii->i_state); 596 set_bit(NILFS_I_INODE_DIRTY, &ii->i_state);
607 597
608 nilfs_write_inode_common(inode, raw_inode, 0); 598 nilfs_write_inode_common(inode, raw_inode, 0);
609 /* XXX: call with has_bmap = 0 is a workaround to avoid 599 /* XXX: call with has_bmap = 0 is a workaround to avoid
610 deadlock of bmap. This delays update of i_bmap to just 600 deadlock of bmap. This delays update of i_bmap to just
611 before writing */ 601 before writing */
612 nilfs_ifile_unmap_inode(sbi->s_ifile, ino, ibh); 602 nilfs_ifile_unmap_inode(ifile, ino, ibh);
613} 603}
614 604
615#define NILFS_MAX_TRUNCATE_BLOCKS 16384 /* 64MB for 4KB block */ 605#define NILFS_MAX_TRUNCATE_BLOCKS 16384 /* 64MB for 4KB block */
@@ -719,12 +709,16 @@ void nilfs_evict_inode(struct inode *inode)
719 if (inode->i_data.nrpages) 709 if (inode->i_data.nrpages)
720 truncate_inode_pages(&inode->i_data, 0); 710 truncate_inode_pages(&inode->i_data, 0);
721 711
712 /* TODO: some of the following operations may fail. */
722 nilfs_truncate_bmap(ii, 0); 713 nilfs_truncate_bmap(ii, 0);
723 nilfs_mark_inode_dirty(inode); 714 nilfs_mark_inode_dirty(inode);
724 end_writeback(inode); 715 end_writeback(inode);
716
717 nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino);
718 atomic_dec(&NILFS_SB(sb)->s_inodes_count);
719
725 nilfs_clear_inode(inode); 720 nilfs_clear_inode(inode);
726 nilfs_free_inode(inode); 721
727 /* nilfs_free_inode() marks inode buffer dirty */
728 if (IS_SYNC(inode)) 722 if (IS_SYNC(inode))
729 nilfs_set_transaction_flag(NILFS_TI_SYNC); 723 nilfs_set_transaction_flag(NILFS_TI_SYNC);
730 nilfs_transaction_commit(sb); 724 nilfs_transaction_commit(sb);
@@ -779,8 +773,8 @@ int nilfs_load_inode_block(struct nilfs_sb_info *sbi, struct inode *inode,
779 spin_lock(&sbi->s_inode_lock); 773 spin_lock(&sbi->s_inode_lock);
780 if (ii->i_bh == NULL) { 774 if (ii->i_bh == NULL) {
781 spin_unlock(&sbi->s_inode_lock); 775 spin_unlock(&sbi->s_inode_lock);
782 err = nilfs_ifile_get_inode_block(sbi->s_ifile, inode->i_ino, 776 err = nilfs_ifile_get_inode_block(ii->i_root->ifile,
783 pbh); 777 inode->i_ino, pbh);
784 if (unlikely(err)) 778 if (unlikely(err))
785 return err; 779 return err;
786 spin_lock(&sbi->s_inode_lock); 780 spin_lock(&sbi->s_inode_lock);
@@ -860,7 +854,7 @@ int nilfs_mark_inode_dirty(struct inode *inode)
860 } 854 }
861 nilfs_update_inode(inode, ibh); 855 nilfs_update_inode(inode, ibh);
862 nilfs_mdt_mark_buffer_dirty(ibh); 856 nilfs_mdt_mark_buffer_dirty(ibh);
863 nilfs_mdt_mark_dirty(sbi->s_ifile); 857 nilfs_mdt_mark_dirty(NILFS_I(inode)->i_root->ifile);
864 brelse(ibh); 858 brelse(ibh);
865 return 0; 859 return 0;
866} 860}