Skip to content

Commit 203681f

Browse files
author
Jaegeuk Kim
committed
f2fs: fix f2fs_write_meta_page at no checkpoint status
If f2fs entered errorneous checkpoint status, it should skip writing meta pages instead of redirtying the pages out. Otherwise, it cannot unmount the partition even though f2fs is under read-only status. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
1 parent bd859c6 commit 203681f

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

‎fs/f2fs/checkpoint.c‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,18 @@ static int f2fs_write_meta_page(struct page *page,
8181
struct inode *inode = page->mapping->host;
8282
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
8383

84-
/* Should not write any meta pages, if any IO error was occurred */
85-
if (unlikely(sbi->por_doing ||
86-
is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)))
84+
if (unlikely(sbi->por_doing))
8785
goto redirty_out;
88-
8986
if (wbc->for_reclaim)
9087
goto redirty_out;
9188

92-
wait_on_page_writeback(page);
89+
/* Should not write any meta pages, if any IO error was occurred */
90+
if (unlikely(is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)))
91+
goto no_write;
9392

93+
wait_on_page_writeback(page);
9494
write_meta_page(sbi, page);
95+
no_write:
9596
dec_page_count(sbi, F2FS_DIRTY_META);
9697
unlock_page(page);
9798
return 0;
@@ -148,10 +149,22 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
148149

149150
for (i = 0; i < nr_pages; i++) {
150151
struct page *page = pvec.pages[i];
152+
151153
lock_page(page);
152-
f2fs_bug_on(page->mapping != mapping);
153-
f2fs_bug_on(!PageDirty(page));
154-
clear_page_dirty_for_io(page);
154+
155+
if (unlikely(page->mapping != mapping)) {
156+
continue_unlock:
157+
unlock_page(page);
158+
continue;
159+
}
160+
if (!PageDirty(page)) {
161+
/* someone wrote it for us */
162+
goto continue_unlock;
163+
}
164+
165+
if (!clear_page_dirty_for_io(page))
166+
goto continue_unlock;
167+
155168
if (f2fs_write_meta_page(page, &wbc)) {
156169
unlock_page(page);
157170
break;

‎fs/f2fs/gc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi)
701701
gc_more:
702702
if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE)))
703703
goto stop;
704+
if (unlikely(is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)))
705+
goto stop;
704706

705707
if (gc_type == BG_GC && has_not_enough_free_secs(sbi, nfree)) {
706708
gc_type = FG_GC;

0 commit comments

Comments
 (0)