Skip to content

Commit c33ec32

Browse files
author
Jaegeuk Kim
committed
f2fs: avoid f2fs_balance_fs call during pageout
This patch should resolve the following bug. ========================================================= [ INFO: possible irq lock inversion dependency detected ] 3.13.0-rc5.f2fs+ rabeeh#6 Not tainted --------------------------------------------------------- kswapd0/41 just changed the state of lock: (&sbi->gc_mutex){+.+.-.}, at: [<ffffffffa030503e>] f2fs_balance_fs+0xae/0xd0 [f2fs] but this lock took another, RECLAIM_FS-READ-unsafe lock in the past: (&sbi->cp_rwsem){++++.?} and interrupts could create inverse lock ordering between them. other info that might help us debug this: Chain exists of: &sbi->gc_mutex --> &sbi->cp_mutex --> &sbi->cp_rwsem Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sbi->cp_rwsem); local_irq_disable(); lock(&sbi->gc_mutex); lock(&sbi->cp_mutex); <Interrupt> lock(&sbi->gc_mutex); *** DEADLOCK *** This bug is due to the f2fs_balance_fs call in f2fs_write_data_page. If f2fs_write_data_page is triggered by wbc->for_reclaim via kswapd, it should not call f2fs_balance_fs which tries to get a mutex grabbed by original syscall flow. Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 499046a commit c33ec32

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/f2fs/data.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,10 @@ static int f2fs_write_data_page(struct page *page,
842842
else if (err)
843843
goto redirty_out;
844844

845-
if (wbc->for_reclaim)
845+
if (wbc->for_reclaim) {
846846
f2fs_submit_merged_bio(sbi, DATA, WRITE);
847+
need_balance_fs = false;
848+
}
847849

848850
clear_cold_data(page);
849851
out:

0 commit comments

Comments
 (0)