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 <jaeg...@kernel.org>
> > 
> > Reviewed-by: Chao Yu <yuch...@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 <jaeg...@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 <yuch...@huawei.com>
Signed-off-by: Jaegeuk Kim <jaeg...@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
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to