From patchwork Sun Nov 5 03:39:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 10041845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE741601EB for ; Sun, 5 Nov 2017 03:40:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7F0029072 for ; Sun, 5 Nov 2017 03:40:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC0B1290E7; Sun, 5 Nov 2017 03:40:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EFA929072 for ; Sun, 5 Nov 2017 03:40:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdKEDkI (ORCPT ); Sat, 4 Nov 2017 23:40:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:51948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751896AbdKEDkH (ORCPT ); Sat, 4 Nov 2017 23:40:07 -0400 Received: from [192.168.0.101] (unknown [49.77.216.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E55902190D; Sun, 5 Nov 2017 03:40:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E55902190D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=chao@kernel.org Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: stop all the operations by cp_error flag To: Chao Yu , Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20171023221409.59148-1-jaegeuk@kernel.org> <20171023221409.59148-2-jaegeuk@kernel.org> <200e3f93-c9bb-381e-9b00-1f50ab82631c@huawei.com> From: Chao Yu Message-ID: <1d3d0d9c-a20a-9d3a-0b7f-a34e2e62b8a5@kernel.org> Date: Sun, 5 Nov 2017 11:39:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <200e3f93-c9bb-381e-9b00-1f50ab82631c@huawei.com> Content-Language: en-US Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jaegeuk, On 2017/10/24 17:51, Chao Yu wrote: > On 2017/10/24 6:14, Jaegeuk Kim wrote: >> This patch replaces to use cp_error flag instead of RDONLY for quota off. We should convert error number with block_page_mkwrite_return in .page_mkwrite, otherwise generic/019 will cause a deadlock issue with below kernel message printed: ============================================ WARNING: possible recursive locking detected 4.14.0-rc1 #35 Tainted: G W O -------------------------------------------- fio/5845 is trying to acquire lock: (&mm->mmap_sem){++++}, at: [] __do_page_fault+0x482/0x510 but task is already holding lock: (&mm->mmap_sem){++++}, at: [] __do_page_fault+0x11e/0x510 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&mm->mmap_sem); lock(&mm->mmap_sem); *** DEADLOCK *** May be due to missing lock nesting notation 1 lock held by fio/5845: #0: (&mm->mmap_sem){++++}, at: [] __do_page_fault+0x11e/0x510 stack backtrace: CPU: 3 PID: 5845 Comm: fio Tainted: G W O 4.14.0-rc1 #35 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 Call Trace: dump_stack+0x5f/0x92 __lock_acquire+0x1019/0x12c0 lock_acquire+0xae/0x220 down_read+0x38/0x60 __do_page_fault+0x482/0x510 do_page_fault+0x26/0x290 common_exception+0x64/0x6a --- fs/f2fs/file.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index e67f03546391..0ce1e82591d1 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -53,8 +53,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf) struct dnode_of_data dn; int err; - if (unlikely(f2fs_cp_error(sbi))) - return -EIO; + if (unlikely(f2fs_cp_error(sbi))) { + err = -EIO; + goto out; + } sb_start_pagefault(inode->i_sb); @@ -66,7 +68,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf) err = f2fs_reserve_block(&dn, page->index); if (err) { f2fs_unlock_op(sbi); - goto out; + goto out_end; } f2fs_put_dnode(&dn); f2fs_unlock_op(sbi); @@ -114,9 +116,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf) out_sem: up_read(&F2FS_I(inode)->i_mmap_sem); -out: +out_end: sb_end_pagefault(inode->i_sb); f2fs_update_time(sbi, REQ_TIME); +out: return block_page_mkwrite_return(err); }