All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsck.f2fs: flush curseg sit entries
@ 2016-11-23 12:40 Liu Xue
  0 siblings, 0 replies; only message in thread
From: Liu Xue @ 2016-11-23 12:40 UTC (permalink / raw)
  To: jaegeuk, zhengjunling, shengyong1, liuxueliu.liu; +Cc: linux-f2fs-devel

Flush curseg sit entries, since type of sit entries may
be changed after move_curseg_info.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
---
 fsck/fsck.c  | 25 +++++++++++++++++++++++++
 fsck/fsck.h  |  4 ++++
 fsck/mount.c |  2 +-
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 0009ea4..7a536b2 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1729,6 +1729,30 @@ static void fix_nat_entries(struct f2fs_sb_info *sbi)
 			nullify_nat_entry(sbi, i);
 }
 
+static void flush_curseg_sit_entries(struct f2fs_sb_info *sbi)
+{
+	struct sit_info *sit_i = SIT_I(sbi);
+	int i;
+
+	/* update curseg sit entries, since we may change
+	 * a segment type in move_curseg_info
+	 */
+	for (i = 0; i < NO_CHECK_TYPE; i++) {
+		struct curseg_info *curseg = CURSEG_I(sbi, i);
+		struct f2fs_sit_block *sit_blk;
+		struct f2fs_sit_entry *sit;
+		struct seg_entry *se;
+
+		se = get_seg_entry(sbi, curseg->segno);
+		sit_blk = get_current_sit_page(sbi, curseg->segno);
+		sit = &sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, curseg->segno)];
+		sit->vblocks = cpu_to_le16((se->type << SIT_VBLOCKS_SHIFT) |
+							se->valid_blocks);
+		rewrite_current_sit_page(sbi, curseg->segno, sit_blk);
+		free(sit_blk);
+	}
+}
+
 static void fix_checkpoint(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
@@ -1982,6 +2006,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 			rewrite_sit_area_bitmap(sbi);
 			move_curseg_info(sbi, SM_I(sbi)->main_blkaddr);
 			write_curseg_info(sbi);
+			flush_curseg_sit_entries(sbi);
 			fix_checkpoint(sbi);
 		} else if (is_set_ckpt_flags(cp, CP_FSCK_FLAG)) {
 			write_checkpoint(sbi);
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 412e7b7..c106153 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -165,6 +165,10 @@ extern void update_nat_blkaddr(struct f2fs_sb_info *, nid_t, nid_t, block_t);
 extern void print_raw_sb_info(struct f2fs_super_block *);
 
 extern u32 get_free_segments(struct f2fs_sb_info *);
+extern struct f2fs_sit_block *get_current_sit_page(struct f2fs_sb_info *,
+			unsigned int);
+extern void rewrite_current_sit_page(struct f2fs_sb_info *, unsigned int,
+			struct f2fs_sit_block *);
 
 /* dump.c */
 struct dump_option {
diff --git a/fsck/mount.c b/fsck/mount.c
index 9fcb008..e7d5cee 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1018,7 +1018,7 @@ static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
 	ASSERT(segno <= end_segno);
 }
 
-static struct f2fs_sit_block *get_current_sit_page(struct f2fs_sb_info *sbi,
+struct f2fs_sit_block *get_current_sit_page(struct f2fs_sb_info *sbi,
 						unsigned int segno)
 {
 	struct sit_info *sit_i = SIT_I(sbi);
-- 
1.8.5.2


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

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

only message in thread, other threads:[~2016-11-23 12:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-23 12:40 [PATCH] fsck.f2fs: flush curseg sit entries Liu Xue

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.