You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
f2fs: avoid to write during the recovery
This patch enhances the recovery routine not to write any data/node/meta until its completion. If any writes are sent to the disk, it could contaminate the written history that will be used for further recovery. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
@@ -81,7 +81,7 @@ static int f2fs_write_meta_page(struct page *page,
|
|||||||
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
|
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
|
||||||
|
|
||||||
/* Should not write any meta pages, if any IO error was occurred */
|
/* Should not write any meta pages, if any IO error was occurred */
|
||||||
if (wbc->for_reclaim ||
|
if (wbc->for_reclaim || sbi->por_doing ||
|
||||||
is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)) {
|
is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)) {
|
||||||
dec_page_count(sbi, F2FS_DIRTY_META);
|
dec_page_count(sbi, F2FS_DIRTY_META);
|
||||||
wbc->pages_skipped++;
|
wbc->pages_skipped++;
|
||||||
|
|||||||
+11
-6
@@ -1156,6 +1156,9 @@ static int f2fs_write_node_page(struct page *page,
|
|||||||
block_t new_addr;
|
block_t new_addr;
|
||||||
struct node_info ni;
|
struct node_info ni;
|
||||||
|
|
||||||
|
if (sbi->por_doing)
|
||||||
|
goto redirty_out;
|
||||||
|
|
||||||
wait_on_page_writeback(page);
|
wait_on_page_writeback(page);
|
||||||
|
|
||||||
/* get old block addr of this node page */
|
/* get old block addr of this node page */
|
||||||
@@ -1171,12 +1174,8 @@ static int f2fs_write_node_page(struct page *page,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wbc->for_reclaim) {
|
if (wbc->for_reclaim)
|
||||||
dec_page_count(sbi, F2FS_DIRTY_NODES);
|
goto redirty_out;
|
||||||
wbc->pages_skipped++;
|
|
||||||
set_page_dirty(page);
|
|
||||||
return AOP_WRITEPAGE_ACTIVATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&sbi->node_write);
|
mutex_lock(&sbi->node_write);
|
||||||
set_page_writeback(page);
|
set_page_writeback(page);
|
||||||
@@ -1186,6 +1185,12 @@ static int f2fs_write_node_page(struct page *page,
|
|||||||
mutex_unlock(&sbi->node_write);
|
mutex_unlock(&sbi->node_write);
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
redirty_out:
|
||||||
|
dec_page_count(sbi, F2FS_DIRTY_NODES);
|
||||||
|
wbc->pages_skipped++;
|
||||||
|
set_page_dirty(page);
|
||||||
|
return AOP_WRITEPAGE_ACTIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user