Skip to contentSkip to conversation

f2fs: fix a infinite loop in writting checkpoint

PATCH In review Yunlei He 2 participants 4 messages Aug 26, 2017 – Sep 4, 2017 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: fix a infinite loop in writting checkpoint

The loop reason is DIRTY IMETA always equal to 1:

Thread A:
-write_checkpoint
-block_operations
-f2fs_sync_inode_meta
-igrab <--- here igrab return NULL

Thread B:
-f2fs_evict_inode
-remove_inode_page
-truncate_xattr_node
-__get_node_page
-read_node_page <---- here return -ENOENT

This patch walk around this cause.

---
 fs/f2fs/node.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/node.c +2 -1
index 2654c91..ec7a0e0 100644
@@ -973,8 +973,9 @@ int truncate_xattr_node(struct inode *inode, struct page *page)
 		return 0;
 
 	npage = get_node_page(sbi, nid);
-	if (IS_ERR(npage))
+	if (IS_ERR(npage) && PTR_ERR(npage) != -ENOENT) {
 		return PTR_ERR(npage);
+	}
 
 	f2fs_i_xnid_write(inode, 0);
 
Signature · 6 lines
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#1 lore raw

Hi Yunlei,

Quoted 8 lines · Yunlei He

The loop reason is DIRTY IMETA always equal to 1:

Thread A:
-write_checkpoint
-block_operations
-f2fs_sync_inode_meta
-igrab <--- here igrab return NULL

Quoted 8 lines

Thread B:
-f2fs_evict_inode
-remove_inode_page
-truncate_xattr_node
-__get_node_page
-read_node_page <---- here return -ENOENT

This patch walk around this cause.

It needs to figure out root cause that why xattr node entry is invalid.

Thanks,

Quoted 12 lines
---
 fs/f2fs/node.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/node.c +0 -0
index 2654c91..ec7a0e0 100644

fs/f2fs/node.c int truncate_xattr_node(struct inode *inode, struct page *page) · line 981

Quoted 10 lines
fs/f2fs/node.c +2 -1
@@ -973,8 +973,9 @@ int truncate_xattr_node(struct inode *inode, struct page *page)
 		return 0;
 
 	npage = get_node_page(sbi, nid);
-	if (IS_ERR(npage))
+	if (IS_ERR(npage) && PTR_ERR(npage) != -ENOENT) {
 		return PTR_ERR(npage);
+	}
 
 	f2fs_i_xnid_write(inode, 0);
 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

author
#2 lore raw

Hi Yunlei,

Quoted 8 lines · Yunlei He

The loop reason is DIRTY IMETA always equal to 1:

Thread A:
-write_checkpoint
-block_operations
-f2fs_sync_inode_meta
-igrab <--- here igrab return NULL

Quoted 8 lines

Thread B:
-f2fs_evict_inode
-remove_inode_page
-truncate_xattr_node
-__get_node_page
-read_node_page <---- here return -ENOENT

This patch walk around this cause.

It needs to figure out root cause that why xattr node entry is invalid.

How about this modification:

fs/f2fs/inode.c +1 -1
index b4c401d..62de5f7 100644
@@ -497,7 +497,7 @@ void f2fs_evict_inode(struct inode *inode)
                f2fs_lock_op(sbi);
                err = remove_inode_page(inode);
                f2fs_unlock_op(sbi);
-               if (err == -ENOENT)
+               if (err == -ENOENT && is_bad_inode(inode))
                        err = 0;
        }
 

Thanks

Quoted 12 lines
---
 fs/f2fs/node.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/node.c index 2654c91..ec7a0e0 renamed from fs/f2fs/node.c +0 -0

100644

fs/f2fs/node.c int truncate_xattr_node(struct inode *inode, struct page *page) · line 981

Quoted 10 lines
fs/f2fs/node.c +2 -1
@@ -973,8 +973,9 @@ int truncate_xattr_node(struct inode *inode, struct page *page)
 		return 0;
 
 	npage = get_node_page(sbi, nid);
-	if (IS_ERR(npage))
+	if (IS_ERR(npage) && PTR_ERR(npage) != -ENOENT) {
 		return PTR_ERR(npage);
+	}
 
 	f2fs_i_xnid_write(inode, 0);
 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

#3 lore raw
Quoted 30 lines · heyunlei

Hi Yunlei,

Quoted 8 lines · Yunlei He

The loop reason is DIRTY IMETA always equal to 1:

Thread A:
-write_checkpoint
-block_operations
-f2fs_sync_inode_meta
-igrab <--- here igrab return NULL

Quoted 8 lines

Thread B:
-f2fs_evict_inode
-remove_inode_page
-truncate_xattr_node
-__get_node_page
-read_node_page <---- here return -ENOENT

This patch walk around this cause.

It needs to figure out root cause that why xattr node entry is invalid.

How about this modification:

fs/f2fs/inode.c +0 -0
index b4c401d..62de5f7 100644

fs/f2fs/inode.c void f2fs_evict_inode(struct inode *inode) · line 500

Quoted 5 lines
fs/f2fs/inode.c +1 -1
@@ -497,7 +497,7 @@ void f2fs_evict_inode(struct inode *inode)
                f2fs_lock_op(sbi);
                err = remove_inode_page(inode);
                f2fs_unlock_op(sbi);
-               if (err == -ENOENT)
+               if (err == -ENOENT && is_bad_inode(inode))

So we expect that before new inode page was allocated, it needs to set bad inode in time covering all error paths?

Thanks,

Quoted 24 lines
fs/f2fs/inode.c +0 -0
                        err = 0;
        }
 

Thanks

Quoted 19 lines
---
 fs/f2fs/node.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/node.c index 2654c91..ec7a0e0 renamed from fs/f2fs/node.c +0 -0

100644

fs/f2fs/node.c +2 -1
@@ -973,8 +973,9 @@ int truncate_xattr_node(struct inode *inode, struct page *page)
 		return 0;
 
 	npage = get_node_page(sbi, nid);
-	if (IS_ERR(npage))
+	if (IS_ERR(npage) && PTR_ERR(npage) != -ENOENT) {
 		return PTR_ERR(npage);
+	}
 
Quoted 4 lines

fs/f2fs/node.c int truncate_xattr_node(struct inode *inode, struct page *page) · line 981

Quoted 3 lines
fs/f2fs/node.c +0 -0
 	f2fs_i_xnid_write(inode, 0);
 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot