f2fs: do not change the valid_block value if cur_valid_map was wrongly set or cleared
diff mbox

Message ID 1501683414-54834-1-git-send-email-yunlong.song@huawei.com
State New
Headers show

Commit Message

Yunlong Song Aug. 2, 2017, 2:16 p.m. UTC
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/segment.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Chao Yu Aug. 5, 2017, 1:23 a.m. UTC | #1
On 2017/8/2 22:16, Yunlong Song wrote:
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

> ---
>  fs/f2fs/segment.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 40e40c5..9e3249a 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1540,6 +1540,8 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
>  			f2fs_msg(sbi->sb, KERN_ERR,
>  				"Bitmap was wrongly set, blk:%u", blkaddr);
>  			f2fs_bug_on(sbi, 1);
> +			se->valid_blocks--;
> +			del = 0;
>  		}
>  
>  		if (f2fs_discard_en(sbi) &&
> @@ -1567,6 +1569,8 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
>  			f2fs_msg(sbi->sb, KERN_ERR,
>  				"Bitmap was wrongly cleared, blk:%u", blkaddr);
>  			f2fs_bug_on(sbi, 1);
> +			se->valid_blocks++;
> +			del = 0;
>  		}
>  
>  		if (f2fs_discard_en(sbi) &&
>

Patch
diff mbox

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 40e40c5..9e3249a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1540,6 +1540,8 @@  static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
 			f2fs_msg(sbi->sb, KERN_ERR,
 				"Bitmap was wrongly set, blk:%u", blkaddr);
 			f2fs_bug_on(sbi, 1);
+			se->valid_blocks--;
+			del = 0;
 		}
 
 		if (f2fs_discard_en(sbi) &&
@@ -1567,6 +1569,8 @@  static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
 			f2fs_msg(sbi->sb, KERN_ERR,
 				"Bitmap was wrongly cleared, blk:%u", blkaddr);
 			f2fs_bug_on(sbi, 1);
+			se->valid_blocks++;
+			del = 0;
 		}
 
 		if (f2fs_discard_en(sbi) &&