From patchwork Tue Nov 22 09:03:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggil Song X-Patchwork-Id: 24218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2088907wrr; Tue, 22 Nov 2022 01:04:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf5E9jcqAtKxUKFv0LAyyKyLIkv6N4g/61bN5RxZhpidwjgG4r2onRjzYAPgSgIw/w4coYKg X-Received: by 2002:a63:d48:0:b0:474:6739:6a09 with SMTP id 8-20020a630d48000000b0047467396a09mr9489660pgn.292.1669107864457; Tue, 22 Nov 2022 01:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669107864; cv=none; d=google.com; s=arc-20160816; b=wjrmQhwggz7nDfvA8GfJ0THyopbZkUiodELinEEVkEMo6PD7JdrjKLslujHUy1ata+ 1XJnDDHPkjeV+TN8oo0pQIPm0N3Ce4PWlaRGfVgUc+guPn4/c47UfdbXYEMsDtcp4uKc n9D2ktwo3cxtrSRjL/hKEMsL5YGSLcuJfen6E5PlS407HovUw6IRnO2z4I36Y2ddvwWS rZxAQCIAr/8gZwdE3DKO3a0xCIKnb2Ne8lCLH6mTi7T9jSQ2/kmZI3ZL2SQXCAe9jPB8 GF3eaW4nu1x6fgVERWFJs1jpugImlKf9uk/fwK9ioeqQMfPVdEC2boC1qeJvYdai7B54 DyAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:date:message-id:to:from:sender:reply-to :subject:mime-version:dkim-signature:dkim-filter; bh=p9LCVLTZUGHskW6P80iZkkOsBwgTL7D4TlYMb1/7yjc=; b=NWa0CBjNvtfN97AViDEwWLZ/8lO/Qs/kQtdrRWr/8W+hp0WYK9tIdcm4wosb6LVQEH n4M3eaYateZMFWA67Sye7SWubku0OM1hY6k3MZ59t0aqpfb3qwLw82yA9c9Vtjw5r09j Lw0bkfZ9MK7dwmzhbWvAm1N2l/FewOj4LEZOB8zoDd4VS2UE56yP1JKSBqhlpXUMFWMg cE//WhvBQwfy8EhO/y9IDPRVaXTGfkjJ3f6cq9RsP2jXrWY9/9NG0nxYymR/5c9D+EVV 425aNAPit57dVFnSsEQD+TYlig83mXdz+JHjn3vD09NfjvFvgueP+KtuH0GVjzJxgEK+ eTIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=D38PXV3Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a170902ed4400b0018659963cdcsi12564920plb.514.2022.11.22.01.04.10; Tue, 22 Nov 2022 01:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=D38PXV3Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233094AbiKVJDp (ORCPT + 99 others); Tue, 22 Nov 2022 04:03:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbiKVJDZ (ORCPT ); Tue, 22 Nov 2022 04:03:25 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7DEC75B for ; Tue, 22 Nov 2022 01:03:23 -0800 (PST) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20221122090321epoutp01660ed243f1d34039e7e4ffb82a0f1793~p3LPG-hjo1844318443epoutp01R for ; Tue, 22 Nov 2022 09:03:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20221122090321epoutp01660ed243f1d34039e7e4ffb82a0f1793~p3LPG-hjo1844318443epoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1669107801; bh=p9LCVLTZUGHskW6P80iZkkOsBwgTL7D4TlYMb1/7yjc=; h=Subject:Reply-To:From:To:Date:References:From; b=D38PXV3Q02Ls+beYpQxX9/lA+prqrFCEV0TkIAgZNhmOmexkdyfSN1cR1fXrTHuJ8 It8sHZdartG3l2fG0CCclMSzJO1i0Ys8yyhNMIIkGmF/z4CUp5QbGvxe8f8p+qMl4H oV5eSf0R90GWGnzP1dSSsuVw93YOZ9xeN/B5NaPI= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20221122090321epcas2p2b3dcb585fd8e66e0a2abf332f2147064~p3LO5okHY1823518235epcas2p2y; Tue, 22 Nov 2022 09:03:21 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.92]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4NGdZw6cL0z4x9Q9; Tue, 22 Nov 2022 09:03:20 +0000 (GMT) X-AuditID: b6c32a47-079a4a8000002127-72-637c90583602 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id A6.2D.08487.8509C736; Tue, 22 Nov 2022 18:03:20 +0900 (KST) Mime-Version: 1.0 Subject: [RESEND][PATCH] f2fs: avoid victim selection from previous victim section Reply-To: yonggil.song@samsung.com Sender: Yonggil Song From: Yonggil Song To: "jaegeuk@kernel.org" , "chao@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20221122090320epcms2p2e5df6f7bb1c2d80ae69fd5e4f84b08be@epcms2p2> Date: Tue, 22 Nov 2022 18:03:20 +0900 X-CMS-MailID: 20221122090320epcms2p2e5df6f7bb1c2d80ae69fd5e4f84b08be X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBKsWRmVeSWpSXmKPExsWy7bCmuW7EhJpkg6un9SxOTz3LZPFk/Sxm i0uL3C0u75rDZjH1/BEmB1aPTas62Tx2L/jM5NG3ZRWjx+dNcgEsUdk2GamJKalFCql5yfkp mXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBrlRTKEnNKgUIBicXFSvp2NkX5 pSWpChn5xSW2SqkFKTkF5gV6xYm5xaV56Xp5qSVWhgYGRqZAhQnZGRNuOhdM5ar4+uQTUwPj Go4uRk4OCQETiX1HLrN1MXJxCAnsYJT4tuIoaxcjBwevgKDE3x3CIDXCAiESP9uXsYLYQgJK EtcO9LJAxPUlNi9exg5iswnoSvzdsBzMFhF4xShxZrUoxHxeiRntT1kgbGmJ7cu3MkLYGhI/ lvUyQ9iiEjdXv2WHsd8fmw9VIyLReu8sVI2gxIOfu6HikhKLDp1ngrDzJf6uuM4GYddIbG1o g4rrS1zr2Ai2l1fAV+Lijylg97MIqEo8e7oTqsZF4vLpj2C9zALyEtvfzmEGeZ1ZQFNi/S59 EFNCQFniyC0WiAo+iY7Df9lhvtox7wnUFDWJzZs2s0LYMhIXHrdBXekh8X7/IiZIqAVKvL34 l3UCo/wsRNjOQrJ3FsLeBYzMqxjFUguKc9NTi40KjOGxmZyfu4kRnOS03Hcwznj7Qe8QIxMH 4yFGCQ5mJRHees+aZCHelMTKqtSi/Pii0pzU4kOMpkAfT2SWEk3OB6bZvJJ4QxNLAxMzM0Nz I1MDcyVx3q4ZWslCAumJJanZqakFqUUwfUwcnFINTAeefrydv/YwM/+H8Ke3Z2pyvMo7/iTy p5BQ5/bE+1f+2urcW/riWx6Lc1fECa3Wn7Nnlf1/Fur6ur5BMmZ27erUiC5mHyffVsYrH39u kaia4VTVNbE2aUImh3/Jok1fPx85Ysp11/F9doW9wzYx439Lw2ssWIW2NBTPaXzzRbl6yuQp R9ZKJVULe2R9jr+fES3zyumFSF+G8maLqAMv634ozOj/McWhOFeDZ7bor1vF+mdsff3ehV76 8UXcd52OuKfymdyTf1J2ljW37mRUPmm8J9y1+/1JgwbDXzxT3rvsvSnEYfS+VM9AVdmveeXu 3O4lZ1+/vbFk+sGL/DFhfH2zHRg2Hs5Weat2cYZ+nRJLcUaioRZzUXEiAHDN5fT7AwAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20221122090320epcms2p2e5df6f7bb1c2d80ae69fd5e4f84b08be References: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750186447717844057?= X-GMAIL-MSGID: =?utf-8?q?1750186447717844057?= When f2fs chooses GC victim in large section & LFS mode, next_victim_seg[gc_type] is referenced first. After segment is freed, next_victim_seg[gc_type] has the next segment number. However, next_victim_seg[gc_type] still has the last segment number even after the last segment of section is freed. In this case, when f2fs chooses a victim for the next GC round, the last segment of previous victim section is chosen as a victim. Initialize next_victim_seg[gc_type] to NULL_SEGNO for the last segment in large section. Fixes: e3080b0120a1 ("f2fs: support subsectional garbage collection") Signed-off-by: Yonggil Song Reviewed-by: Chao Yu --- fs/f2fs/gc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 0f967b1e98f2..f1b68eda2235 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1749,8 +1749,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, get_valid_blocks(sbi, segno, false) == 0) seg_freed++; - if (__is_large_section(sbi) && segno + 1 < end_segno) - sbi->next_victim_seg[gc_type] = segno + 1; + if (__is_large_section(sbi)) + sbi->next_victim_seg[gc_type] = + (segno + 1 < end_segno) ? segno + 1 : NULL_SEGNO; skip: f2fs_put_page(sum_page, 0); }