All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mkfs.f2fs: fix wrong curseg check
@ 2017-08-26  0:10 Jaegeuk Kim
  2017-08-28  9:47 ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2017-08-26  0:10 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

We should avoid i==j, otherwise we always assign 0~5 segments.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 mkfs/f2fs_format.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index b379e80..219c2a7 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -123,7 +123,7 @@ static void verify_cur_segs(void)
 
 	for (i = 0; i < NR_CURSEG_TYPE; i++) {
 		for (j = 0; j < NR_CURSEG_TYPE; j++)
-			if (c.cur_seg[i] == c.cur_seg[j])
+			if (i != j && c.cur_seg[i] == c.cur_seg[j])
 				break;
 	}
 
-- 
2.14.0.rc1.383.gd1ce394fe2-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mkfs.f2fs: fix wrong curseg check
  2017-08-26  0:10 [PATCH] mkfs.f2fs: fix wrong curseg check Jaegeuk Kim
@ 2017-08-28  9:47 ` Chao Yu
  2017-09-05 12:43   ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2017-08-28  9:47 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-f2fs-devel

On 2017/8/26 8:10, Jaegeuk Kim wrote:
> We should avoid i==j, otherwise we always assign 0~5 segments.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

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

> ---
>  mkfs/f2fs_format.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index b379e80..219c2a7 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -123,7 +123,7 @@ static void verify_cur_segs(void)
>  
>  	for (i = 0; i < NR_CURSEG_TYPE; i++) {
>  		for (j = 0; j < NR_CURSEG_TYPE; j++)
> -			if (c.cur_seg[i] == c.cur_seg[j])
> +			if (i != j && c.cur_seg[i] == c.cur_seg[j])
>  				break;
>  	}
>  
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mkfs.f2fs: fix wrong curseg check
  2017-08-28  9:47 ` Chao Yu
@ 2017-09-05 12:43   ` Chao Yu
  2017-09-05 17:47     ` Jaegeuk Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2017-09-05 12:43 UTC (permalink / raw)
  To: Chao Yu, Jaegeuk Kim, linux-f2fs-devel

Hi Jaegeuk,

I still can hit kernel panic with this patch, the reason is reorder of log header
during mkfs is not actually executed, it needs to change as below.

On 2017/8/28 17:47, Chao Yu wrote:
> On 2017/8/26 8:10, Jaegeuk Kim wrote:
>> We should avoid i==j, otherwise we always assign 0~5 segments.
>>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
>> ---
>>  mkfs/f2fs_format.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
>> index b379e80..219c2a7 100644
>> --- a/mkfs/f2fs_format.c
>> +++ b/mkfs/f2fs_format.c
>> @@ -123,7 +123,7 @@ static void verify_cur_segs(void)
>>  
>>  	for (i = 0; i < NR_CURSEG_TYPE; i++) {
>>  		for (j = 0; j < NR_CURSEG_TYPE; j++)
>> -			if (c.cur_seg[i] == c.cur_seg[j])
>> +			if (i != j && c.cur_seg[i] == c.cur_seg[j])
>>  				break;

	if (i != j && c.cur_seg[i] == c.cur_seg[j])
		goto reorder;
return;

reorder:
c.cur_seg[0] = 0;

Thanks,

>>  	}
>>  
>>
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mkfs.f2fs: fix wrong curseg check
  2017-09-05 12:43   ` Chao Yu
@ 2017-09-05 17:47     ` Jaegeuk Kim
  2017-09-06  3:41       ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2017-09-05 17:47 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

