Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3332062rdb; Tue, 6 Feb 2024 14:33:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU74AYsd58zAjfcd4pAacTE5DB1dGp6sP8tExtUnTYb+hbk4916jvAg4L/lUoS+BTmCNvUtAKfW9slKKCJmvZUDiPOxHCSLyFhTNpsOCQ== X-Google-Smtp-Source: AGHT+IEYk81ulPuONH+FEktBRW1IdRPLYSnFpm7DpOloaNF7I+nowCrAhF/6RMgWCYBRbBcYxqPF X-Received: by 2002:a05:620a:9d7:b0:785:3ed3:4a14 with SMTP id y23-20020a05620a09d700b007853ed34a14mr3864570qky.49.1707258795362; Tue, 06 Feb 2024 14:33:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707258795; cv=pass; d=google.com; s=arc-20160816; b=Kqmj4uq/ekqofxmG5EXmKrFGLGjzZdiU6JCUMP861vLB6m5vK2pfS1s05QO3ZcOYJ0 YrZUxWQBLLrMNaFZV3w87Alas3Us5a+cOE+ZERydt9c3n/2jPISQaFibmebrbxSPpz2C zqdoPCUrF1w4vF47MiU6s8SAKiB7BD5bZ55XYHNQndmNqVH3K2jiWGH1rmDfpvFzbYSl I9ReaApluhYiGDHMhLLRVqYnUMXDVgnBvOFNr58E0fI5WCtVy6ogqvroASPiEAlFu45A C5/VKhhGSW0paeORHuzcEzP0Nx4+CATgbzZEWyzA4u6smaY3hQfFW1tSqHHPIL3GYyFW vU3g== 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=00pmZ6kibv+G4s9omY1rvgDUEdmKCy0BpQNbUzvHf2k=; fh=LCnxqrUVo06la30SydLe4W4v56fjruZG71V/bnON284=; b=o8s3wPRT+EFLlD4B9RPMk7ow1hW30Bcs52t5ap5fS6Y34r1jY018/uADVZQa+ffWbh QTYd14ToDQsjGa0g87XCJF7MwfJowCm957z3xxSxK7Rk6anunFNo1JzWvznGwdRyp1Af WZTse9uOUF1V9LQxTumuxlLCd+aDlP7gnq7RNdOzf87GJdxJgL34BXoCwztG285DaY29 p8L3S9JFACZOWpwjs/Tu+gbTLWn7h6F+yK9/RrBZGds2Ok0MJac9vygPAFKvi/XAw75i wb/8Ue3zK2QaxBj8FKmTlSIdtapET8QFUe1AfpYuoeTFndDUPGhYvLt/gaNbM5Is9LOd PWYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dAbjJP2F; 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-55691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVQNNtXOXBnsFdWKcy6PzzrC+TX+Am6X95a0O67RMctDG9UcnyNF67JvggL1ouLUFqeFVwduF90gJQwfW586EfWwZ7pTcSc13j8201R4A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id cx23-20020a05620a51d700b00783f0325d1csi3234058qkb.131.2024.02.06.14.33.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:33:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dAbjJP2F; 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-55691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55691-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 200F01C21EBA for ; Tue, 6 Feb 2024 22:33:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CAC91C2AD; Tue, 6 Feb 2024 22:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dAbjJP2F" Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 68FA51C29C for ; Tue, 6 Feb 2024 22:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707258786; cv=none; b=tDBNYJGxXeP1byklM1S2b8T1c0XEAjBAFISBQkl40oFOrKUgYDpheLS0K9h0t0HqxN7E4LkxxPVbQl3z+i/oBg5W+5nWSJRMk1zSMLPy5Ztdbr+XpXadelizEDSy83VsxOmMI1C0QL6iD9CSBleq0m2VyYs6zL+g9JaA8XJU/C8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707258786; c=relaxed/simple; bh=sukycBZ4DQwhrKijFq94qphTf/v5PohQw/3KG49HqcA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=g23cIlUHkelbzxPZm1eVmQJR8dIqUXgxJ7XqZPR50QLGzO51XYDI4R019vgQu+ImaKlZJm1n2LSIe19J4TqBJu7eqg14/9Z0v9ob8xPjzdkx8ud7/gMcykN8Jk0uv4CNwttGOCUuf5iu4PvuBGO/vnAVGwDXSR6I3kynRTVs6pI= 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=dAbjJP2F; arc=none smtp.client-ip=209.85.216.53 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-pj1-f53.google.com with SMTP id 98e67ed59e1d1-296c2b74448so1083649a91.0 for ; Tue, 06 Feb 2024 14:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707258784; x=1707863584; 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=00pmZ6kibv+G4s9omY1rvgDUEdmKCy0BpQNbUzvHf2k=; b=dAbjJP2FjvUbWZ5/xlj6zKL4uz+PsmKUwIhiDyxC8zgL9JMA1+U7gytU4oTc1LW60H 75IAexDRyQmRjVTQEbKyTvV3fjncv+fedDJMvePXHo1CLzl1m75VjFrNn7nch+xeNFcU OCM6K17P5yuz56w5GZUptlCpY+ZysHnw8kGY4uOnWJY9IA9LbLww40QXPH4cDBHmLf3F X26/TwEc+fGgy422shTBaAmTzY2G0Ox8qjABs7V8cy7PUk2I7eieRuNMSe29EHIYRjQ6 IniX0JEdhDGIXOuQLDaiMjXXZ7o4cws4hG8OrHCzLepS5X0qC26akGOjqES8btFKRFWL xzOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707258784; x=1707863584; 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=00pmZ6kibv+G4s9omY1rvgDUEdmKCy0BpQNbUzvHf2k=; b=T8RL2SpfpnIJwTI1SWCibAv64Ly3qVe+OhZyXq/XmGtbea2i4oI48tBtOi3aJboFP8 Dfsp/A3OZ0sTNlvmXSg3Jxr+viqp8TUwiJH0KogzS6DXYD+kNJq85/l1/CakDfDHrMWh w+eHwzsjafmHPDCfkS6zsLqugeVoL+KBTtqh9O0NBjIaUIFzUgUIE9YpaJVK1HHB34VB Bx4MBciCMUSNBzfICq/qC6pQvFNwykBcgrpn6bZvLaofpAdYehiu/7uakbYwi2AQvosA u1NQ32ib66mdFLoo8oI+M44TukxL3wKzGYNM9KKU1PNBmkrmDhysKbkL34xXefF2+wCb l3rQ== X-Gm-Message-State: AOJu0YzKr5Uo59d1KcfymziiXplvmHFIKwW/MyGz7tarNqkuvH564pUY i8Cy3be8ficRfqWvFsCKF/mRyKod6bDPdAnIHGmS6f3jQYuOFffGeHNWKRSU X-Received: by 2002:a17:90a:3189:b0:296:9bc8:c16d with SMTP id j9-20020a17090a318900b002969bc8c16dmr984401pjb.26.1707258784206; Tue, 06 Feb 2024 14:33:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXc6fivOnbrdtPy6PSV7U7G5sDFUskyySDlpl9XItR4RSmzcx7WMPVFXScv6FmQATmvQ9oKEViDUfNAso87u1Z0mEqh74yLewWSU9k55Kdg4ukOvCfb2h7wDftWZXIUJ2u2PHzIwashMdbsNPBlEmCqnlDUUc4acxza8JQoQVtzXxOfsw== Received: from daehojeong-desktop.mtv.corp.google.com ([2620:0:1000:8411:6e38:9e6f:4818:7d04]) by smtp.gmail.com with ESMTPSA id n3-20020a170902dc8300b001d6f091ca04sm32371pld.13.2024.02.06.14.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:33:03 -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 1/3] f2fs: separate f2fs_gc_range() to use GC for a range Date: Tue, 6 Feb 2024 14:32:55 -0800 Message-ID: <20240206223257.3461359-1-daeho43@gmail.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-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 a079eebfb080..a46d5053f965 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1983,10 +1983,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 += sbi->segs_per_sec) { + 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; @@ -2012,25 +2036,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 += sbi->segs_per_sec) { - 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.594.gd9cf4e227d-goog