From patchwork Tue Feb 13 17:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13555441 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 4C837C4829A for ; Tue, 13 Feb 2024 17:38:26 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rZwjf-0003oN-HP; Tue, 13 Feb 2024 17:38:24 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rZwjd-0003oH-VB for linux-f2fs-devel@lists.sourceforge.net; Tue, 13 Feb 2024 17:38:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vBDyj3Iv7QB4U+Y1PAOul+HNZzqp+6gSDSC9V0g8NJY=; b=IXuvAWqw9l36QeDBy7oOc72Wl+ 1q/axKZL9xbLFe0xtsosWmZKnlcmRr01dT4BhBYD4sjAabN1yCpFvFWdBY7xzHQG5ddlz99rBkvfO wa63NaHku124+0/kib80vRI6aqG1rTSNr+MOhMRWffKFY9CiaO+hCKcF4UiT3AFvnisI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=vBDyj3Iv7QB4U+Y1PAOul+HNZzqp+6gSDSC9V0g8NJY=; b=D HHtbxivsQ8L3/kgc7GkhWYCcpxv8XbsOzuD64x4DKTa8+oTYnYxBAnWwseW/19crRXxNSrtiFwl6C 1HGgwDoHJjOT00IFsqS9TE4H77BMMLtn6YZi2JtlHf3w0OCQg0Cy739tzR3mkJ8zI2SGmg0q806MX 5sUL1qJmzzVcpvk4=; Received: from mail-pj1-f49.google.com ([209.85.216.49]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rZwjd-0003ju-Jb for linux-f2fs-devel@lists.sourceforge.net; Tue, 13 Feb 2024 17:38:22 +0000 Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-29080973530so3340555a91.1 for ; Tue, 13 Feb 2024 09:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707845896; x=1708450696; darn=lists.sourceforge.net; 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=mzLMiMCLR8fEYg6dKX0Fto6IlHiP4Yv42u71Yik94O2AlZqeotNmSGideF207MFfRR egAOlla7o3O4yYjYe3oOb5CNLkx9B+UuhXL+Bxk11mrwXJg8w4AcN/iRdPb22r4bIh0s STLyHTwv0WSUmnAmQQclOBdqsUMO8jTZwdRBCdWqgXpX50ASlzdPd0dVxWyq1mDdfTL5 OA/3Ixv8/0zQUYuT/VMsmO7/3lW8JRD7y+hrTDwVR5J7b6EQBgFBPMzUU9P4kra8CY/g 4QPSiCO2H5SRzWOzGOgCg/TsuJu16HtsEXtNJMOQJX631Emll3BpK+1K9Md+yNRbq6zM UjGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707845896; x=1708450696; 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=pSHwxzWfhGY/qIo8a1ImzswNZXgIebK+oXAzOj8Fd5kULKvi9Lvg5psAbXKvdqD/bp Wd330Q2gExdn3RcCmTHPd+/0h6T9LeYaMvdPLrrbRFm5XLFdqRJ+bbgzeRZF6ayvMp09 ZZ30edcOuNkd9OW1uvfGb6rISI5HGKkVfa207Lc154fx0GrB5/kQZSniCXCJFBqZUxK4 fo0PFzohR7OAg7mmhsf0mCFI6EpmhnPvMXMvLVTdawj9CxfOLptU/lt0wQsneRzBvXfr 1YalorLNVXRZStDWXXw/54Bfv2Gp3prQH0w/qKS5pxBfLWiOPh3QwHDMDPLX6eLzT6XM boCw== X-Forwarded-Encrypted: i=1; AJvYcCUnwFG8gGeXIvjv7SQ1qj4Zzxfa5s7y/z8CHLduRevJQgjT8dCvtJ2z/dFLmW8T7LfcNx9ERxu9F9/bvpg/gcoSlfHRveoifNkrKerR+zz58/2q+jZ3SQ== X-Gm-Message-State: AOJu0Yw7AIvqMpv2PWaPbe/e9eUVuGY8k2Uqu/4i6BmQ8eOb6zdl+Ijp /HI/HX3DaVHSW1XPlw8j1hkvaFNFjN9W0hyuT2tCGmncKzh5FKR6 X-Google-Smtp-Source: AGHT+IFW3W85BONrKtua73JEpUlNUnM0AJHEdGsV1qPTe08O6+wHY1sVAFgjb3rFc25HUMnNh6gW6g== X-Received: by 2002:a17:90b:1881:b0:297:2748:3a0b with SMTP id mn1-20020a17090b188100b0029727483a0bmr144667pjb.44.1707845896405; Tue, 13 Feb 2024 09:38:16 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX6V7Ro+C296FFuXGiC612aVz9WWS1Ry0aaZwCBOUaZLpQuhQiuvzDwAuYlSpUFkwY/RCLyJzCk1kegA0Z6NQ5PCI+3pToXjgETVYRLhxy0yE2sESy7xK0duaSBHRE050nW61lCUD3u/iX+NQ0JDQH+wiBxf84x30ioBGPtbEjFhSNrEg== Received: from daehojeong-desktop.mtv.corp.google.com ([2620:0:1000:8411:1deb:64bb:dfd3:ad56]) by smtp.gmail.com with ESMTPSA id a18-20020a17090acb9200b00298cc2b7e94sm198137pju.34.2024.02.13.09.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 09:38:16 -0800 (PST) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Tue, 13 Feb 2024 09:38:11 -0800 Message-ID: <20240213173812.1432663-1-daeho43@gmail.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog MIME-Version: 1.0 X-Headers-End: 1rZwjd-0003ju-Jb Subject: [f2fs-dev] [PATCH v3 1/2] f2fs: separate f2fs_gc_range() to use GC for a range 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: Jaegeuk Kim , Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 Reviewed-by: Chao Yu --- 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);