From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757059AbbCCSC4 (ORCPT ); Tue, 3 Mar 2015 13:02:56 -0500 Received: from mail.kernel.org ([198.145.29.136]:39223 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755221AbbCCSCy (ORCPT ); Tue, 3 Mar 2015 13:02:54 -0500 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 1/3] f2fs: avoid to trigger writepage during POR Date: Tue, 3 Mar 2015 10:02:47 -0800 Message-Id: <1425405769-92563-1-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.1.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch doesn't make any effect on previous behavior, since f2fs_write_data_page bypasses writing the page during POR. But, the difference is that this patch avoids holding writepages mutex. This is to avoid the following false warning, since this can happen only when mount and shutdown are triggered at the same time. ====================================================== [ INFO: possible circular locking dependency detected ] 4.0.0-rc1+ #3 Tainted: G O ------------------------------------------------------- kworker/u8:0/2270 is trying to acquire lock: (&sbi->gc_mutex){+.+.+.}, at: [] f2fs_balance_fs+0x73/0x90 [f2fs] but task is already holding lock: (&sbi->writepages){+.+...}, at: [] f2fs_write_data_pages+0xcb/0x3a0 [f2fs] which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&sbi->writepages){+.+...}: [] lock_acquire+0xe1/0x2f0 [] mutex_lock_nested+0x63/0x530 [] f2fs_write_data_pages+0xcb/0x3a0 [f2fs] [] do_writepages+0x21/0x50 [] __writeback_single_inode+0x76/0xbf0 [] writeback_single_inode+0xea/0x1c0 [] write_inode_now+0x95/0xa0 [] iput+0x20b/0x3f0 [] recover_data.constprop.14+0x26b/0xa80 [f2fs] [] recover_fsync_data+0x2b6/0x5e0 [f2fs] [] f2fs_fill_super+0xb24/0xb90 [f2fs] [] mount_bdev+0x1a4/0x1e0 [] f2fs_mount+0x15/0x20 [f2fs] [] mount_fs+0x39/0x180 [] vfs_kern_mount+0x6b/0x160 [] do_mount+0x204/0xbe0 [] SyS_mount+0x8b/0xe0 [] system_call_fastpath+0x16/0x1b -> #1 (&sbi->cp_mutex){+.+...}: [] lock_acquire+0xe1/0x2f0 [] mutex_lock_nested+0x63/0x530 [] write_checkpoint+0x42/0x1230 [f2fs] [] f2fs_sync_fs+0x9d/0x2a0 [f2fs] [] sync_filesystem+0x82/0xb0 [] generic_shutdown_super+0x34/0x100 [] kill_block_super+0x27/0x70 [] kill_f2fs_super+0x20/0x30 [f2fs] [] deactivate_locked_super+0x49/0x80 [] deactivate_super+0x4e/0x70 [] cleanup_mnt+0x43/0x90 [] __cleanup_mnt+0x12/0x20 [] task_work_run+0xc4/0xf0 [] do_notify_resume+0x8d/0xa0 [] int_signal+0x12/0x17 -> #0 (&sbi->gc_mutex){+.+.+.}: [] __lock_acquire+0x1ac6/0x1c90 [] lock_acquire+0xe1/0x2f0 [] mutex_lock_nested+0x63/0x530 [] f2fs_balance_fs+0x73/0x90 [f2fs] [] f2fs_write_data_page+0x348/0x5b0 [f2fs] [] __f2fs_writepage+0x1a/0x50 [f2fs] [] write_cache_pages+0x274/0x6f0 [] f2fs_write_data_pages+0xe0/0x3a0 [f2fs] [] do_writepages+0x21/0x50 [] __writeback_single_inode+0x76/0xbf0 [] writeback_sb_inodes+0x32a/0x710 [] __writeback_inodes_wb+0x9f/0xd0 [] wb_writeback+0x3db/0x850 [] bdi_writeback_workfn+0x148/0x980 [] process_one_work+0x1e2/0x840 [] worker_thread+0x121/0x460 [] kthread+0xf8/0x110 [] ret_from_fork+0x7c/0xb0 Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 389fda7..0057d4b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1408,6 +1408,10 @@ static int f2fs_write_data_pages(struct address_space *mapping, available_free_memory(sbi, DIRTY_DENTS)) goto skip_write; + /* during POR, we don't need to trigger writepage at all. */ + if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) + goto skip_write; + diff = nr_pages_to_write(sbi, DATA, wbc); if (!S_ISDIR(inode->i_mode)) { -- 2.1.1