aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/recovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2/recovery.c')
-rw-r--r--fs/nilfs2/recovery.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index d0c35ef39f6a..5d2711c28da7 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -440,7 +440,6 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
440 segnum[2] = ri->ri_segnum; 440 segnum[2] = ri->ri_segnum;
441 segnum[3] = ri->ri_nextnum; 441 segnum[3] = ri->ri_nextnum;
442 442
443 nilfs_attach_writer(nilfs, sbi);
444 /* 443 /*
445 * Releasing the next segment of the latest super root. 444 * Releasing the next segment of the latest super root.
446 * The next segment is invalidated by this recovery. 445 * The next segment is invalidated by this recovery.
@@ -480,7 +479,6 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
480 479
481 failed: 480 failed:
482 /* No need to recover sufile because it will be destroyed on error */ 481 /* No need to recover sufile because it will be destroyed on error */
483 nilfs_detach_writer(nilfs, sbi);
484 return err; 482 return err;
485} 483}
486 484
@@ -504,6 +502,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
504 502
505static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, 503static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
506 struct nilfs_sb_info *sbi, 504 struct nilfs_sb_info *sbi,
505 struct nilfs_root *root,
507 struct list_head *head, 506 struct list_head *head,
508 unsigned long *nr_salvaged_blocks) 507 unsigned long *nr_salvaged_blocks)
509{ 508{
@@ -515,7 +514,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
515 int err = 0, err2 = 0; 514 int err = 0, err2 = 0;
516 515
517 list_for_each_entry_safe(rb, n, head, list) { 516 list_for_each_entry_safe(rb, n, head, list) {
518 inode = nilfs_iget(sbi->s_super, rb->ino); 517 inode = nilfs_iget(sbi->s_super, root, rb->ino);
519 if (IS_ERR(inode)) { 518 if (IS_ERR(inode)) {
520 err = PTR_ERR(inode); 519 err = PTR_ERR(inode);
521 inode = NULL; 520 inode = NULL;
@@ -578,6 +577,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
578 */ 577 */
579static int nilfs_do_roll_forward(struct the_nilfs *nilfs, 578static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
580 struct nilfs_sb_info *sbi, 579 struct nilfs_sb_info *sbi,
580 struct nilfs_root *root,
581 struct nilfs_recovery_info *ri) 581 struct nilfs_recovery_info *ri)
582{ 582{
583 struct buffer_head *bh_sum = NULL; 583 struct buffer_head *bh_sum = NULL;
@@ -597,7 +597,6 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
597 }; 597 };
598 int state = RF_INIT_ST; 598 int state = RF_INIT_ST;
599 599
600 nilfs_attach_writer(nilfs, sbi);
601 pseg_start = ri->ri_lsegs_start; 600 pseg_start = ri->ri_lsegs_start;
602 seg_seq = ri->ri_lsegs_start_seq; 601 seg_seq = ri->ri_lsegs_start_seq;
603 segnum = nilfs_get_segnum_of_block(nilfs, pseg_start); 602 segnum = nilfs_get_segnum_of_block(nilfs, pseg_start);
@@ -649,7 +648,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
649 goto failed; 648 goto failed;
650 if (flags & NILFS_SS_LOGEND) { 649 if (flags & NILFS_SS_LOGEND) {
651 err = nilfs_recover_dsync_blocks( 650 err = nilfs_recover_dsync_blocks(
652 nilfs, sbi, &dsync_blocks, 651 nilfs, sbi, root, &dsync_blocks,
653 &nsalvaged_blocks); 652 &nsalvaged_blocks);
654 if (unlikely(err)) 653 if (unlikely(err))
655 goto failed; 654 goto failed;
@@ -688,7 +687,6 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
688 out: 687 out:
689 brelse(bh_sum); 688 brelse(bh_sum);
690 dispose_recovery_list(&dsync_blocks); 689 dispose_recovery_list(&dsync_blocks);
691 nilfs_detach_writer(nilfs, sbi);
692 return err; 690 return err;
693 691
694 confused: 692 confused:
@@ -746,19 +744,20 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
746 struct nilfs_sb_info *sbi, 744 struct nilfs_sb_info *sbi,
747 struct nilfs_recovery_info *ri) 745 struct nilfs_recovery_info *ri)
748{ 746{
747 struct nilfs_root *root;
749 int err; 748 int err;
750 749
751 if (ri->ri_lsegs_start == 0 || ri->ri_lsegs_end == 0) 750 if (ri->ri_lsegs_start == 0 || ri->ri_lsegs_end == 0)
752 return 0; 751 return 0;
753 752
754 err = nilfs_attach_checkpoint(sbi, ri->ri_cno); 753 err = nilfs_attach_checkpoint(sbi, ri->ri_cno, true, &root);
755 if (unlikely(err)) { 754 if (unlikely(err)) {
756 printk(KERN_ERR 755 printk(KERN_ERR
757 "NILFS: error loading the latest checkpoint.\n"); 756 "NILFS: error loading the latest checkpoint.\n");
758 return err; 757 return err;
759 } 758 }
760 759
761 err = nilfs_do_roll_forward(nilfs, sbi, ri); 760 err = nilfs_do_roll_forward(nilfs, sbi, root, ri);
762 if (unlikely(err)) 761 if (unlikely(err))
763 goto failed; 762 goto failed;
764 763
@@ -770,7 +769,7 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
770 goto failed; 769 goto failed;
771 } 770 }
772 771
773 err = nilfs_attach_segment_constructor(sbi); 772 err = nilfs_attach_segment_constructor(sbi, root);
774 if (unlikely(err)) 773 if (unlikely(err))
775 goto failed; 774 goto failed;
776 775
@@ -788,7 +787,7 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
788 } 787 }
789 788
790 failed: 789 failed:
791 nilfs_detach_checkpoint(sbi); 790 nilfs_put_root(root);
792 return err; 791 return err;
793} 792}
794 793