Skip to contentSkip to conversation

f2fs: don't discard next free dnode page for an umount checkpoint

PATCH In review Chao Yu 2 participants 4 messages Jan 31, 2015 – Feb 6, 2015 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 2/2 f2fs: don't discard next free dnode page for an umount checkpoint

Previously, discard_next_dnode is added before a checkpoint to prevent that we may meet a garbage dnode page readed from next free blkaddr in recover flow.

Since f2fs will skip recovery flow for a clean umount image, this condition will never happen.

So it's safe for us to leave next free dnode as it is in an umount checkpoint.

---
 fs/f2fs/checkpoint.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +5 -1
index f7cdcad..991fd0a 100644
@@ -905,8 +905,12 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	/*
 	 * This avoids to conduct wrong roll-forward operations and uses
 	 * metapages, so should be called prior to sync_meta_pages below.
+	 * But if we are in an umount checkpoint, we'd better skip this
+	 * because we will not enter recovery flow to use the next free
+	 * blkaddr when mounting it.
 	 */
-	discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));
+	if (cpc->reason != CP_UMOUNT)
+		discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));
 
 	/* Flush all the NAT/SIT pages */
 	while (get_pages(sbi, F2FS_DIRTY_META)) {
Signature · 1 line
2.2.1
maintainer
#1 lore raw

Hi Chao,

Quoted 18 lines · Chao Yu

Previously, discard_next_dnode is added before a checkpoint to prevent that we may meet a garbage dnode page readed from next free blkaddr in recover flow.

Since f2fs will skip recovery flow for a clean umount image, this condition will never happen.

So it's safe for us to leave next free dnode as it is in an umount checkpoint.

---
 fs/f2fs/checkpoint.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +0 -0
index f7cdcad..991fd0a 100644

fs/f2fs/checkpoint.c static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 913

Quoted 10 lines
fs/f2fs/checkpoint.c +5 -1
@@ -905,8 +905,12 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	/*
 	 * This avoids to conduct wrong roll-forward operations and uses
 	 * metapages, so should be called prior to sync_meta_pages below.
+	 * But if we are in an umount checkpoint, we'd better skip this
+	 * because we will not enter recovery flow to use the next free
+	 * blkaddr when mounting it.
 	 */
-	discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));
+	if (cpc->reason != CP_UMOUNT)
+		discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));

The reason for discard_next_dnode is to avoid wrong execution due to old mkfs.f2fs which remains gabage data.
It needs to do all the time.

Thanks,

Quoted 5 lines
fs/f2fs/checkpoint.c +0 -0
 	/* Flush all the NAT/SIT pages */
 	while (get_pages(sbi, F2FS_DIRTY_META)) {
Signature · 1 line
2.2.1
author
#2 lore raw

Hi Jaegeuk,

Quoted 29 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, February 03, 2015 7:38 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] f2fs: don't discard next free dnode page for an umount checkpoint

Hi Chao,

fs/f2fs/checkpoint.c static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control

Quoted 18 lines · Chao Yu

Previously, discard_next_dnode is added before a checkpoint to prevent that we may meet a garbage dnode page readed from next free blkaddr in recover flow.

Since f2fs will skip recovery flow for a clean umount image, this condition will never happen.

So it's safe for us to leave next free dnode as it is in an umount checkpoint.

---
 fs/f2fs/checkpoint.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +0 -0
index f7cdcad..991fd0a 100644
@@ -905,8 +905,12 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control

*cpc)

Quoted 14 lines

fs/f2fs/checkpoint.c static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 913

Quoted 10 lines
fs/f2fs/checkpoint.c +5 -1
 	/*
 	 * This avoids to conduct wrong roll-forward operations and uses
 	 * metapages, so should be called prior to sync_meta_pages below.
+	 * But if we are in an umount checkpoint, we'd better skip this
+	 * because we will not enter recovery flow to use the next free
+	 * blkaddr when mounting it.
 	 */
-	discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));
+	if (cpc->reason != CP_UMOUNT)
+		discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));

The reason for discard_next_dnode is to avoid wrong execution due to old mkfs.f2fs which remains gabage data.
It needs to do all the time.

Maybe my previously understanding is wrong.

Is this issue due to old mkfs.f2fs do not discard entire flash storage device when formating? Or another bug of mkfs? If so, can you please offer a fix commit id of mkfs?

I'm curious about how this happened. :-)

Thanks,

Quoted 8 lines

Thanks,

Quoted 5 lines
fs/f2fs/checkpoint.c +0 -1
 	/* Flush all the NAT/SIT pages */
 	while (get_pages(sbi, F2FS_DIRTY_META)) {
--

2.2.1

maintainer
#3 lore raw

Hi Chao,

Quoted 46 lines · Chao Yu

Hi Jaegeuk,

Quoted 29 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, February 03, 2015 7:38 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] f2fs: don't discard next free dnode page for an umount checkpoint

Hi Chao,

fs/f2fs/checkpoint.c static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control

Quoted 18 lines · Chao Yu

Previously, discard_next_dnode is added before a checkpoint to prevent that we may meet a garbage dnode page readed from next free blkaddr in recover flow.

Since f2fs will skip recovery flow for a clean umount image, this condition will never happen.

So it's safe for us to leave next free dnode as it is in an umount checkpoint.

---
 fs/f2fs/checkpoint.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +0 -0
index f7cdcad..991fd0a 100644
@@ -905,8 +905,12 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control

*cpc)

Quoted 14 lines

fs/f2fs/checkpoint.c static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 913

Quoted 10 lines
fs/f2fs/checkpoint.c +5 -1
 	/*
 	 * This avoids to conduct wrong roll-forward operations and uses
 	 * metapages, so should be called prior to sync_meta_pages below.
+	 * But if we are in an umount checkpoint, we'd better skip this
+	 * because we will not enter recovery flow to use the next free
+	 * blkaddr when mounting it.
 	 */
-	discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));
+	if (cpc->reason != CP_UMOUNT)
+		discard_next_dnode(sbi, NEXT_FREE_BLKADDR(sbi, curseg));

The reason for discard_next_dnode is to avoid wrong execution due to old mkfs.f2fs which remains gabage data.
It needs to do all the time.

Quoted 5 lines

Maybe my previously understanding is wrong.

Is this issue due to old mkfs.f2fs do not discard entire flash storage device when formating? Or another bug of mkfs? If so, can you please offer a fix commit id of mkfs?

commit ffbada4298c7aed059bb99a8d553d6dd555963c0

Author: Jaegeuk Kim <[email protected]>
Date:   Mon Nov 11 13:29:11 2013 +0900

mkfs: remove stale node blocks

If the device does not support discard, we should write zero blocks to avoid roll-forward recovery.

Thanks,

Quoted 12 lines

I'm curious about how this happened. :-)

Thanks,

Quoted 8 lines

Thanks,

Quoted 5 lines
fs/f2fs/checkpoint.c +0 -1
 	/* Flush all the NAT/SIT pages */
 	while (get_pages(sbi, F2FS_DIRTY_META)) {
--

2.2.1