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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 233E4C6FA8B for ; Tue, 20 Sep 2022 00:51:16 +0000 (UTC) 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.95) (envelope-from ) id 1oaRTm-0008Lg-2x; Tue, 20 Sep 2022 00:51:14 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oaRTl-0008La-AE for linux-f2fs-devel@lists.sourceforge.net; Tue, 20 Sep 2022 00:51:13 +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:Cc:To:From:Date:Sender:Reply-To: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=ToPfnxF2NxQ2HGUaHBvaCuziGYRm0Sf9SFgkXvvGB3Q=; b=OVxmveaGwqLGFmVgDPJ5pFLdv7 U9DJeKrdy0poJOyW369N1iWqquVKjcQYFBU2vqsp+8d0HrgjjbvOS5gXpT3puncPQqdHgsOWAHJNS rYahZzFLAm7tY/3vPX/sh81tO/oD9M+0XfT4wVCdZ8dNyiE+rhCLb1WYn+aqje1qt3h0=; 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:Cc:To :From:Date:Sender:Reply-To: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=ToPfnxF2NxQ2HGUaHBvaCuziGYRm0Sf9SFgkXvvGB3Q=; b=SZL4mGnMQ77wO8p2nuZIoy+27X 9IjLctTKrQISGK6+7YHpOIO6FWibEwGEhxgFNxMCUMDTKJaapJt5ilj9jRYIakF+T0BV9fvfqxxva 9NKH288XcDIEJ16jYbJmynD6uQcyaI3krhOjaLJ/KQL+MpE3f4w5MklG6+hvzr+uuqek=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1oaRTg-0002Ya-No for linux-f2fs-devel@lists.sourceforge.net; Tue, 20 Sep 2022 00:51:13 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5917561949; Tue, 20 Sep 2022 00:50:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94D37C433D6; Tue, 20 Sep 2022 00:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663635054; bh=yOberSEUqwdenP4n+exju7j3AQ6fgojCHFFpQfJqfKk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Je46AiyUGmzY04wq9Golwz6HFn+OrAQtxFRzSKNyTFGArWtb7ykqgHE7oIGhNFS2G 4Unv8apLY8M+VxzCmLlw8sT0TVljgLcZ5NQG6JuzUGeOwh8cgazsinaxP7jiFKnNOP ACh2b6ffK2p1tVTVqn8zhyKkPIHIS78EyaQxVkQdV3eDZ0u3RZBH4yCKHoknUg7z1x sh679JxGCwq+blNutBoUwu8svYvi68eZbhhqVuL3fBlmDALkUCHQSu/2G/ipxUKLPD 0vcW3bYsUrhKrwpOaRrGnDUGfnm23p+P3sgLbwIxMylQCs9e9TVRQdaDoOZ2wC23J3 qWmwYh5sUdc8w== Date: Mon, 19 Sep 2022 17:50:52 -0700 From: Jaegeuk Kim To: Wu Bo Message-ID: References: <20220914040423.539-1-bo.wu@vivo.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220914040423.539-1-bo.wu@vivo.com> X-Headers-End: 1oaRTg-0002Ya-No Subject: Re: [f2fs-dev] [PATCH 1/1] f2fs: fix to check space of current segment journal 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: , Cc: Philippe De Muyter , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 09/14, Wu Bo wrote: > As Philippe De Muyter reported: > https://lore.kernel.org/linux-f2fs-devel/20220913224908.GA25100@172.21.0.10/T/#u > > The warning log showed that when finding a new space for nat the journal > space turned out to be full. This because the journal_rwsem is not > locked before the journal space checking. The journal space may become > full just after we check it. > > Reported-by: Philippe De Muyter > Signed-off-by: Wu Bo > --- > fs/f2fs/node.c | 6 +++--- > fs/f2fs/segment.c | 10 +++++----- > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index e06a0c478b39..971d8b9ccdf1 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -2995,13 +2995,13 @@ static int __flush_nat_entry_set(struct f2fs_sb_info *sbi, > * #1, flush nat entries to journal in current hot data summary block. > * #2, flush nat entries to nat page. > */ > + down_write(&curseg->journal_rwsem); > if ((cpc->reason & CP_UMOUNT) || > !__has_cursum_space(journal, set->entry_cnt, NAT_JOURNAL)) I think this is for NAT which was covered by nat_tree_lock. So, we don't need this under journal_rwsem. > to_journal = false; > > - if (to_journal) { > - down_write(&curseg->journal_rwsem); > - } else { > + if (!to_journal) { > + up_write(&curseg->journal_rwsem); > page = get_next_nat_page(sbi, start_nid); > if (IS_ERR(page)) > return PTR_ERR(page); > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 0de21f82d7bc..d545032d2f6f 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -3914,13 +3914,13 @@ int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type, > if (le32_to_cpu(nid_in_journal(journal, i)) == val) > return i; > } > - if (alloc && __has_cursum_space(journal, 1, NAT_JOURNAL)) > + if (alloc) > return update_nats_in_cursum(journal, 1); > } else if (type == SIT_JOURNAL) { > for (i = 0; i < sits_in_cursum(journal); i++) > if (le32_to_cpu(segno_in_journal(journal, i)) == val) > return i; > - if (alloc && __has_cursum_space(journal, 1, SIT_JOURNAL)) > + if (alloc) > return update_sits_in_cursum(journal, 1); > } > return -1; > @@ -4085,13 +4085,13 @@ void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) > (unsigned long)MAIN_SEGS(sbi)); > unsigned int segno = start_segno; > > + down_write(&curseg->journal_rwsem); > if (to_journal && > !__has_cursum_space(journal, ses->entry_cnt, SIT_JOURNAL)) > to_journal = false; > > - if (to_journal) { > - down_write(&curseg->journal_rwsem); > - } else { > + if (!to_journal) { > + up_write(&curseg->journal_rwsem); > page = get_next_sit_page(sbi, start_segno); > raw_sit = page_address(page); > } > -- > 2.36.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel