Skip to contentSkip to conversation

f2fs: don't need to invalidate wrong node page

PATCH In review Jaegeuk Kim 2 participants 8 messages Mar 6, 2017 – Mar 9, 2017

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/2 f2fs: don't need to invalidate wrong node page

If f2fs_new_inode() is failed, the bad inode will invalidate 0'th node page during f2fs_evict_inode(), which doesn't need to do.

---
 fs/f2fs/inode.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +4 -1
index 24bb8213d974..ef8610bf950f 100644
@@ -411,7 +411,10 @@ void f2fs_evict_inode(struct inode *inode)
 	stat_dec_inline_dir(inode);
 	stat_dec_inline_inode(inode);
 
-	invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, inode->i_ino);
+	/* ino == 0, if f2fs_new_inode() was failed t*/
+	if (inode->i_ino)
+		invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino,
+							inode->i_ino);
 	if (xnid)
 		invalidate_mapping_pages(NODE_MAPPING(sbi), xnid, xnid);
 	if (inode->i_nlink) {
Signature · 9 lines
2.11.0


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
author maintainer
#1 lore raw

PATCH 2/2 f2fs: don't overwrite node block by SSR

This patch fixes that SSR can overwrite previous warm node block consisting of a node chain since the last checkpoint.

Fixes 5b6c6be2d878 ("f2fs: use SSR for warm node as well")
---
 fs/f2fs/segment.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/segment.c +6 -0
index 2ae36d04d03e..684b869e1861 100644
@@ -1177,6 +1177,12 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
 		if (f2fs_discard_en(sbi) &&
 			!f2fs_test_and_set_bit(offset, se->discard_map))
 			sbi->discard_blks--;
+
+		/* don't overwrite by SSR to keep node chain */
+		if (se->type == CURSEG_WARM_NODE) {
+			if (!f2fs_test_and_set_bit(offset, se->ckpt_valid_map))
+				se->ckpt_valid_blocks++;
+		}
 	} else {
 		if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) {
 #ifdef CONFIG_F2FS_CHECK_FS
Signature · 9 lines
2.11.0


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
#2 lore raw

Re: [f2fs-dev] [PATCH 2/2] f2fs: don't overwrite node block by SSR

Quoted 2 lines · Jaegeuk Kim

This patch fixes that SSR can overwrite previous warm node block consisting of a node chain since the last checkpoint.

Good catch!

Need to consider the impact to other accesser, e.g. is_checkpointed_data, add_discard_addrs?

Thanks,

Quoted 25 lines
Fixes 5b6c6be2d878 ("f2fs: use SSR for warm node as well")
---
 fs/f2fs/segment.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/segment.c +6 -0
index 2ae36d04d03e..684b869e1861 100644
@@ -1177,6 +1177,12 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
 		if (f2fs_discard_en(sbi) &&
 			!f2fs_test_and_set_bit(offset, se->discard_map))
 			sbi->discard_blks--;
+
+		/* don't overwrite by SSR to keep node chain */
+		if (se->type == CURSEG_WARM_NODE) {
+			if (!f2fs_test_and_set_bit(offset, se->ckpt_valid_map))
+				se->ckpt_valid_blocks++;
+		}
 	} else {
 		if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) {
 #ifdef CONFIG_F2FS_CHECK_FS
author maintainer
#3 lore raw

Re: [f2fs-dev] [PATCH 2/2] f2fs: don't overwrite node block by SSR

Quoted 8 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

This patch fixes that SSR can overwrite previous warm node block consisting of a node chain since the last checkpoint.

Good catch!

Need to consider the impact to other accesser, e.g. is_checkpointed_data, add_discard_addrs?

I've checked them. is_checkpointed_data() has nothing to do with this warm node and this prevents add_discard_addrs to issue discard command.

Thanks,

Quoted 20 lines

Thanks,

Quoted 17 lines
Fixes 5b6c6be2d878 ("f2fs: use SSR for warm node as well")
---
 fs/f2fs/segment.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/segment.c +2 -0
index 2ae36d04d03e..684b869e1861 100644
@@ -1177,6 +1177,12 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
 		if (f2fs_discard_en(sbi) &&
 			!f2fs_test_and_set_bit(offset, se->discard_map))
 			sbi->discard_blks--;
+
+		/* don't overwrite by SSR to keep node chain */
Quoted 8 lines

fs/f2fs/segment.c static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) · line 1188

Quoted 8 lines
fs/f2fs/segment.c +4 -0
+		if (se->type == CURSEG_WARM_NODE) {
+			if (!f2fs_test_and_set_bit(offset, se->ckpt_valid_map))
+				se->ckpt_valid_blocks++;
+		}
 	} else {
 		if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) {
 #ifdef CONFIG_F2FS_CHECK_FS

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford

Reviewed-by
#4 lore raw

Re: [f2fs-dev] [PATCH 2/2] f2fs: don't overwrite node block by SSR

Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

This patch fixes that SSR can overwrite previous warm node block consisting of a node chain since the last checkpoint.

Quoted 7 lines
Quoted 4 lines

Good catch!

Need to consider the impact to other accesser, e.g. is_checkpointed_data, add_discard_addrs?

I've checked them. is_checkpointed_data() has nothing to do with this warm node and this prevents add_discard_addrs to issue discard command.

That's right.

Thanks,

Quoted 34 lines

Thanks,

Quoted 20 lines

Thanks,

Quoted 17 lines
Fixes 5b6c6be2d878 ("f2fs: use SSR for warm node as well")
---
 fs/f2fs/segment.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/segment.c +2 -0
index 2ae36d04d03e..684b869e1861 100644
@@ -1177,6 +1177,12 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
 		if (f2fs_discard_en(sbi) &&
 			!f2fs_test_and_set_bit(offset, se->discard_map))
 			sbi->discard_blks--;
+
+		/* don't overwrite by SSR to keep node chain */
Quoted 8 lines

fs/f2fs/segment.c static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) · line 1188

Quoted 8 lines
fs/f2fs/segment.c +4 -0
+		if (se->type == CURSEG_WARM_NODE) {
+			if (!f2fs_test_and_set_bit(offset, se->ckpt_valid_map))
+				se->ckpt_valid_blocks++;
+		}
 	} else {
 		if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) {
 #ifdef CONFIG_F2FS_CHECK_FS

.

#5 lore raw
In reply to Jaegeuk Kim
Quoted 2 lines · Jaegeuk Kim

If f2fs_new_inode() is failed, the bad inode will invalidate 0'th node page during f2fs_evict_inode(), which doesn't need to do.

Hmm...should not allow other using of inode->i_ino in following codes of f2fs_evict_inode, right?

Thanks,

Quoted 23 lines
---
 fs/f2fs/inode.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +4 -1
index 24bb8213d974..ef8610bf950f 100644
@@ -411,7 +411,10 @@ void f2fs_evict_inode(struct inode *inode)
 	stat_dec_inline_dir(inode);
 	stat_dec_inline_inode(inode);
 
-	invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, inode->i_ino);
+	/* ino == 0, if f2fs_new_inode() was failed t*/
+	if (inode->i_ino)
+		invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino,
+							inode->i_ino);
 	if (xnid)
 		invalidate_mapping_pages(NODE_MAPPING(sbi), xnid, xnid);
 	if (inode->i_nlink) {
author maintainer
#6 lore raw
Quoted 6 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

If f2fs_new_inode() is failed, the bad inode will invalidate 0'th node page during f2fs_evict_inode(), which doesn't need to do.

Hmm...should not allow other using of inode->i_ino in following codes of f2fs_evict_inode, right?

Right.

Quoted 26 lines

Thanks,

Quoted 23 lines
---
 fs/f2fs/inode.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +4 -1
index 24bb8213d974..ef8610bf950f 100644
@@ -411,7 +411,10 @@ void f2fs_evict_inode(struct inode *inode)
 	stat_dec_inline_dir(inode);
 	stat_dec_inline_inode(inode);
 
-	invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, inode->i_ino);
+	/* ino == 0, if f2fs_new_inode() was failed t*/
+	if (inode->i_ino)
+		invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino,
+							inode->i_ino);
 	if (xnid)
 		invalidate_mapping_pages(NODE_MAPPING(sbi), xnid, xnid);
 	if (inode->i_nlink) {
Reviewed-by
#7 lore raw
Quoted 9 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

If f2fs_new_inode() is failed, the bad inode will invalidate 0'th node page during f2fs_evict_inode(), which doesn't need to do.

Hmm...should not allow other using of inode->i_ino in following codes of f2fs_evict_inode, right?

Right.

I mean those codes below invalidate_mapping_pages(NODE_MAPPING(sbi),,) After having a look at them, I think it's OK without any change. :)

Thanks,

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford