From patchwork Tue Jul 2 12:06:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunmin Jeong X-Patchwork-Id: 13719525 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 531A3C30658 for ; Tue, 2 Jul 2024 12:06:50 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sOcHX-0001Y5-Nf; Tue, 02 Jul 2024 12:06:48 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sOcHW-0001Xy-JT for linux-f2fs-devel@lists.sourceforge.net; Tue, 02 Jul 2024 12:06:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:Content-Type:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=n7bVkJMnRU7Mlc/hN2ckbv1SrBU+L0lB2TRSSvXzKuY=; b=fff9mpAtAssMvT9sXXzuxzIENt OYZqQhHscRr7MXIrwtqYmKOCtN/sScmJsIvhZvCxyHm6IihZwzjqchfFG7g4hwJ1ew06AkKdVVzug 4QwK6Jg9/PR6ZGd7a4+Z6uEV8iSsVzpP2YTZwkSBaUmKpcN08GWqHsf37xmiSdvuNItc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:Content-Type:Content-Transfer-Encoding:MIME-Version:Message-Id :Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=n7bVkJMnRU7Mlc/hN2ckbv1SrBU+L0lB2TRSSvXzKuY=; b=j jEQo4uTSf+nFD1EDOyAqU529Dese2TYLHa7ShWio7LF+G5GM3f0kTGH2A26+1Y37Ucak524G7Tkap kd/9uPBAI75i5QjWhI4rMAN5rLOBTbgauS/HHZaOIf1DMnunQftLKObxrHLc6AxM+NkoAJorJMHpf +HL5VNebHXQiJphY=; Received: from mailout2.samsung.com ([203.254.224.25]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sOcHW-0000Ew-Bq for linux-f2fs-devel@lists.sourceforge.net; Tue, 02 Jul 2024 12:06:46 +0000 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240702120633epoutp029ba965c2495d36e04436fd7012abcedc~eY-C5sDRZ1707717077epoutp02e for ; Tue, 2 Jul 2024 12:06:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240702120633epoutp029ba965c2495d36e04436fd7012abcedc~eY-C5sDRZ1707717077epoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719921993; bh=n7bVkJMnRU7Mlc/hN2ckbv1SrBU+L0lB2TRSSvXzKuY=; h=From:To:Cc:Subject:Date:References:From; b=Pr9+hmER4C58fODF0+aSvM+rQVomfU4mTyFAvGE4xIOYjVxPqtHbk4FN1F/r1LJBw JhOEFgPIDguZgSLOuRGzMxHpyuCkb4Oit6h2AO5KOutkzLb5HBolBkOAtKEQFL4vPd VH5NytzbFeomobMsvGh47/5d74EsgJcNB1TY39Ic= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20240702120632epcas1p45ade09d4511ab60b9807a75c8bf513fe~eY-ChQ66R0895308953epcas1p45; Tue, 2 Jul 2024 12:06:32 +0000 (GMT) Received: from epsmgec1p1.samsung.com (unknown [182.195.38.242]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4WD1pw3YdJz4x9Ps; Tue, 2 Jul 2024 12:06:32 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmgec1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 8F.75.08602.84DE3866; Tue, 2 Jul 2024 21:06:32 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240702120631epcas1p1c7044f77b56009471e2dc07d4e135a99~eY-BOnj2a1487914879epcas1p1z; Tue, 2 Jul 2024 12:06:31 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240702120631epsmtrp1bd088745aea8d562f54ddaccc39a5a25~eY-BNMEty0771107711epsmtrp1Q; Tue, 2 Jul 2024 12:06:31 +0000 (GMT) X-AuditID: b6c32a33-66ffa7000000219a-67-6683ed48cd33 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FB.B4.07412.74DE3866; Tue, 2 Jul 2024 21:06:31 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.34]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240702120631epsmtip1d563847d3def3ca480bec6950d252da6~eY-BA_LQQ0993309933epsmtip1s; Tue, 2 Jul 2024 12:06:31 +0000 (GMT) From: Sunmin Jeong To: jaegeuk@kernel.org, chao@kernel.org Date: Tue, 2 Jul 2024 21:06:24 +0900 Message-Id: <20240702120624.476067-1-s_min.jeong@samsung.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmga7H2+Y0g+6rohanp55lspjavpfR 4sn6WcwWlxa5Wyxo/c1iseXfEVaLBRsfMVrM2P+U3YHDY8GmUo9NqzrZPHYv+Mzk0bdlFaPH 501yAaxR2TYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5 QJcoKZQl5pQChQISi4uV9O1sivJLS1IVMvKLS2yVUgtScgrMCvSKE3OLS/PS9fJSS6wMDQyM TIEKE7IzFpx4xFJwU6biyeRvzA2MneJdjJwcEgImEte+NbB0MXJxCAnsYJTYumw7M4TziVFi 1etJUM43Roldc3czwbSsOX6TESKxl1Hi5pI+JriWg3cvMIJUsQnoSDycepsFxBYRUJc4NWkp 2BJmgauMEl1v54CNEhawl3h9fhkriM0ioCpxYnMbO4jNK2ArseDzXVaIdfISMy99h4oLSpyc +QRsKDNQvHnrbLD7JASusUt8a5zPDNHgInFu+W0oW1ji1fEt7BC2lMTL/jYou1ji6PwN7BDN DYwSN77ehErYSzS3NrN1MXIAbdCUWL9LH2IZn8S7rz2sIGEJAV6JjjYhiGpVie5HS6BWSUss O3YQaoqHxN+l88HuFBKIlTjXNJ91AqPcLCQvzELywiyEZQsYmVcxiqUWFOempyYbFhjC4zI5 P3cTIzgNahnvYLw8/5/eIUYmDsZDjBIczEoivIG/6tOEeFMSK6tSi/Lji0pzUosPMZoCA3Ui s5Rocj4wEeeVxBuaWBqYmBmZWBhbGpspifOeuVKWKiSQnliSmp2aWpBaBNPHxMEp1cDkpT57 j3fg9WcqKuKrp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dnZbPlFoy5tzqSmuZt7HIz2reov/PMhnWrT2 eNzEF8/q3KX3HwuUeC+2XcAmPvoK89vpd77z3vefXHRz9R+jFexiWk0L333/sGKxSq3I4wls U4SZGu+fFXzsrLLWVcOGyyF53s9/4n4H1NNM//CxWjaVpZWxZB5USjCU1nfIdDlc/NnE6p7/ 78MLFpTNvmUQOytnfvXutErpz9FHlncpsRRnJBpqMRcVJwIAYscT5sQCAAA= X-CMS-MailID: 20240702120631epcas1p1c7044f77b56009471e2dc07d4e135a99 X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240702120631epcas1p1c7044f77b56009471e2dc07d4e135a99 References: X-Headers-End: 1sOcHW-0000Ew-Bq Subject: [f2fs-dev] [PATCH 1/2] f2fs: use meta inode for GC of atomic file 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: daehojeong@google.com, stable@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Sungjong Seo Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net The page cache of the atomic file keeps new data pages which will be stored in the COW file. It can also keep old data pages when GCing the atomic file. In this case, new data can be overwritten by old data if a GC thread sets the old data page as dirty after new data page was evicted. Also, since all writes to the atomic file are redirected to COW inodes, GC for the atomic file is not working well as below. f2fs_gc(gc_type=FG_GC) - select A as a victim segment do_garbage_collect - iget atomic file's inode for block B move_data_page f2fs_do_write_data_page - use dn of cow inode - set fio->old_blkaddr from cow inode - seg_freed is 0 since block B is still valid - goto gc_more and A is selected as victim again To solve the problem, let's separate GC writes and updates in the atomic file by using the meta inode for GC writes. Fixes: 3db1de0e582c ("f2fs: change the current atomic write way") Cc: stable@vger.kernel.org #v5.19+ Reviewed-by: Sungjong Seo Reviewed-by: Yeongjin Gil Signed-off-by: Sunmin Jeong --- fs/f2fs/f2fs.h | 5 +++++ fs/f2fs/gc.c | 6 +++--- fs/f2fs/segment.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index a000cb024dbe..59c5117e54b1 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4267,6 +4267,11 @@ static inline bool f2fs_post_read_required(struct inode *inode) f2fs_compressed_file(inode); } +static inline bool f2fs_meta_inode_gc_required(struct inode *inode) +{ + return f2fs_post_read_required(inode) || f2fs_is_atomic_file(inode); +} + /* * compress.c */ diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index a079eebfb080..136b9e8180a3 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1580,7 +1580,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, start_bidx = f2fs_start_bidx_of_node(nofs, inode) + ofs_in_node; - if (f2fs_post_read_required(inode)) { + if (f2fs_meta_inode_gc_required(inode)) { int err = ra_data_block(inode, start_bidx); f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); @@ -1631,7 +1631,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, start_bidx = f2fs_start_bidx_of_node(nofs, inode) + ofs_in_node; - if (f2fs_post_read_required(inode)) + if (f2fs_meta_inode_gc_required(inode)) err = move_data_block(inode, start_bidx, gc_type, segno, off); else @@ -1639,7 +1639,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, segno, off); if (!err && (gc_type == FG_GC || - f2fs_post_read_required(inode))) + f2fs_meta_inode_gc_required(inode))) submitted++; if (locked) { diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 7e47b8054413..b55fc4bd416a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3823,7 +3823,7 @@ void f2fs_wait_on_block_writeback(struct inode *inode, block_t blkaddr) struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct page *cpage; - if (!f2fs_post_read_required(inode)) + if (!f2fs_meta_inode_gc_required(inode)) return; if (!__is_valid_data_blkaddr(blkaddr)) @@ -3842,7 +3842,7 @@ void f2fs_wait_on_block_writeback_range(struct inode *inode, block_t blkaddr, struct f2fs_sb_info *sbi = F2FS_I_SB(inode); block_t i; - if (!f2fs_post_read_required(inode)) + if (!f2fs_meta_inode_gc_required(inode)) return; for (i = 0; i < len; i++)