Skip to contentSkip to conversation

f2fs: retry to update the inode page given EIO

PATCH In review Jaegeuk Kim 2 participants 11 messages Jan 5, 2023 – Jan 31, 2023

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: retry to update the inode page given EIO

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

---
 fs/f2fs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/inode.c +2 -2
index 01b9e6f85f6b..66e407fcefd3 100644
@@ -719,10 +719,10 @@ void f2fs_update_inode_page(struct inode *inode)
 	if (IS_ERR(node_page)) {
 		int err = PTR_ERR(node_page);
 
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || err == -EIO) {
 			cond_resched();
 			goto retry;
-		} else if (err != -ENOENT) {
+		} else if (err != -ENOENT || f2fs_cp_error(sbi)) {
 			f2fs_stop_checkpoint(sbi, false,
 					STOP_CP_REASON_UPDATE_INODE);
 		}
Signature · 8 lines
2.39.0.314.g84b9a713c41-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
author maintainer
#1 lore raw

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

---

Change log from v1:
- fix a bug

 fs/f2fs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/inode.c +1 -1
index ff6cf66ed46b..2ed7a621fdf1 100644
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
 	if (IS_ERR(node_page)) {
 		int err = PTR_ERR(node_page);
 
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
 			cond_resched();
 			goto retry;
 		} else if (err != -ENOENT) {
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
maintainer
#2 lore raw
Quoted 3 lines · Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

f2fs_handle_page_eio() only covers the case that EIO occurs on the same page, should we cover the case EIO occurs on different pages?

Thanks,

Quoted 25 lines

---

Change log from v1:
- fix a bug

  fs/f2fs/inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/inode.c +1 -1
index ff6cf66ed46b..2ed7a621fdf1 100644
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
  	if (IS_ERR(node_page)) {
  		int err = PTR_ERR(node_page);
 
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
  			cond_resched();
  			goto retry;
  		} else if (err != -ENOENT) {
author maintainer
#3 lore raw
Quoted 7 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

f2fs_handle_page_eio() only covers the case that EIO occurs on the same page, should we cover the case EIO occurs on different pages?

Which case are you looking at?

Quoted 15 lines

Thanks,

Quoted 12 lines

---

Change log from v1:
- fix a bug

  fs/f2fs/inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/f2fs/inode.c void f2fs_update_inode_page(struct inode *inode) · line 724

Quoted 12 lines
fs/f2fs/inode.c +1 -1
index ff6cf66ed46b..2ed7a621fdf1 100644
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
  	if (IS_ERR(node_page)) {
  		int err = PTR_ERR(node_page);
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
  			cond_resched();
  			goto retry;
  		} else if (err != -ENOENT) {

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#4 lore raw
Quoted 10 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

f2fs_handle_page_eio() only covers the case that EIO occurs on the same page, should we cover the case EIO occurs on different pages?

Which case are you looking at?

- __get_node_page(PageA) - __get_node_page(PageB)
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageA->index
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageB->index

In such race case, it may has low probability to set CP_ERROR_FLAG as we expect?

Thanks,

Quoted 16 lines
Quoted 16 lines

Thanks,

Quoted 12 lines

---

Change log from v1:
- fix a bug

   fs/f2fs/inode.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
fs/f2fs/inode.c +0 -0
index ff6cf66ed46b..2ed7a621fdf1 100644
Quoted 8 lines

fs/f2fs/inode.c void f2fs_update_inode_page(struct inode *inode) · line 724

Quoted 8 lines
fs/f2fs/inode.c +1 -1
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
   	if (IS_ERR(node_page)) {
   		int err = PTR_ERR(node_page);
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
   			cond_resched();
   			goto retry;
   		} else if (err != -ENOENT) {

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#5 lore raw
Quoted 12 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

f2fs_handle_page_eio() only covers the case that EIO occurs on the same page, should we cover the case EIO occurs on different pages?

Which case are you looking at?

Quoted 7 lines

- __get_node_page(PageA) - __get_node_page(PageB)
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageA->index
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageB->index

In such race case, it may has low probability to set CP_ERROR_FLAG as we expect?

Do you see that case in products?
I'm trying to avoid setting CP_ERROR_FLAG here.

Quoted 19 lines

Thanks,

Quoted 16 lines
Quoted 16 lines

Thanks,

Quoted 12 lines

---

Change log from v1:
- fix a bug

   fs/f2fs/inode.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
fs/f2fs/inode.c +0 -0
index ff6cf66ed46b..2ed7a621fdf1 100644
Quoted 8 lines
Quoted 8 lines

fs/f2fs/inode.c void f2fs_update_inode_page(struct inode *inode) · line 724

Quoted 8 lines
fs/f2fs/inode.c +1 -1
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
   	if (IS_ERR(node_page)) {
   		int err = PTR_ERR(node_page);
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
   			cond_resched();
   			goto retry;
   		} else if (err != -ENOENT) {

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#6 lore raw
Quoted 19 lines · Jaegeuk Kim
Quoted 18 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

f2fs_handle_page_eio() only covers the case that EIO occurs on the same page, should we cover the case EIO occurs on different pages?

Which case are you looking at?

- __get_node_page(PageA) - __get_node_page(PageB)
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageA->index
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageB->index

Quoted 3 lines
Quoted 1 line

In such race case, it may has low probability to set CP_ERROR_FLAG as we expect?

Do you see that case in products?

Not yet.

Quoted 1 line

I'm trying to avoid setting CP_ERROR_FLAG here.

Copied, how about using the same logic for node page as meta page, like we did in f2fs_get_meta_page_retry()?

Thanks,

Quoted 32 lines
Quoted 32 lines

Thanks,

Quoted 28 lines
Quoted 28 lines

Thanks,

Quoted 24 lines

---

Change log from v1:
- fix a bug

fs/f2fs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

fs/f2fs/inode.c +1 -1
index ff6cf66ed46b..2ed7a621fdf1 100644
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
    	if (IS_ERR(node_page)) {
    		int err = PTR_ERR(node_page);
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
    			cond_resched();
    			goto retry;
    		} else if (err != -ENOENT) {
author maintainer
#7 lore raw
Quoted 22 lines · Chao Yu
Quoted 21 lines · Jaegeuk Kim
Quoted 19 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

f2fs_handle_page_eio() only covers the case that EIO occurs on the same page, should we cover the case EIO occurs on different pages?

Which case are you looking at?

- __get_node_page(PageA) - __get_node_page(PageB)
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageA->index
- f2fs_handle_page_eio
- sbi->page_eio_ofs[type] = PageB->index

In such race case, it may has low probability to set CP_ERROR_FLAG as we expect?

Quoted 8 lines
Quoted 1 line

Do you see that case in products?

Not yet.

Quoted 1 line

I'm trying to avoid setting CP_ERROR_FLAG here.

Copied, how about using the same logic for node page as meta page, like we did in f2fs_get_meta_page_retry()?

Yeah.. let me send v3 and test a bit. Thanks~ :)

Quoted 35 lines

Thanks,

Quoted 32 lines
Quoted 32 lines

Thanks,

Quoted 28 lines
Quoted 28 lines

Thanks,

Quoted 24 lines

---

Change log from v1:
- fix a bug

fs/f2fs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

fs/f2fs/inode.c +1 -1
index ff6cf66ed46b..2ed7a621fdf1 100644
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
    	if (IS_ERR(node_page)) {
    		int err = PTR_ERR(node_page);
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
    			cond_resched();
    			goto retry;
    		} else if (err != -ENOENT) {
author maintainer
#8 lore raw
In reply to Jaegeuk Kim

In f2fs_update_inode_page, f2fs_get_node_page handles EIO along with f2fs_handle_page_eio that stops checkpoint, if the disk couldn't be recovered. As a result, we don't need to stop checkpoint right away given single EIO.

---

Change log from v2:
- set EIO to cover the case of data corruption given by buggy UFS driver

 fs/f2fs/inode.c | 2 +-
 fs/f2fs/node.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/inode.c +1 -1
index ff6cf66ed46b..2ed7a621fdf1 100644
@@ -719,7 +719,7 @@ void f2fs_update_inode_page(struct inode *inode)
 	if (IS_ERR(node_page)) {
 		int err = PTR_ERR(node_page);
 
-		if (err == -ENOMEM) {
+		if (err == -ENOMEM || (err == -EIO && !f2fs_cp_error(sbi))) {
 			cond_resched();
 			goto retry;
 		} else if (err != -ENOENT) {
fs/f2fs/node.c +1 -1
index 558b318f7316..1629dc300c61 100644
@@ -1455,7 +1455,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 			  ofs_of_node(page), cpver_of_node(page),
 			  next_blkaddr_of_node(page));
 	set_sbi_flag(sbi, SBI_NEED_FSCK);
-	err = -EINVAL;
+	err = -EIO;
 out_err:
 	ClearPageUptodate(page);
 out_put_err:
Signature · 8 lines
2.39.0.314.g84b9a713c41-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
author maintainer
#9 lore raw
In reply to Jaegeuk Kim

If the storage gives a corrupted node block due to short power failure and reset, f2fs stops the entire operations by setting the checkpoint failure flag.

Let's give more chances to live by re-issuing IOs for a while in such critical path.

---

Change log from v2:
- adopting the retry logic

 fs/f2fs/inode.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
fs/f2fs/inode.c +7 -6
index e1d6e021e82b..7bf660d4cad9 100644
@@ -724,18 +724,19 @@ void f2fs_update_inode_page(struct inode *inode)
 {
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	struct page *node_page;
+	int count = 0;
 retry:
 	node_page = f2fs_get_node_page(sbi, inode->i_ino);
 	if (IS_ERR(node_page)) {
 		int err = PTR_ERR(node_page);
 
-		if (err == -ENOMEM) {
-			cond_resched();
+		/* The node block was truncated. */
+		if (err == -ENOENT)
+			return;
+
+		if (err == -ENOMEM || ++count <= DEFAULT_RETRY_IO_COUNT)
 			goto retry;
-		} else if (err != -ENOENT) {
-			f2fs_stop_checkpoint(sbi, false,
-					STOP_CP_REASON_UPDATE_INODE);
-		}
+		f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_UPDATE_INODE);
 		return;
 	}
 	f2fs_update_inode(inode, node_page);
Signature · 1 line
2.39.1.456.gfc5497dd1b-goog
maintainer Reviewed-by
#10 lore raw
Quoted 10 lines · Jaegeuk Kim

If the storage gives a corrupted node block due to short power failure and reset, f2fs stops the entire operations by setting the checkpoint failure flag.

Let's give more chances to live by re-issuing IOs for a while in such critical path.

Thanks,