diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-11-14 18:20:10 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-11-25 10:15:58 -0800 |
commit | c79b7ff1d3c7710c23d8828a69d8cbc5597ad19f (patch) | |
tree | e9edc403cd3bee72408fab2be1cde725859a4c97 /fs/f2fs/segment.c | |
parent | 7702bdbe505a22380dd958e2ee35124c7c414806 (diff) | |
download | linux-stable-c79b7ff1d3c7710c23d8828a69d8cbc5597ad19f.tar.gz linux-stable-c79b7ff1d3c7710c23d8828a69d8cbc5597ad19f.tar.bz2 linux-stable-c79b7ff1d3c7710c23d8828a69d8cbc5597ad19f.zip |
f2fs: fix wrong written_valid_blocks counting
Previously, written_valid_blocks was got by ckpt->valid_block_count. But if
the last checkpoint has some NEW_ADDR due to power-cut, we can get wrong value.
Fix it to get the number from actual written block count from sit entries.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 20eedf0eb751..808cb6800852 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2255,7 +2255,6 @@ out: static int build_sit_info(struct f2fs_sb_info *sbi) { struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); - struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); struct sit_info *sit_i; unsigned int sit_segs, start; char *src_bitmap, *dst_bitmap; @@ -2322,7 +2321,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi) sit_i->sit_base_addr = le32_to_cpu(raw_super->sit_blkaddr); sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; - sit_i->written_valid_blocks = le64_to_cpu(ckpt->valid_block_count); + sit_i->written_valid_blocks = 0; sit_i->sit_bitmap = dst_bitmap; sit_i->bitmap_size = bitmap_size; sit_i->dirty_sentries = 0; @@ -2476,6 +2475,9 @@ static void init_free_segmap(struct f2fs_sb_info *sbi) struct seg_entry *sentry = get_seg_entry(sbi, start); if (!sentry->valid_blocks) __set_free(sbi, start); + else + SIT_I(sbi)->written_valid_blocks += + sentry->valid_blocks; } /* set use the current segments */ |