On 09/05, Chao Yu wrote:
> Hi Jaegeuk,
> 
> I still can hit kernel panic with this patch, the reason is reorder of log header
> during mkfs is not actually executed, it needs to change as below.
> 
> On 2017/8/28 17:47, Chao Yu wrote:
> > On 2017/8/26 8:10, Jaegeuk Kim wrote:
> >> We should avoid i==j, otherwise we always assign 0~5 segments.
> >>
> >> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > 
> > Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > 
> >> ---
> >>  mkfs/f2fs_format.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> >> index b379e80..219c2a7 100644
> >> --- a/mkfs/f2fs_format.c
> >> +++ b/mkfs/f2fs_format.c
> >> @@ -123,7 +123,7 @@ static void verify_cur_segs(void)
> >>  
> >>  	for (i = 0; i < NR_CURSEG_TYPE; i++) {
> >>  		for (j = 0; j < NR_CURSEG_TYPE; j++)
> >> -			if (c.cur_seg[i] == c.cur_seg[j])
> >> +			if (i != j && c.cur_seg[i] == c.cur_seg[j])
> >>  				break;
> 
> 	if (i != j && c.cur_seg[i] == c.cur_seg[j])

Can be overflowed?

How about this?

>From 53923f74b188028c4f5a8b64b330f0d7b12adf24 Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <jaegeuk@kernel.org>
Date: Thu, 24 Aug 2017 19:33:10 -0700
Subject: [PATCH] mkfs.f2fs: fix wrong curseg check

We should avoid i==j, otherwise we always assign 0~5 segments.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 mkfs/f2fs_format.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index b379e80..8319f24 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -120,14 +120,18 @@ next:
 static void verify_cur_segs(void)
 {
 	int i, j;
+	bool reorder = false;
 
 	for (i = 0; i < NR_CURSEG_TYPE; i++) {
-		for (j = 0; j < NR_CURSEG_TYPE; j++)
-			if (c.cur_seg[i] == c.cur_seg[j])
+		for (j = i + 1; j < NR_CURSEG_TYPE; j++) {
+			if (c.cur_seg[i] == c.cur_seg[j]) {
+				reorder = true;
 				break;
+			}
+		}
 	}
 
-	if (i == NR_CURSEG_TYPE && j == NR_CURSEG_TYPE)
+	if (!reorder)
 		return;
 
 	c.cur_seg[0] = 0;
-- 
2.14.0.rc1.383.gd1ce394fe2-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mkfs.f2fs: fix wrong curseg check
  2017-09-05 17:47     ` Jaegeuk Kim
@ 2017-09-06  3:41       ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2017-09-06  3:41 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: linux-f2fs-devel

On 2017/9/6 1:47, Jaegeuk Kim wrote:
> On 09/05, Chao Yu wrote:
>> Hi Jaegeuk,
>>
>> I still can hit kernel panic with this patch, the reason is reorder of log header
>> during mkfs is not actually executed, it needs to change as below.
>>
>> On 2017/8/28 17:47, Chao Yu wrote:
>>> On 2017/8/26 8:10, Jaegeuk Kim wrote:
>>>> We should avoid i==j, otherwise we always assign 0~5 segments.
>>>>
>>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>>
>>> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>>>
>>>> ---
>>>>  mkfs/f2fs_format.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
>>>> index b379e80..219c2a7 100644
>>>> --- a/mkfs/f2fs_format.c
>>>> +++ b/mkfs/f2fs_format.c
>>>> @@ -123,7 +123,7 @@ static void verify_cur_segs(void)
>>>>  
>>>>  	for (i = 0; i < NR_CURSEG_TYPE; i++) {
>>>>  		for (j = 0; j < NR_CURSEG_TYPE; j++)
>>>> -			if (c.cur_seg[i] == c.cur_seg[j])
>>>> +			if (i != j && c.cur_seg[i] == c.cur_seg[j])
>>>>  				break;
>>
>> 	if (i != j && c.cur_seg[i] == c.cur_seg[j])
> 
> Can be overflowed?
> 
> How about this?

It's OK to me. :)

Thanks,

> 
>>From 53923f74b188028c4f5a8b64b330f0d7b12adf24 Mon Sep 17 00:00:00 2001
> From: Jaegeuk Kim <jaegeuk@kernel.org>
> Date: Thu, 24 Aug 2017 19:33:10 -0700
> Subject: [PATCH] mkfs.f2fs: fix wrong curseg check
> 
> We should avoid i==j, otherwise we always assign 0~5 segments.
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  mkfs/f2fs_format.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index b379e80..8319f24 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -120,14 +120,18 @@ next:
>  static void verify_cur_segs(void)
>  {
>  	int i, j;
> +	bool reorder = false;
>  
>  	for (i = 0; i < NR_CURSEG_TYPE; i++) {
> -		for (j = 0; j < NR_CURSEG_TYPE; j++)
> -			if (c.cur_seg[i] == c.cur_seg[j])
> +		for (j = i + 1; j < NR_CURSEG_TYPE; j++) {
> +			if (c.cur_seg[i] == c.cur_seg[j]) {
> +				reorder = true;
>  				break;
> +			}
> +		}
>  	}
>  
> -	if (i == NR_CURSEG_TYPE && j == NR_CURSEG_TYPE)
> +	if (!reorder)
>  		return;
>  
>  	c.cur_seg[0] = 0;
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-06  3:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-26  0:10 [PATCH] mkfs.f2fs: fix wrong curseg check Jaegeuk Kim
2017-08-28  9:47 ` Chao Yu
2017-09-05 12:43   ` Chao Yu
2017-09-05 17:47     ` Jaegeuk Kim
2017-09-06  3:41       ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.