Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1804099ybz; Thu, 23 Apr 2020 06:17:01 -0700 (PDT) X-Google-Smtp-Source: APiQypK6x3PPkUW5Cxk5dzCbe9aUV2RxrPNsrUC6HQZsfUfctOMYG6mtMqpC5JxvojLnTrk4H0Tp X-Received: by 2002:aa7:ca48:: with SMTP id j8mr2487515edt.328.1587647821460; Thu, 23 Apr 2020 06:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587647821; cv=none; d=google.com; s=arc-20160816; b=xDtPo9S5DaH+k35V55evTcy8l8ClwXwXWKmmwwfChEPLJZ4gja8eDaVctiJsB5oHFe kZzZFbjCwYZ3A7g+CHgXAJIPenSz+knxwS68q4Pe/1PfMQd5SGHCqjHImXq7uoJoEZbc D5IqNClqwvF/e1DwoIEPqNSqCpdzcUI15kt/y+/So43v4XHsqVPBl17/OQ4t7Lkp9rdC qC5NGjfAJ+bJj6Xk9GJHAdR6MaIgvkVKXdlYBkota1tJzWRk6wvQPLAnSE5sq7el9oE8 +S0rhTKignrksSvKm1LVTwr0jOF56p2sqtRirRRwMYaD/o9PzAbZJK/dg3NUvpn1tlP3 1DLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=wU3ViB8TR58UIUwMAieBlNJm3H88iCe9IPDt2eVIgVo=; b=K9HoOUmXpCiA/O3k7iwVY3MeoF5iQCo8S33qbLEtcWXzJEcD1O7gy8p4E5if90YuHv mJMw5GrHGYjL0ZMvDjfnwkTgEZzqXSZ9xY674A2/ndE45RhOy/K7UeSoIswG/lwWSr6Y iJjOF6dlfNjvQN0llqZdbu2235h/O6DfWHlm3GpJP9f8TsLIU3LI29QngwORXzqnKq3W Eig5tkbDfZh0jQjaLkQ4dCQZYU8Md8GN+byqx/CQ2SR+6AvMGlOGJ2kPZ7ZtLl2wiMAw 3Vr8fJwvw3pallkpRw4m9MYZTikWcW4Ntox4dfWek+JkkQFsZd+G8CSmUpVePutPkamg 4NQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="I3MyzsA/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si1179252ejj.44.2020.04.23.06.16.37; Thu, 23 Apr 2020 06:17:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="I3MyzsA/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726685AbgDWNNz (ORCPT + 99 others); Thu, 23 Apr 2020 09:13:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbgDWNNz (ORCPT ); Thu, 23 Apr 2020 09:13:55 -0400 Received: from [192.168.0.107] (unknown [58.213.200.224]) (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 B2ECA2076C; Thu, 23 Apr 2020 13:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587647634; bh=sCzr7jegZyFDnovWPo6SGkC+fWK3YOKcrQa3UVaVFq0=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=I3MyzsA/KeqgxHnqdOnj/WknM268wrDEcFc0gvdmJ4TpI1p9bFmeY8k8ze8uDR322 Ne+9PICAq5KVQH46faqKUWzN7nNvblevNA6P+GBx38tiUQXTLHjnZ9A9d65hqw0cTR BrKfDDmmejLFS3rsfGNmbs9SKy5bMIOHbqNIvobQ= Subject: Re: [f2fs-dev] [PATCH] f2fs: Avoid double lock for cp_rwsem To: Sayali Lokhande , jaegeuk@kernel.org, yuchao0@huawei.com, linux-f2fs-devel@lists.sourceforge.net References: <1587636832-17939-1-git-send-email-sayalil@codeaurora.org> Cc: linux-kernel@vger.kernel.org From: Chao Yu Message-ID: <4b1a9995-5c4c-c547-e42a-bc6047dfb7f6@kernel.org> Date: Thu, 23 Apr 2020 21:13:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1587636832-17939-1-git-send-email-sayalil@codeaurora.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sayali, On 2020-4-23 18:13, Sayali Lokhande wrote: > Call stack : > f2fs_write_checkpoint() > -> block_operations(sbi) > f2fs_lock_all(sbi); > down_write(&sbi->cp_rwsem); => write lock held > <> It looks the full race condition should be? Thread B - open() - igrab() - write() write inline data - unlink() > -> f2fs_sync_node_pages() > if (is_inline_node(page)) > flush_inline_data() ilookup() > page = f2fs_pagecache_get_page() > if (!page) > goto iput_out; > iput_out: - close() - iput() > iput(inode); > -> f2fs_evict_inode() > f2fs_truncate_blocks() > f2fs_lock_op() > down_read(&sbi->cp_rwsem); => read lock fail > > Signed-off-by: Sayali Lokhande > --- > fs/f2fs/checkpoint.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c > index 5ba649e..5c504cf 100644 > --- a/fs/f2fs/checkpoint.c > +++ b/fs/f2fs/checkpoint.c > @@ -1219,21 +1219,19 @@ static int block_operations(struct f2fs_sb_info *sbi) > goto retry_flush_quotas; > } > > -retry_flush_nodes: > down_write(&sbi->node_write); > > if (get_pages(sbi, F2FS_DIRTY_NODES)) { > up_write(&sbi->node_write); Call up_write(&sbi->node_change) here could wake up threads earlier who hang on this lock, how do you think? Thanks, > + f2fs_unlock_all(sbi); > atomic_inc(&sbi->wb_sync_req[NODE]); > err = f2fs_sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO); > atomic_dec(&sbi->wb_sync_req[NODE]); > - if (err) { > - up_write(&sbi->node_change); > - f2fs_unlock_all(sbi); > + up_write(&sbi->node_change); > + if (err) > goto out; > - } > cond_resched(); > - goto retry_flush_nodes; > + goto retry_flush_quotas; > } > > /* >