f2fs: use multiplication instead of division in sanity_check_raw_super
PATCH 1/1 f2fs: use multiplication instead of division in sanity_check_raw_super
From: Liu Song <[email protected]>
Use multiplication instead of division and be more consistent with f2fs_msg output information.
--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/super.c +1 -1
@@ -2489,7 +2489,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } -if ((segment_count / segs_per_sec) < total_sections) { +if (segment_count < (segs_per_sec * total_sections)) {f2fs_msg (sb,KERN_INFO ,"Small segment_count (%u < %u * %u)" , segment_count, segs_per_sec, total_sections);
Signature · 8 lines
2.20.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerHi Song,
Quoted 15 lines · On 2019-7-1 21:38, Liu Song via Linux-f2fs-devel wrote:
From: Liu Song <[email protected]>
Use multiplication instead of division and be more consistent with
f2fs_msgoutput information.Signed-off-by Liu Song <[email protected]>--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/super.c +0
-0
fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2492
Quoted 4 lines
fs/f2fs/super.c +0
-1@@ -2489,7 +2489,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } -if ((segment_count / segs_per_sec) < total_sections) {
I think we use division intentionally to avoid potential overflow when doing multiplication.
You can see the detailed commit message in below fixing patch:
0cfe75c5b011 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows")
Thanks,
Quoted 5 lines
fs/f2fs/super.c +1
-0+if (segment_count < (segs_per_sec * total_sections)) {f2fs_msg (sb,KERN_INFO ,"Small segment_count (%u < %u * %u)" , segment_count, segs_per_sec, total_sections);
Hi Chao,
Thanks for your reply, I understand why there can't use multiplication, thanks a lot :D
Best regards
Liu Song
Quoted 26 lines
Hi Song,
Quoted 15 lines · On 2019-7-1 21:38, Liu Song via Linux-f2fs-devel wrote:
From: Liu Song <[email protected]>
Use multiplication instead of division and be more consistent with
f2fs_msgoutput information.Signed-off-by Liu Song <[email protected]>--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2492
Quoted 4 lines
fs/f2fs/super.c +0
-1@@ -2489,7 +2489,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } -if ((segment_count / segs_per_sec) < total_sections) {I think we use division intentionally to avoid potential overflow when doing multiplication.
Quoted 11 lines
You can see the detailed commit message in below fixing patch:
0cfe75c5b011("f2fs: enhancesanity_check_raw_super()to avoid potential overflows")Thanks,
Quoted 5 lines
fs/f2fs/super.c +1
-0+if (segment_count < (segs_per_sec * total_sections)) {f2fs_msg (sb,KERN_INFO ,"Small segment_count (%u < %u * %u)" , segment_count, segs_per_sec, total_sections);
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel