aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/checkpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/checkpoint.c')
-rw-r--r--fs/f2fs/checkpoint.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index ab743f92ee06..7c18f8efaadc 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -268,7 +268,7 @@ int recover_orphan_inodes(struct f2fs_sb_info *sbi)
268{ 268{
269 block_t start_blk, orphan_blkaddr, i, j; 269 block_t start_blk, orphan_blkaddr, i, j;
270 270
271 if (!(F2FS_CKPT(sbi)->ckpt_flags & CP_ORPHAN_PRESENT_FLAG)) 271 if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG))
272 return 0; 272 return 0;
273 273
274 sbi->por_doing = 1; 274 sbi->por_doing = 1;
@@ -287,7 +287,7 @@ int recover_orphan_inodes(struct f2fs_sb_info *sbi)
287 f2fs_put_page(page, 1); 287 f2fs_put_page(page, 1);
288 } 288 }
289 /* clear Orphan Flag */ 289 /* clear Orphan Flag */
290 F2FS_CKPT(sbi)->ckpt_flags &= (~CP_ORPHAN_PRESENT_FLAG); 290 clear_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG);
291 sbi->por_doing = 0; 291 sbi->por_doing = 0;
292 return 0; 292 return 0;
293} 293}
@@ -376,7 +376,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
376 pre_version = le64_to_cpu(cp_block->checkpoint_ver); 376 pre_version = le64_to_cpu(cp_block->checkpoint_ver);
377 377
378 /* Read the 2nd cp block in this CP pack */ 378 /* Read the 2nd cp block in this CP pack */
379 cp_addr += le64_to_cpu(cp_block->cp_pack_total_block_count) - 1; 379 cp_addr += le32_to_cpu(cp_block->cp_pack_total_block_count) - 1;
380 cp_page_2 = get_meta_page(sbi, cp_addr); 380 cp_page_2 = get_meta_page(sbi, cp_addr);
381 381
382 cp_block = (struct f2fs_checkpoint *)page_address(cp_page_2); 382 cp_block = (struct f2fs_checkpoint *)page_address(cp_page_2);
@@ -605,8 +605,8 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
605 block_t start_blk; 605 block_t start_blk;
606 struct page *cp_page; 606 struct page *cp_page;
607 unsigned int data_sum_blocks, orphan_blocks; 607 unsigned int data_sum_blocks, orphan_blocks;
608 unsigned int crc32 = 0;
608 void *kaddr; 609 void *kaddr;
609 __u32 crc32 = 0;
610 int i; 610 int i;
611 611
612 /* Flush all the NAT/SIT pages */ 612 /* Flush all the NAT/SIT pages */
@@ -646,33 +646,35 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
646 /* 2 cp + n data seg summary + orphan inode blocks */ 646 /* 2 cp + n data seg summary + orphan inode blocks */
647 data_sum_blocks = npages_for_summary_flush(sbi); 647 data_sum_blocks = npages_for_summary_flush(sbi);
648 if (data_sum_blocks < 3) 648 if (data_sum_blocks < 3)
649 ckpt->ckpt_flags |= CP_COMPACT_SUM_FLAG; 649 set_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG);
650 else 650 else
651 ckpt->ckpt_flags &= (~CP_COMPACT_SUM_FLAG); 651 clear_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG);
652 652
653 orphan_blocks = (sbi->n_orphans + F2FS_ORPHANS_PER_BLOCK - 1) 653 orphan_blocks = (sbi->n_orphans + F2FS_ORPHANS_PER_BLOCK - 1)
654 / F2FS_ORPHANS_PER_BLOCK; 654 / F2FS_ORPHANS_PER_BLOCK;
655 ckpt->cp_pack_start_sum = 1 + orphan_blocks; 655 ckpt->cp_pack_start_sum = cpu_to_le32(1 + orphan_blocks);
656 ckpt->cp_pack_total_block_count = 2 + data_sum_blocks + orphan_blocks;
657 656
658 if (is_umount) { 657 if (is_umount) {
659 ckpt->ckpt_flags |= CP_UMOUNT_FLAG; 658 set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
660 ckpt->cp_pack_total_block_count += NR_CURSEG_NODE_TYPE; 659 ckpt->cp_pack_total_block_count = cpu_to_le32(2 +
660 data_sum_blocks + orphan_blocks + NR_CURSEG_NODE_TYPE);
661 } else { 661 } else {
662 ckpt->ckpt_flags &= (~CP_UMOUNT_FLAG); 662 clear_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
663 ckpt->cp_pack_total_block_count = cpu_to_le32(2 +
664 data_sum_blocks + orphan_blocks);
663 } 665 }
664 666
665 if (sbi->n_orphans) 667 if (sbi->n_orphans)
666 ckpt->ckpt_flags |= CP_ORPHAN_PRESENT_FLAG; 668 set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
667 else 669 else
668 ckpt->ckpt_flags &= (~CP_ORPHAN_PRESENT_FLAG); 670 clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
669 671
670 /* update SIT/NAT bitmap */ 672 /* update SIT/NAT bitmap */
671 get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP)); 673 get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP));
672 get_nat_bitmap(sbi, __bitmap_ptr(sbi, NAT_BITMAP)); 674 get_nat_bitmap(sbi, __bitmap_ptr(sbi, NAT_BITMAP));
673 675
674 crc32 = f2fs_crc32(ckpt, le32_to_cpu(ckpt->checksum_offset)); 676 crc32 = f2fs_crc32(ckpt, le32_to_cpu(ckpt->checksum_offset));
675 *(__u32 *)((unsigned char *)ckpt + 677 *(__le32 *)((unsigned char *)ckpt +
676 le32_to_cpu(ckpt->checksum_offset)) 678 le32_to_cpu(ckpt->checksum_offset))
677 = cpu_to_le32(crc32); 679 = cpu_to_le32(crc32);
678 680
@@ -716,7 +718,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
716 sbi->alloc_valid_block_count = 0; 718 sbi->alloc_valid_block_count = 0;
717 719
718 /* Here, we only have one bio having CP pack */ 720 /* Here, we only have one bio having CP pack */
719 if (sbi->ckpt->ckpt_flags & CP_ERROR_FLAG) 721 if (is_set_ckpt_flags(ckpt, CP_ERROR_FLAG))
720 sbi->sb->s_flags |= MS_RDONLY; 722 sbi->sb->s_flags |= MS_RDONLY;
721 else 723 else
722 sync_meta_pages(sbi, META_FLUSH, LONG_MAX); 724 sync_meta_pages(sbi, META_FLUSH, LONG_MAX);