Skip to content

Commit 50c6300

Browse files
author
Jaegeuk Kim
committed
f2fs: avoid an infinite loop in f2fs_sync_dirty_inodes
If one read IO is always failing, we can fall into an infinite loop in f2fs_sync_dirty_inodes. This happens during xfstests/generic/475. [ 142.803335] Buffer I/O error on dev dm-1, logical block 8388592, async page read ... [ 382.887210] submit_bio_noacct+0xdd/0x2a0 [ 382.887213] submit_bio+0x80/0x110 [ 382.887223] __submit_bio+0x4d/0x300 [f2fs] [ 382.887282] f2fs_submit_page_bio+0x125/0x200 [f2fs] [ 382.887299] __get_meta_page+0xc9/0x280 [f2fs] [ 382.887315] f2fs_get_meta_page+0x13/0x20 [f2fs] [ 382.887331] f2fs_get_node_info+0x317/0x3c0 [f2fs] [ 382.887350] f2fs_do_write_data_page+0x327/0x6f0 [f2fs] [ 382.887367] f2fs_write_single_data_page+0x5b7/0x960 [f2fs] [ 382.887386] f2fs_write_cache_pages+0x302/0x890 [f2fs] [ 382.887405] ? preempt_count_add+0x7a/0xc0 [ 382.887408] f2fs_write_data_pages+0xfd/0x320 [f2fs] [ 382.887425] ? _raw_spin_unlock+0x1a/0x30 [ 382.887428] do_writepages+0xd3/0x1d0 [ 382.887432] filemap_fdatawrite_wbc+0x69/0x90 [ 382.887434] filemap_fdatawrite+0x50/0x70 [ 382.887437] f2fs_sync_dirty_inodes+0xa4/0x270 [f2fs] [ 382.887453] f2fs_write_checkpoint+0x189/0x1640 [f2fs] [ 382.887469] ? schedule_timeout+0x114/0x150 [ 382.887471] ? ttwu_do_activate+0x6d/0xb0 [ 382.887473] ? preempt_count_add+0x7a/0xc0 [ 382.887476] kill_f2fs_super+0xca/0x100 [f2fs] [ 382.887491] deactivate_locked_super+0x35/0xa0 [ 382.887494] deactivate_super+0x40/0x50 [ 382.887497] cleanup_mnt+0x139/0x190 [ 382.887499] __cleanup_mnt+0x12/0x20 [ 382.887501] task_work_run+0x64/0xa0 [ 382.887505] exit_to_user_mode_prepare+0x1b7/0x1c0 [ 382.887508] syscall_exit_to_user_mode+0x27/0x50 [ 382.887510] do_syscall_64+0x48/0xc0 [ 382.887513] entry_SYSCALL_64_after_hwframe+0x44/0xae Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent f41ee8b commit 50c6300

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

fs/f2fs/checkpoint.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
9898
}
9999

100100
if (unlikely(!PageUptodate(page))) {
101+
if (page->index == sbi->metapage_eio_ofs &&
102+
sbi->metapage_eio_cnt++ == MAX_RETRY_META_PAGE_EIO) {
103+
set_ckpt_flags(sbi, CP_ERROR_FLAG);
104+
} else {
105+
sbi->metapage_eio_ofs = page->index;
106+
sbi->metapage_eio_cnt = 0;
107+
}
101108
f2fs_put_page(page, 1);
102109
return ERR_PTR(-EIO);
103110
}

fs/f2fs/f2fs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ enum {
577577
/* maximum retry quota flush count */
578578
#define DEFAULT_RETRY_QUOTA_FLUSH_COUNT 8
579579

580+
/* maximum retry of EIO'ed meta page */
581+
#define MAX_RETRY_META_PAGE_EIO 100
582+
580583
#define F2FS_LINK_MAX 0xffffffff /* maximum link count per file */
581584

582585
#define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
@@ -1614,6 +1617,8 @@ struct f2fs_sb_info {
16141617
/* keep migration IO order for LFS mode */
16151618
struct f2fs_rwsem io_order_lock;
16161619
mempool_t *write_io_dummy; /* Dummy pages */
1620+
pgoff_t metapage_eio_ofs; /* EIO page offset */
1621+
int metapage_eio_cnt; /* EIO count */
16171622

16181623
/* for checkpoint */
16191624
struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */

0 commit comments

Comments
 (0)