linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsck.f2fs: avoid false alarm on SIT type fix
@ 2014-11-14  0:56 Jaegeuk Kim
  0 siblings, 0 replies; only message in thread
From: Jaegeuk Kim @ 2014-11-14  0:56 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch removed a false alarm when detecting any inconsistency in SIT types.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/f2fs.h  |  1 +
 fsck/fsck.c  | 35 ++++++++++++++++++++++++++++++-----
 fsck/mount.c |  1 +
 3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index 47f785d..57bad9b 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -72,6 +72,7 @@ struct seg_entry {
 	unsigned short ckpt_valid_blocks;
 	unsigned char *ckpt_valid_map;
 	unsigned char type;             /* segment type like CURSEG_XXX_TYPE */
+	unsigned char orig_type;        /* segment type like CURSEG_XXX_TYPE */
 	unsigned long long mtime;       /* modification time of the segment */
 };
 
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 78737d5..994145e 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -23,17 +23,15 @@ static inline int f2fs_set_main_bitmap(struct f2fs_sb_info *sbi, u32 blk,
 	if (se->type != type) {
 		if (type == CURSEG_WARM_DATA) {
 			if (se->type != CURSEG_COLD_DATA) {
-				FIX_MSG("Wrong segment type [0x%x] %x -> %x",
+				DBG(1, "Wrong segment type [0x%x] %x -> %x",
 						GET_SEGNO(sbi, blk), se->type,
 						CURSEG_WARM_DATA);
 				se->type = CURSEG_WARM_DATA;
-				config.bug_on = 1;
 			}
 		} else {
-			FIX_MSG("Wrong segment type [0x%x] %x -> %x",
+			DBG(1, "Wrong segment type [0x%x] %x -> %x",
 				GET_SEGNO(sbi, blk), se->type, type);
 			se->type = type;
-			config.bug_on = 1;
 		}
 	}
 	return f2fs_set_bit(BLKOFF_FROM_MAIN(sbi, blk), fsck->main_area_bitmap);
@@ -998,6 +996,25 @@ int check_curseg_offset(struct f2fs_sb_info *sbi)
 	return 0;
 }
 
+int check_sit_types(struct f2fs_sb_info *sbi)
+{
+	struct seg_entry *se;
+	unsigned int i;
+	int err = 0;
+
+	for (i = 0; i < TOTAL_SEGS(sbi); i++) {
+		struct seg_entry *se;
+
+		se = get_seg_entry(sbi, i);
+		if (se->orig_type != se->type) {
+			FIX_MSG("Wrong segment type [0x%x] %x -> %x",
+					i, se->orig_type, se->type);
+			err = -EINVAL;
+		}
+	}
+	return err;
+}
+
 int fsck_verify(struct f2fs_sb_info *sbi)
 {
 	unsigned int i = 0;
@@ -1108,13 +1125,21 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		config.bug_on = 1;
 	}
 
+	printf("[FSCK] SIT types                                     ");
+	if (check_sit_types(sbi) == 0) {
+		printf(" [Ok..]\n");
+	} else {
+		printf(" [Fail]\n");
+		ret = EXIT_ERR_CODE;
+		config.bug_on = 1;
+	}
+
 	printf("[FSCK] other corrupted bugs                          ");
 	if (config.bug_on == 0) {
 		printf(" [Ok..]\n");
 	} else {
 		printf(" [Fail]\n");
 		ret = EXIT_ERR_CODE;
-		config.bug_on = 1;
 	}
 
 	/* fix global metadata */
diff --git a/fsck/mount.c b/fsck/mount.c
index 8ff7ff7..0aca60b 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -795,6 +795,7 @@ void seg_info_from_raw_sit(struct seg_entry *se,
 	memcpy(se->cur_valid_map, raw_sit->valid_map, SIT_VBLOCK_MAP_SIZE);
 	memcpy(se->ckpt_valid_map, raw_sit->valid_map, SIT_VBLOCK_MAP_SIZE);
 	se->type = GET_SIT_TYPE(raw_sit);
+	se->orig_type = GET_SIT_TYPE(raw_sit);
 	se->mtime = le64_to_cpu(raw_sit->mtime);
 }
 
-- 
2.1.1


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk

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

only message in thread, other threads:[~2014-11-14  0:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-14  0:56 [PATCH] fsck.f2fs: avoid false alarm on SIT type fix 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).