Skip to contentSkip to conversation

defrag.f2fs: fix missing SSA updates

PATCH New Jaegeuk Kim 1 participant 2 messages Dec 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 defrag.f2fs: fix missing SSA updates

Previously SSA is updated if it is not included in current segment info. But, defrag.f2fs doesn't handle current segment info during the process, and instead lastly update the whole current segment info at a time. So, we need to update summary entries all the time.
Otherwise, we can lose the SSA entry.

---
 fsck/mount.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fsck/mount.c +6 -3
index 79611e5..d2f1432 100644
@@ -761,13 +761,16 @@ void update_sum_entry(struct f2fs_sb_info *sbi, block_t blk_addr,
 	sum_blk->footer.entry_type = IS_NODESEG(se->type) ? SUM_TYPE_NODE :
 							SUM_TYPE_DATA;
 
-	if (type == SEG_TYPE_NODE || type == SEG_TYPE_DATA ||
-					type == SEG_TYPE_MAX) {
+	/* write SSA all the time */
+	if (type < SEG_TYPE_MAX) {
 		u64 ssa_blk = GET_SUM_BLKADDR(sbi, segno);
 		ret = dev_write_block(sum_blk, ssa_blk);
 		ASSERT(ret >= 0);
-		free(sum_blk);
 	}
+
+	if (type == SEG_TYPE_NODE || type == SEG_TYPE_DATA ||
+					type == SEG_TYPE_MAX)
+		free(sum_blk);
 }
 
 static void restore_curseg_summaries(struct f2fs_sb_info *sbi)
Signature · 4 lines
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------
#1 lore raw

PATCH 2/2 fsck.f2fs: fix losing journal entries

If fsck.f2fs reports a bug, move_curseg_info tries to change the current segment info.
When it changes the new summary block, it overwrites the existing journal entries.
This patch fixes it not to overwrite journal entry space.

---
 fsck/mount.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fsck/mount.c +4 -1
index d2f1432..fe68f37 100644
@@ -1438,6 +1438,7 @@ void move_curseg_info(struct f2fs_sb_info *sbi, u64 from)
 	/* update summary blocks having nullified journal entries */
 	for (i = 0; i < NO_CHECK_TYPE; i++) {
 		struct curseg_info *curseg = CURSEG_I(sbi, i);
+		struct f2fs_summary_block buf;
 		u32 old_segno;
 		u64 ssa_blk, to;
 
@@ -1457,9 +1458,11 @@ void move_curseg_info(struct f2fs_sb_info *sbi, u64 from)
 
 		/* update new segno */
 		ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno);
-		ret = dev_read_block(curseg->sum_blk, ssa_blk);
+		ret = dev_read_block(&buf, ssa_blk);
 		ASSERT(ret >= 0);
 
+		memcpy(curseg->sum_blk, &buf, SUM_ENTRIES_SIZE);
+
 		/* update se->types */
 		reset_curseg(sbi, i);
 
Signature · 4 lines
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------