Skip to content

Commit

Permalink
f2fs: retry to update the inode page given data corruption
Browse files Browse the repository at this point in the history
commit 3aa51c6 upstream.

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.

Cc: [email protected]
Suggested-by: Randall Huang <[email protected]>
Suggested-by: Chao Yu <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jaegeuk Kim authored and gregkh committed Mar 10, 2023
1 parent f07a8d6 commit 85e1289
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fs/f2fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,18 +708,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);
Expand Down

0 comments on commit 85e1289

Please sign in to comment.