Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1658527ybz; Thu, 23 Apr 2020 03:16:06 -0700 (PDT) X-Google-Smtp-Source: APiQypIQDhuYx09fcjZXTfw3D94Ek+KKgw9zA8BroxuGeqWvwJj7fehVNz9UbwE6ZhU+1jLzxhGW X-Received: by 2002:a17:906:138c:: with SMTP id f12mr2071163ejc.35.1587636966134; Thu, 23 Apr 2020 03:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587636966; cv=none; d=google.com; s=arc-20160816; b=1BQlSbUjTJro7MsBMVtQfe02hEXlhDHlCiLMvXgTeZkBX9z5T9X8fX7JPpCzCG4/cN 2Dap1x/+8gIH1CWg9K/5WjyzY14C8lBQMCxCLi4yS6QnJdaqzWlYzrcprTGK8ggNUmAj ZwtupEk/dg34b2c8Sc4qKpZygWsbrQ2hw+psWxlsg54G6q7yxmFkHapkDKqK4uWM0F07 BpItgA59zT2SOCHxpikMkUTqpflhVjT8bMzPsvR7Ui/PTO3zIFW3BMeRe3vShDKXmg8S SQURaWevTtc0HBiWyoooszoMGtvCvrdC9XeZ0YWMN+qNe/ny0JjWM+lRha8jG+Qjnjhq WRDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=XkTvNo/jbkM19vHDq0zRKvy3gJ3iYXjBL0TBCr698Hs=; b=Gh2Xgh46+l6Qc83P74YSFRyg0vSC+USKf3rvPiWOTWN5kFO8khYQEA0l7XdIkbfzJq 4RPojPBg3XATg8f1iQCmRf+UDQ1Gmb82Uvy1FFs+Lp7HrmO46qOBOCVfYMGmdymNiYqa BhbykC7gIaYowmzfORn/fxAoNdt80U3nJBYwEm8o+CtP0gmWthG4I5zfzXcQxOaaQE3P xWLj7DyywGrRSEyy6wlgJatx3j9CgkwSMAT+whMNIzCsS926F3FlW1tVBFjuMVZCw9jx YxCrSBX+kCr96Q9NL+DugsSnzGZXHnlym99HSYuAtvftJ/oiIUyucbCg7BFd+kZTpNGs L5xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fEJwAmuN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si908243ejk.0.2020.04.23.03.15.42; Thu, 23 Apr 2020 03:16:06 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fEJwAmuN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbgDWKOP (ORCPT + 99 others); Thu, 23 Apr 2020 06:14:15 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:42107 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbgDWKOO (ORCPT ); Thu, 23 Apr 2020 06:14:14 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587636854; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=XkTvNo/jbkM19vHDq0zRKvy3gJ3iYXjBL0TBCr698Hs=; b=fEJwAmuNRdduEc4IqXUR3/T+1JcAwdyu3aqs96y+mfvNysuhzNl8Ab36Xf5KgDPnKRofU3yK vprnvyHbViZ8N762GSnglFDYaoI9AO0VAzfPwxeAWFRlGNkwVX7uVCr641j0FjNqTyH3Fo4B 7BV54Mvpx3lHue5qTO4DcR+2r9A= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5ea16a70.7f56514b1e30-smtp-out-n04; Thu, 23 Apr 2020 10:14:08 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 89CCCC433CB; Thu, 23 Apr 2020 10:14:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sayalil-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sayalil) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4318FC433D2; Thu, 23 Apr 2020 10:14:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4318FC433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sayalil@codeaurora.org From: Sayali Lokhande To: jaegeuk@kernel.org, yuchao0@huawei.com, linux-f2fs-devel@lists.sourceforge.net Cc: stummala@codeaurora.org, linux-kernel@vger.kernel.org, Sayali Lokhande Subject: [PATCH] f2fs: Avoid double lock for cp_rwsem Date: Thu, 23 Apr 2020 15:43:52 +0530 Message-Id: <1587636832-17939-1-git-send-email-sayalil@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call stack : f2fs_write_checkpoint() -> block_operations(sbi) f2fs_lock_all(sbi); down_write(&sbi->cp_rwsem); => write lock held <> -> f2fs_sync_node_pages() if (is_inline_node(page)) flush_inline_data() page = f2fs_pagecache_get_page() if (!page) goto iput_out; iput_out: 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); + 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; } /* -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project