linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] mkfs.f2fs: fix wrong segment assignment
@ 2017-04-26  0:53 Jaegeuk Kim
  0 siblings, 0 replies; only message in thread
From: Jaegeuk Kim @ 2017-04-26  0:53 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-26  0:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-26  0:53 [PATCH] mkfs.f2fs: fix wrong segment assignment Jaegeuk Kim

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