* [f2fs-dev] [PATCH] f2fs: use multiplication instead of division in sanity_check_raw_super
@ 2019-07-01 13:38 Liu Song via Linux-f2fs-devel
2019-07-01 14:37 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Liu Song via Linux-f2fs-devel @ 2019-07-01 13:38 UTC (permalink / raw)
To: jaegeuk, yuchao0; +Cc: liu.song11, linux-kernel, linux-f2fs-devel
From: Liu Song <liu.song11@zte.com.cn>
Use multiplication instead of division and be more
consistent with f2fs_msg output information.
Signed-off-by: Liu Song <liu.song11@zte.com.cn>
---
fs/f2fs/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index af58b2cc21b8..eba4c0f9c347 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -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);
--
2.20.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: use multiplication instead of division in sanity_check_raw_super
2019-07-01 13:38 [f2fs-dev] [PATCH] f2fs: use multiplication instead of division in sanity_check_raw_super Liu Song via Linux-f2fs-devel
@ 2019-07-01 14:37 ` Chao Yu
2019-07-02 13:32 ` fishland via Linux-f2fs-devel
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2019-07-01 14:37 UTC (permalink / raw)
To: Liu Song, jaegeuk, yuchao0; +Cc: linux-f2fs-devel, liu.song11, linux-kernel
Hi Song,
On 2019-7-1 21:38, Liu Song via Linux-f2fs-devel wrote:
> From: Liu Song <liu.song11@zte.com.cn>
>
> Use multiplication instead of division and be more
> consistent with f2fs_msg output information.
>
> Signed-off-by: Liu Song <liu.song11@zte.com.cn>
> ---
> fs/f2fs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index af58b2cc21b8..eba4c0f9c347 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -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,
> + 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
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: use multiplication instead of division in sanity_check_raw_super
2019-07-01 14:37 ` Chao Yu
@ 2019-07-02 13:32 ` fishland via Linux-f2fs-devel
0 siblings, 0 replies; 3+ messages in thread
From: fishland via Linux-f2fs-devel @ 2019-07-02 13:32 UTC (permalink / raw)
To: Chao Yu, jaegeuk, yuchao0; +Cc: linux-f2fs-devel, liu.song11, linux-kernel
Hi Chao,
Thanks for your reply, I understand why there can't use multiplication, thanks a lot :D
Best regards
Liu Song
>Hi Song,
>
>On 2019-7-1 21:38, Liu Song via Linux-f2fs-devel wrote:
>> From: Liu Song <liu.song11@zte.com.cn>
>>
>> Use multiplication instead of division and be more
>> consistent with f2fs_msg output information.
>>
>> Signed-off-by: Liu Song <liu.song11@zte.com.cn>
>> ---
>> fs/f2fs/super.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index af58b2cc21b8..eba4c0f9c347 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -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,
>
>> + 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
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-02 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-01 13:38 [f2fs-dev] [PATCH] f2fs: use multiplication instead of division in sanity_check_raw_super Liu Song via Linux-f2fs-devel
2019-07-01 14:37 ` Chao Yu
2019-07-02 13:32 ` fishland via Linux-f2fs-devel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).