We must guarantee that current segments should be different between different
logs.
This should resolve xfstests/generic/015 panic.

Fixes: 8f9327c0c02ee1 ("mkfs.f2fs: use noheap by default")
Signed-off-by: Jaegeuk Kim <jaeg...@kernel.org>
---
 mkfs/f2fs_format.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index ca47385..d354c88 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -117,6 +117,24 @@ next:
        free(c.extension_list);
 }
 
+static void verify_cur_segs(void)
+{
+       int i, j;
+
+       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])
+                               break;
+       }
+
+       if (i == NR_CURSEG_TYPE && j == NR_CURSEG_TYPE)
+               return;
+
+       c.cur_seg[0] = 0;
+       for (i = 1; i < NR_CURSEG_TYPE; i++)
+               c.cur_seg[i] = next_zone(i - 1);
+}
+
 static int f2fs_prepare_super_block(void)
 {
        u_int32_t blk_size_bytes;
@@ -384,6 +402,9 @@ static int f2fs_prepare_super_block(void)
                                        next_zone(CURSEG_COLD_DATA));
        }
 
+       /* if there is redundancy, reassign it */
+       verify_cur_segs();
+
        cure_extension_list();
 
        /* get kernel version */
-- 
2.11.0


------------------------------------------------------------------------------
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