Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp669667rdb; Thu, 8 Feb 2024 18:43:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLG/2UwLEHo5hE/JuPDN3Gm1S6FEElWt/wWffn4FH3RMaSkTeXS5tAydRcS8029xDzreIoYLc1zZ6SVqA3jj1Z4erRCVZ8fOxflrEKPg== X-Google-Smtp-Source: AGHT+IF1+NnnDqmmtcjEZmS2RPVpC4aJRuo+neb3yq0KK2hanJOQnUoltj8u1g9ka6LUMBilxlmL X-Received: by 2002:ac8:5acb:0:b0:42c:472e:9690 with SMTP id d11-20020ac85acb000000b0042c472e9690mr429707qtd.16.1707446583876; Thu, 08 Feb 2024 18:43:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707446583; cv=pass; d=google.com; s=arc-20160816; b=zglbV2QSdQ+oUuWscD35xuyudY/iRrd4BTbkfBEaIGLwjNulkQ8I+HRbap9e+vRnOV ZJXoyhLHeKqNXxcw1U7a5jZsFSQ3c+8zXS+mCLRSaaULSdX83hqnwHyYWCPfta+XCwuj Yh4Xt2b7I9t8XwkhHf3QIiVrFj8Dsz9Z00yA9RU8hcRK+Y1c2yD+oAh1rkSGorougRC0 nDErFx1bAWW1iU52suaApOEVl9ecLVLZJ6kUi3ZO3sHZNVzRyDWwJuwrzb06/zcCFDA1 7gU6H6mGsD1IekQOioaJXwuFIAsp0Zt99rI9TnfqaefmixeNY+toNx3VMpotJ+1Nn0kf OShg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=vBDyj3Iv7QB4U+Y1PAOul+HNZzqp+6gSDSC9V0g8NJY=; fh=MvJvUS62syfxaWVlFdOMEx/T6jID6bLITc84smCwllQ=; b=ZnCGFvSHoN+eZX1qLlDZk2g4QPPmWH2AmX1658GGASXS7Y0AjPTYy3YrM1HK3spWsq /Y8zCcXL/oA0cyzD5HOgml0JVuz4Aa8V8ZNJQ+ZR//IIP72SrQgaOZyNdwHUXU4klwPr vZZsbwzR1MxqxHhkbSd7ijE1XJKZ4m+r4MCkBcuYTH7NjBKcPgcNHU3G2DB7F4tLE2Ew vWP5+50wcOsFG+ya7DSLkQpdZ28BTWdoSqguWT97eM2Lo/NpsiRuFfLt3aUkI97B/fi6 w2/ksuHs0Hj9swAOpBUl6SSO619u8Aflt3SDyxijVps7VftgzJAi9a3OKtuRXSt3zR35 mcBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HUXtGzl1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWVRW1+6ymkwMJpii8agzIqA5M3box6DkI/tFeMWtP+J4OGODjxVBOOtYPRBG6qjDc1d3HBoteHzXeB/oFjZl7+0TTybh3vLttK0gdfSg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o14-20020ac85a4e000000b0042bfc455c91si939077qta.544.2024.02.08.18.43.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 18:43:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HUXtGzl1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 274FB1C26049 for ; Fri, 9 Feb 2024 02:43:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74DDB184F; Fri, 9 Feb 2024 02:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HUXtGzl1" Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C93715CB for ; Fri, 9 Feb 2024 02:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707446576; cv=none; b=p+eiGRr4rfXqA+GRg/yqMBdJorDJATuxKITLW4bO0r0Ec0ZSzvy9UgDZibPzT1av+ffqtlhxgX5jCHZ7ipQwA9bsiM0qPNNIPz/NbFvb5EgeaXe1C8/Ol3se0dDF3c7kdm8iPjeww9w31OtpUGbMrylCbntHPg6zzRiQ4MWmGEY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707446576; c=relaxed/simple; bh=GGZXavwH2wnOBhvMLP1tok9fBEDPJbr/LjEdpsP726Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uPnoaaLkF1hROruE+SSpVmxUQj5k2fzdKmMzJXIppbe9pXtXev2rRPJ6GUAGJr/wUwvg39eYpDHhF+lMMeI5YIqYcisPfQAjmWTFYAFhywnMtPaRh/jpPLXHfA6rx9oXFIpYo544K8iO1nZsWjJXUaAR3byKSE/V5S/YXdNoqSI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HUXtGzl1; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e062fa6e00so312198b3a.1 for ; Thu, 08 Feb 2024 18:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707446574; x=1708051374; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vBDyj3Iv7QB4U+Y1PAOul+HNZzqp+6gSDSC9V0g8NJY=; b=HUXtGzl1ZyUuCdioXSzKL3RneHkNTxXjPOPXmBeupb06MQ97jUHAV1QTlNBq7XH1Cy MPjVfjsrZbsvqlAp/RHVGYaZ6j+SPAiY38W0MC8aHIrqWDXEMG6Nls1dGSP0NDhqVYOe BbnwkgpKA1MKBQbr0sq2zLYayCaz2aNO3NZqq32nzM6ERJpVSQxWSmoYki/tAkjSGuid r7dxJWpDcEmO9Qoygu7gavQwywrIxBbyRJWt/8eBs0prF+N7ZOpMdRmFe/sbiL9yCC5Y N1a0rG4Sa+PPgeBEdGVltbfrFZxe1Hoj3YBh5RioZmARD0U5zqvISEn2o1+/LZO5hmPU ikRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707446574; x=1708051374; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vBDyj3Iv7QB4U+Y1PAOul+HNZzqp+6gSDSC9V0g8NJY=; b=cL+IofOWfTFE3qqDSWi1JzHEnDO0KSYrtdt/9MTwEVsv4a6QdnnbffoHe94tBhPYLL TH4hy4Fa4sTuj13A5JsV2zcZIpG4ET3xf9jglUMf6d79CHtCclF42jNZJbHFEzj8sekC 0Q70dIlcdqr/qsc39AZsnXAtjGEO6q0pFj1uiHGe8zt2K+GnPKTsGRxyGLLJE4FLcaX7 p0oTNNbMeSNxXGFr5rgHP4lsJYEnlZWbDjJyGX/3o6KGXoaXGHWvwEmMZQQ0MlQdabnk gjiNw535R2Tq/6gnxeablLUfNXn3Y/O/uLSx6PbzWMp4CqfWhX+msl7ARsyjXgB9J85u PQrg== X-Gm-Message-State: AOJu0YwrwgjKC9o+Sl4k0SzoByvuKkAFaeDWMHxvvRS3Fs1bUMOdYVGp zPjbAWHC8Q9LZkiCOCE2RSCZ9pVyyN4nZj82qtIZg9rAlNibEFM2V40r/Wv2 X-Received: by 2002:a05:6a00:10c5:b0:6db:d040:4d05 with SMTP id d5-20020a056a0010c500b006dbd0404d05mr448678pfu.22.1707446574237; Thu, 08 Feb 2024 18:42:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV+VsKHdVQvMC/78ocjiVjk/KLdMxA8f6hwUqQ/IjHhCJmRQlNHHD/WEV0r/2pERktgn2HAl/iFkpXo5P4jTEOGqpsvPqznpjb22+NhV8pjuWU6lpht6/oc1V5iKPpxgUXixjq2ls6VbbIHmE4YXzVjRbyMBs1648Sa5rv5Hf7WAUtEwQ== Received: from daehojeong-desktop.mtv.corp.google.com ([2620:0:1000:8411:20e:63ed:be25:710f]) by smtp.gmail.com with ESMTPSA id t28-20020a62d15c000000b006d9a7a48bbesm521505pfl.116.2024.02.08.18.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 18:42:53 -0800 (PST) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong , Jaegeuk Kim Subject: [PATCH v2 1/2] f2fs: separate f2fs_gc_range() to use GC for a range Date: Thu, 8 Feb 2024 18:42:25 -0800 Message-ID: <20240209024227.66741-1-daeho43@gmail.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Daeho Jeong Make f2fs_gc_range() an extenal function to use it for GC for a range. Signed-off-by: Daeho Jeong Signed-off-by: Jaegeuk Kim --- fs/f2fs/gc.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 8a9cdc5a72c5..a089a938355b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1961,10 +1961,34 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi) init_atgc_management(sbi); } +static int f2fs_gc_range(struct f2fs_sb_info *sbi, + unsigned int start_seg, unsigned int end_seg, bool dry_run) +{ + unsigned int segno; + + for (segno = start_seg; segno <= end_seg; segno += SEGS_PER_SEC(sbi)) { + struct gc_inode_list gc_list = { + .ilist = LIST_HEAD_INIT(gc_list.ilist), + .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS), + }; + + do_garbage_collect(sbi, segno, &gc_list, FG_GC, true); + put_gc_inode(&gc_list); + + if (!dry_run && get_valid_blocks(sbi, segno, true)) + return -EAGAIN; + + if (fatal_signal_pending(current)) + return -ERESTARTSYS; + } + + return 0; +} + static int free_segment_range(struct f2fs_sb_info *sbi, - unsigned int secs, bool gc_only) + unsigned int secs, bool dry_run) { - unsigned int segno, next_inuse, start, end; + unsigned int next_inuse, start, end; struct cp_control cpc = { CP_RESIZE, 0, 0, 0 }; int gc_mode, gc_type; int err = 0; @@ -1990,25 +2014,8 @@ static int free_segment_range(struct f2fs_sb_info *sbi, f2fs_allocate_segment_for_resize(sbi, type, start, end); /* do GC to move out valid blocks in the range */ - for (segno = start; segno <= end; segno += SEGS_PER_SEC(sbi)) { - struct gc_inode_list gc_list = { - .ilist = LIST_HEAD_INIT(gc_list.ilist), - .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS), - }; - - do_garbage_collect(sbi, segno, &gc_list, FG_GC, true); - put_gc_inode(&gc_list); - - if (!gc_only && get_valid_blocks(sbi, segno, true)) { - err = -EAGAIN; - goto out; - } - if (fatal_signal_pending(current)) { - err = -ERESTARTSYS; - goto out; - } - } - if (gc_only) + err = f2fs_gc_range(sbi, start, end, dry_run); + if (err || dry_run) goto out; stat_inc_cp_call_count(sbi, TOTAL_CALL); -- 2.43.0.687.g38aa6559b0-goog