From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F84C63797 for ; Thu, 22 Jul 2021 17:44:42 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A45D261289; Thu, 22 Jul 2021 17:44:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A45D261289 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.92.3) (envelope-from ) id 1m6ckU-0001LV-95; Thu, 22 Jul 2021 17:44:42 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1m6ckT-0001LO-Ad for linux-f2fs-devel@lists.sourceforge.net; Thu, 22 Jul 2021 17:44:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=KSOzutUeRqPDwj7532S0t+cTZriEo1IZe7gia5sDwBo=; b=iZVtwczATJMPrUvmRJJgkmlG8O jkYmpoBzF6AEfcer35YhbdfNXiYj/h4Q+9/lmdZcHuhk57mtyZ9uToqDHsgR97tYQ9p4qXuM/zbhf wEmTa6UsOba5tWYDnPMz9JLU8qg9Mo1vboI2ELoox+rC8jyQLcH8S32OH/SZerVfLxbQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KSOzutUeRqPDwj7532S0t+cTZriEo1IZe7gia5sDwBo=; b=IKJYCWzZxXAM0fNnZYQu6zSaYv RRqKcwGDe6WJvaurrtpTG7IGoeDorgxsmMvLyYiSvA8XxYDbHqCzrmlOVlNirrcGbR9HRtr7TYrPS V7eEtPBbdkHIdEfhgnhkvPUpKZIBthqa0ZVm3DtCIO+RzFYlrQCe3o29GI9/xgNEHlcs=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1m6ckN-0004QJ-5V for linux-f2fs-devel@lists.sourceforge.net; Thu, 22 Jul 2021 17:44:41 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id AEB5061001; Thu, 22 Jul 2021 17:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626975869; bh=+1VtaWnpu+/vg0Zu7lXitOvQJPQ5sE29/Tcbn/mDaJw=; h=Date:From:To:Subject:References:In-Reply-To:From; b=u9loRPsvhcfjzmctIAYBGzicMdiPmZqpfANrWNV1BIb+tJZ1mV4+NfLphNTnNOjFw 0fYVzaBKoTyQQdm1nepJPpgg1xgGlAEim3ygYRtMdpm4LC47XBlBlKHkpWkurwviqD iWfDT6PVBKnQz5kIaf5V0fuLFxoV9JQl15oyGAMA0VtnzCoBsjsZWVFqoS/dYDERT7 cE0XlVtO7R9hpOf7hNdIddYQsD9t1tsA/djWeL7ANoy0SEnSlbyvBpWhuB/AwiRPjW Zfe5RBXrWFHJ0ngUsedMe0z6+sQS7Q5shV+pn1bs2Vwc+s0N37xXeNfg68L3eb6imB eTNrgs0SpkPUw== Date: Thu, 22 Jul 2021 10:44:28 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Message-ID: References: <20210722014149.525166-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210722014149.525166-1-jaegeuk@kernel.org> X-Headers-End: 1m6ckN-0004QJ-5V Subject: Re: [f2fs-dev] [PATCH v2] f2fs: don't sleep while grabing nat_tree_lock X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This tries to fix priority inversion in the below condition resulting in long checkpoint delay. f2fs_get_node_info() - nat_tree_lock -> sleep to grab journal_rwsem by contention checkpoint - waiting for nat_tree_lock In order to let checkpoint go, let's release nat_tree_lock, if there's a journal_rwsem contention. Signed-off-by: Jaegeuk Kim --- Change log from v1: - drop rwlock but take retry logic to reduce lock-holding time fs/f2fs/node.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 0be9e2d7120e..c60ba4179bb2 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -552,7 +552,7 @@ int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid, int i; ni->nid = nid; - +retry: /* Check nat cache */ down_read(&nm_i->nat_tree_lock); e = __lookup_nat_cache(nm_i, nid); @@ -564,10 +564,16 @@ int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid, return 0; } - memset(&ne, 0, sizeof(struct f2fs_nat_entry)); + /* + * Check current segment summary by trying to grab journal_rwsem first. + * This sem is on the critical path on the checkpoint requiring the above + * nat_tree_lock. Therefore, we should retry, if we failed to grab here. + */ + if (!down_read_trylock(&curseg->journal_rwsem)) { + up_read(&nm_i->nat_tree_lock); + goto retry; + } - /* Check current segment summary */ - down_read(&curseg->journal_rwsem); i = f2fs_lookup_journal_in_cursum(journal, NAT_JOURNAL, nid, 0); if (i >= 0) { ne = nat_in_journal(journal, i); -- 2.32.0.432.gabb21c7263-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel