f2fs: fix the number of orphan inode blocks
authorWanpeng Li <wanpeng.li@linux.intel.com>
Wed, 25 Feb 2015 23:57:21 +0000 (07:57 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 10 Apr 2015 22:08:26 +0000 (15:08 -0700)
cp_pack_start_sum is calculated in do_checkpoint and is equal to
cpu_to_le32(1 + cp_payload_blks + orphan_blocks). The number of
orphan inode blocks is take advantage of by recover_orphan_inodes
to readahead meta pages and recovery inodes. However, current codes
forget to reduce the number of cp payload blocks when calculate
the number of orphan inode blocks. This patch fix it.

Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c

index c7cafd8..4d5e697 100644 (file)
@@ -464,7 +464,7 @@ static void recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
 
 void recover_orphan_inodes(struct f2fs_sb_info *sbi)
 {
-       block_t start_blk, orphan_blkaddr, i, j;
+       block_t start_blk, orphan_blocks, i, j;
 
        if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG))
                return;
@@ -472,11 +472,11 @@ void recover_orphan_inodes(struct f2fs_sb_info *sbi)
        set_sbi_flag(sbi, SBI_POR_DOING);
 
        start_blk = __start_cp_addr(sbi) + 1 + __cp_payload(sbi);
-       orphan_blkaddr = __start_sum_addr(sbi) - 1;
+       orphan_blocks = __start_sum_addr(sbi) - 1 - __cp_payload(sbi);
 
-       ra_meta_pages(sbi, start_blk, orphan_blkaddr, META_CP);
+       ra_meta_pages(sbi, start_blk, orphan_blocks, META_CP);
 
-       for (i = 0; i < orphan_blkaddr; i++) {
+       for (i = 0; i < orphan_blocks; i++) {
                struct page *page = get_meta_page(sbi, start_blk + i);
                struct f2fs_orphan_block *orphan_blk;