mkfs.f2fs: fix wrong curseg check
PATCH 1/1 mkfs.f2fs: fix wrong curseg check
We should avoid i==j, otherwise we always assign 0~5 segments.
--- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mkfs/f2fs_format.c +1 -1
@@ -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 ; }
Signature · 6 lines
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
Quoted 3 lines · Jaegeuk Kim
We should avoid i==j, otherwise we always assign 0~5 segments.
Signed-off-by Jaegeuk Kim <[email protected]>
Quoted 10 lines
--- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mkfs/f2fs_format.c +0
-0
mkfs/f2fs_format.c static void verify_cur_segs(void) · line 129
Quoted 8 lines
mkfs/f2fs_format.c +1
-1@@ -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
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.
Quoted 17 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
We should avoid i==j, otherwise we always assign 0~5 segments.
Signed-off-by Jaegeuk Kim <[email protected]>Reviewed-by Chao Yu <[email protected]>Quoted 10 lines
--- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mkfs/f2fs_format.c +0
-0@@ -123,7 +123,7 @@ static void verify_cur_segs(void)
Quoted 5 lines
mkfs/f2fs_format.c static void verify_cur_segs(void) · line 127
Quoted 5 lines
mkfs/f2fs_format.c +1
-1for (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,
Quoted 5 lines
mkfs/f2fs_format.c static void verify_cur_segs(void) · line 129
Quoted 3 lines
mkfs/f2fs_format.c +0
-0}
Quoted 8 lines
------------------------------------------------------------------------------
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 [email protected]
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
Jaegeuk Kim
Reviewed-by Chao YuQuoted 23 lines · Chao Yu
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.
Quoted 17 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
We should avoid i==j, otherwise we always assign 0~5 segments.
Signed-off-by Jaegeuk Kim <[email protected]>Reviewed-by Chao Yu <[email protected]>Quoted 10 lines
--- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mkfs/f2fs_format.c +0
-0@@ -123,7 +123,7 @@ static void verify_cur_segs(void)
Quoted 7 lines
Quoted 5 lines
mkfs/f2fs_format.c static void verify_cur_segs(void) · line 127
Quoted 5 lines
mkfs/f2fs_format.c +1
-1for (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?
Quoted 1 line
From
53923f74b188028c4f5a8b64b330f0d7b12adf24Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
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.
--- mkfs/f2fs_format.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
mkfs/f2fs_format.c +7 -3
@@ -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 ;
Signature · 6 lines
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
Quoted 32 lines · Jaegeuk Kim
Quoted 23 lines · Chao Yu
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.
Quoted 17 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
We should avoid i==j, otherwise we always assign 0~5 segments.
Signed-off-by Jaegeuk Kim <[email protected]>Reviewed-by Chao Yu <[email protected]>Quoted 10 lines
--- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mkfs/f2fs_format.c +0
-0@@ -123,7 +123,7 @@ static void verify_cur_segs(void)Quoted 7 lines
Quoted 5 lines
mkfs/f2fs_format.c next: · line 129
Quoted 5 lines
mkfs/f2fs_format.c +1
-1for (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])
Quoted 3 lines
Can be overflowed?
How about this?
It's OK to me. :)
Thanks,
Quoted 31 lines
Quoted 2 lines
From
53923f74b188028c4f5a8b64b330f0d7b12adf24Mon Sep 17 00:00:00 2001From: Jaegeuk Kim <[email protected]>
Date: Thu, 24 Aug 2017 19:33:10 -0700
Subject: [PATCH] mkfs.f2fs: fix wrong curseg checkWe should avoid i==j, otherwise we always assign 0~5 segments.
Reviewed-by Chao Yu <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>--- mkfs/f2fs_format.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)mkfs/f2fs_format.c +4
-2@@ -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;
mkfs/f2fs_format.c next: · line 137
Quoted 10 lines
mkfs/f2fs_format.c +3
-1break ; + } + } } -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