linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] No need to do recovery if there is no available CP
@ 2013-11-03 15:08 Huajun Li
  2013-11-04  1:24 ` Jaegeuk Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Huajun Li @ 2013-11-03 15:08 UTC (permalink / raw)
  To: jaegeuk.kim, linux-f2fs-devel; +Cc: linux-fsdevel, Huajun Li

From: Huajun Li <huajun.li@intel.com>

Normally we expect an empty partition after formatting by
mkfs.f2fs. But in this case, when we format a dirty partition and mount
it again. The former file will be recovered and available again! and
kernel log shows a recovery procedure is evoked.
This patch adds a new flag CP_EXIST_FLAG to indicate whether is a
available CP, and do recovery only when this flag is set.

You can reproduce the bug by following script:
===================================
	TEST_DEV=/dev/sdb1
	umount $TEST_DEV
	mkfs.f2fs $TEST_DEV > /dev/null
	mount -t f2fs $TEST_DEV /mnt
	dmesg -c > /dev/null

	echo
	echo "Small Vector Sync"
	echo "abcdefghijklmnopqrstuvwxyz" > /mnt/small_vector_async

	xfs_io -F -f -s -c "pread -v 0 1"\
	    -c "pwrite -S 0x61 4090 1"\
	    /mnt/small_vector_async

	umount $TEST_DEV

	mkfs.f2fs $TEST_DEV
	#After we format a partition, there should be nothing but root in it.
	#But in this case, when we format a used partition and mount it again,
	#the former created file small_vector_async will be recover!

	mount -t f2fs $TEST_DEV /mnt
	#We expect nothing after mkfs, but in this case small_vector_async will
	#be recovered when we mount the partition.

	ls /mnt
	dmesg


Signed-off-by: Huajun Li <huajun.li@intel.com>
Reported-and-tested-by: Weihong Xu <weihong.xu@intel.com>
---
 fs/f2fs/checkpoint.c    |    2 ++
 fs/f2fs/super.c         |    3 ++-
 include/linux/f2fs_fs.h |    1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index d430157..22b3972 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -767,6 +767,8 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
 		clear_prefree_segments(sbi);
 		F2FS_RESET_SB_DIRT(sbi);
 	}
+	if (!is_set_ckpt_flags(ckpt, CP_EXIST_FLAG))
+		set_ckpt_flags(ckpt, CP_EXIST_FLAG);
 }
 
 /*
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e42351c..963da7d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -959,7 +959,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	}
 
 	/* recover fsynced data */
-	if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
+	if (!test_opt(sbi, DISABLE_ROLL_FORWARD) &&
+	    is_set_ckpt_flags(F2FS_CKPT(sbi), CP_EXIST_FLAG)) {
 		err = recover_fsync_data(sbi);
 		if (err)
 			f2fs_msg(sb, KERN_ERR,
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index bb942f6..6e48f22 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -80,6 +80,7 @@ struct f2fs_super_block {
 /*
  * For checkpoint
  */
+#define CP_EXIST_FLAG		0x00000010
 #define CP_ERROR_FLAG		0x00000008
 #define CP_COMPACT_SUM_FLAG	0x00000004
 #define CP_ORPHAN_PRESENT_FLAG	0x00000002
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-11-11  6:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-03 15:08 [PATCH 1/1] No need to do recovery if there is no available CP Huajun Li
2013-11-04  1:24 ` Jaegeuk Kim
2013-11-04 15:40   ` Huajun Li
2013-11-05  4:48     ` Jaegeuk Kim
2013-11-05 13:28       ` Huajun Li
2013-11-11  4:33         ` Jaegeuk Kim
2013-11-11  6:06           ` Huajun Li

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