From patchwork Mon Apr 3 08:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 78417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2156349vqo; Mon, 3 Apr 2023 02:00:26 -0700 (PDT) X-Google-Smtp-Source: AKy350Yb03o1yJTAHU2kljOd9iGYLEVJBaMMmH6TepqYWAKQwDEw+++efbdDaQNICRQuoSZiQZkI X-Received: by 2002:a62:6282:0:b0:62d:b7c7:bd6e with SMTP id w124-20020a626282000000b0062db7c7bd6emr14124674pfb.12.1680512426587; Mon, 03 Apr 2023 02:00:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680512426; cv=pass; d=google.com; s=arc-20160816; b=UTlRR/t3SP2BI9N3ngW9zROJIU/kVawvJbj5ENr6/RZH/TDMW3ZKSShl7pNylO+G7k 85oQR29d30zfOUulaWlAHSrgEmFuHvvS47qcSs28M2RB9yNv5XMEq0/ybij/PK8WXuTx Y7lFpEmC+dguGmaVVzNRoR7lQHKC9x/lk4AX7NbD5A64DFpMtQSiuA4u5PpCvlBKvh8S gBdD/lqpPCrznIl59nhGXEHrVtZk2fwlStp15gpla2x8gmiJYPnc13r4zmdtwKszDHha fY52064e4eASrUmAa4292TtjmtLOwIBiQbFcpUYu+Krbzau+U4lZhkRy26OWCH+CCndr J/uw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=MLrsLzjyMRlBeXTe/gW3HzqmTd8IPC4x83ju3uTFvfE=; b=UPE9h72Hpo3JDCkkoFpJ5qf4eQBNRDM8/7rKcMWgR8dxBPtCATxCBP2D4dDLfNg/He BKqQkQnUzERULIWTS6cQ+2eNlkrIgO0o/Pf1NuBYB1X3irQoPTkCKGRqs0dNHoBw/6Qi KfPcCyJaFdXlCQVcw33wVdeCYhoIQO6FJ8Qz/fQEXba1qzeQPaUBr8p1bayAKMy4nDY8 +dHz9jHsgNX3iMJfEZwsapA00u4cpKyta0E0cHB3zS2cR6vix0sMg2gqijpQtNfIBYXY ytWog4mPjAs/vCz4zz4Eanw/Mxe2VUO6gjqSPBAVORavRZLSLAHaf6+n7FHS8hraeUx0 Hbrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="nnsVQ6S/"; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 64-20020a620443000000b005a908acf446si8042591pfe.104.2023.04.03.02.00.13; Mon, 03 Apr 2023 02:00:25 -0700 (PDT) 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=@vivo.com header.s=selector2 header.b="nnsVQ6S/"; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbjDCIlX (ORCPT + 99 others); Mon, 3 Apr 2023 04:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbjDCIlU (ORCPT ); Mon, 3 Apr 2023 04:41:20 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2105.outbound.protection.outlook.com [40.107.255.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E2D19BF for ; Mon, 3 Apr 2023 01:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=corWlnQbvyFeeEA5yECst8pJXBx5t9qYluqrZNzIp9jXeiF7PDDRwFAnujsXbNfzxN6YC6NhNGZJVVnG1hFKi91nvJSxLVZTcQLUMj6bful8BSuIft+omMk1tZArPxLihFTOjmHKEr652Spld8MKP2iHItyDUNnler/poAGqO05X4rRLpr5kRpncR6UlubesXJDSAv1+WU8xJxF5VTq99gxY7/G59XTnoQ4EEED2fgb7kdz5/ZDiRYLrbMCg5ofKeT+vFYL+7aPCcm+r+mQPmlBett0bI9hsNLoY20f8huREJmfFxsEJH/Tli2bsFQxQVHU7nCIdlNjOuY2k2gzbkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MLrsLzjyMRlBeXTe/gW3HzqmTd8IPC4x83ju3uTFvfE=; b=ay+57BHAqY/QmouNPaKJUqJLa32c7mxcYMJM4UgJXh4iFT80eaHfvsq+JD+zLggP0uPFSOZ5vcCiwnf6iv5gCMsBQ6j997v1gp5sBYYn4cCZdkVmRo29XoweuPLUQkA+BuHHIswwM2rABK15+EWJdoG0m7ZJ8Rta0Drnc2Vaukrg5xS9HDZuGUNJsuqRh7O4BlI/c5jDnrutZkGEAAt9Hj8F5QnniF6eElW0V2jALYruaheD7L2aBkRvi2OZj5vQ7Y1UOqaKRLepcAUqb7kgHDcslolL8LN9el4LGBssRQSIgZfE/ZTuogHKLj+CRDErOWxmRNvlrFAQ/j31kQwxIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MLrsLzjyMRlBeXTe/gW3HzqmTd8IPC4x83ju3uTFvfE=; b=nnsVQ6S/cTLlVrDvLDIn6VAJocgJWuq4Rs64mwjuf8vnecugx/CP5WDKJnuqlo1bcTaqy+GvHLoHJS8/HFgoKqw8EFRqlybe2odqlrmOls6+lGLDYWiqQtw1u2UzaD6fO4Za1u74kcDw6RC1/IptfpqGwGqiXhjATf00t3iN1ylUEOaHcoLW2heC30UjK3XML5csq5nCPg4sYIZQcaAIhkMe7qXq5iQqWl6MC55pxOfkuhpduo64GQSNS9kxcrvrnAXb6xTcmE/7azCIzH1cBHMghaUZ74y1KS0a7kfhHvPBgVyw3TioOy/w5PSzNUbmZ32Uf4bc4KX+EaQkNwF7wQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4300.apcprd06.prod.outlook.com (2603:1096:4:15f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 08:41:11 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c%6]) with mapi id 15.20.6254.028; Mon, 3 Apr 2023 08:41:11 +0000 From: Yangtao Li To: Jaegeuk Kim , Chao Yu Cc: Yangtao Li , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] f2fs: remove struct victim_selection default_v_ops Date: Mon, 3 Apr 2023 16:40:54 +0800 Message-Id: <20230403084055.21482-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI2PR02CA0035.apcprd02.prod.outlook.com (2603:1096:4:195::22) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4300:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e2b0231-bd1e-4c50-491b-08db341f2d01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KVV7A37heW2uKnBLBJ5/bEwTSbvff0gHxnb6K32++rxZqGojoIlll+TD1B0UEbhIDMcN0f8iTTX0/rr39MzI4noAyYeG6BtP71II1SCLCbjcuXO7jutiewZ7/G7VYZ+FPU8pok0rToT4dhe0TTp5xQ7HYvANUTI4KT+60KRj7qB91yE47hsqCwaGYU86gOsd8ASSa+6GqvIeMdJziVF83IXAY6rzp5aOzmmy9gXj1DBfEuQsZDNjowIz7bAcpIT4cjR08/t2BN2qIyQ8TeOVs5r8NygtzxMZCfN9NTzedenhgIqh8iD8kS/Q4otypdBHskHlc7SwtqVWD+7lPEXjSmDSfiupMTCtDAV1+5G1Tt+Mo+1WFGXIgeN4PvOsdG+ss33Z+Y39H2WWcdStrQJTSOBJYhVoj92zMizzdEYECnJXnq7ZCT2wbjy9PhbspGLmLn0x4v8XZ1FJPsPac+9y45Er82CxomTOfku+susIk1hfATi4mOrEznwiUz9uxvck93IP5iiMTxqQpuegdRUUU61xkv/pn1ygSGEmmxiufUcRuDHyaez4ImxCTq3rRx3t/mDvc2SO1n8EsuDVwVhsDyYyuj+/+P8sHWRA9ImWOJzBy+HG36zvOvQKAs40CYaE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(39860400002)(136003)(376002)(366004)(451199021)(316002)(110136005)(8676002)(66476007)(66556008)(41300700001)(4326008)(66946007)(5660300002)(38100700002)(8936002)(38350700002)(478600001)(86362001)(2906002)(6486002)(52116002)(6506007)(6512007)(26005)(6666004)(1076003)(186003)(83380400001)(36756003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bz5/MY3MEIhmkONHQehtwNF8FgH/eugBbZXA9259KKSvG35aLigrYnj+1kZq3pqnNjhOmsefnwk6BVJ6bcs0WQiUKCvWrwyGb5G1DRvNNlZG6KnfU7BBq0/Pe/b96OaRlyQWgDhL5rGyKUCWu1legCPFp1i0f6FQczrY0LRL+ct5MB+ouu6yPMo294RBcXX+GJgvG7OL/vwEG6114Ho7ZukUeUa5bnZ9eEdNJXQwhK+5rpLuTQKLR2MXr8t1mQZuRbCSLIYQrX2F3xFg1WSS8DaqkiBpwAk5KJM7XQe7+iEpG0IW0jKkTMdD8ltVGjWVxGz5XZCZ9uAB178GPSrCgNP74OGPUWtHLdRIBYiFA9AlQGQCh/ZAvIR0aRs++jRUiMbF4AzhfQqwboWA8Mgc58ATOU/rpqsox5ogctEuDdnSYEPPelXvXI3GzQgVEjlXuATtcQOsxXitex5jekzr/qEc3GLhMBIpk2QLvimDAH9AML4aYP0x2lBAe3jiszTrSTHoX8sipo6xe84FEQNnNCOqiDjt3SNN92sXKh/vwKCL8mBGKokR5M85gl1QSHGlWvml37YiRdLe4QgtwqbieWFe2bCPrN+7X5R3Cmc1qv/WIgCcMeP1vBdoiO6EMcv85SNH+osdqHk42N7L+ALAmHLSwD64RHq/Ky2kp8a0s9pOCEhJikI/nwzKvGOgneCHNRY2LF/ycEtjR7HF+h+wVRiz1DiO5WJjuvNuawlMwGFgO6nJmnqy0iexeRtmeuAOXOv7cusXdsW0DFfd5n0DIKvXPnDxn///f/o/CKZizJ3pMHkd8PWIDtQtFq3KEhBF2g0zpQIGSsTCpsXM4MN75vnqNUpyUps2ACd+Gm4eh0LDp/6pxO2bzgnv5dzbLI1lQqFUBrULywWcBp4IYVPgLyfbscUyI8rW2ErQFHlqqUKxVlNz1biVgz2MwqC4a/u4vW2ufCEAnzwQKLItvv12Eg6yLTn1CPHprDUKMm2ZhTBhxn57da3PW+qepdFkMe0+X+HzfkDbEDwTXHNMMUI3HKheNN2EStrBj06/FrOgTeg5w7XFSVgQ/cyPsOLoFpsXY2ASkuUY1OdxoIL4jWoRi7C5yjGdCanhj+rEmgK6R4qSsKF2312Co/EyYP9/IRp4yCuZO3SXtEaJdBZZ11HYpvMvEj6ofUDJXfzVe10Ek3ouhTOeN26A0HqEcQ8Gxoa3e8oYNWlz27T4FEOzxdb0yNmzhOdnFNhTt35T7b+jMaJkhhPrR/ckWBV3OffKBDPo5apdS8bpYwYVfGkrBJzfX/jgisbqKjaKUtJXOQp2u3wPdf5GL9lfZx1Jm0RGszYEePip+j+O+KS9Y3y/fP6Nffx445nMfmQChHEAib2XZ6sc9FHv9NfEN453jCjh/PzuT3LJijsKrhWBoWab3hN/iGsVdnB25sVGiDazChwnfT46izCKD3T31F9Eo/PMdkt4tH7iqmmS+IDUkwqR+DEm1rUdWhop6+TswWvyI4MpcxjD/Cs1xES14cgpCUl80wIBQlTx63JDuWspdCWO2WdpRVbe6DFNzHBhqEBHhkzwkYp4T9mowL8LZcmAN/+DZ/X+ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2b0231-bd1e-4c50-491b-08db341f2d01 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 08:41:10.8757 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4HOVWeiolj018KbbmzyemMfCEz3RAEZ8yQRmaIcl0al6PS21WPZdv2pjlG3hTHrlma186XOx6zT4N0hwhr87oA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4300 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1762144997121197578?= X-GMAIL-MSGID: =?utf-8?q?1762144997121197578?= There is only single instance of these ops, so remove the indirection and call get_victim_by_default directly. Signed-off-by: Yangtao Li --- fs/f2fs/f2fs.h | 5 ++++- fs/f2fs/gc.c | 12 +++--------- fs/f2fs/segment.c | 7 ++++--- fs/f2fs/segment.h | 7 ------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 8d5124569a03..9a1ec5515121 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3871,7 +3871,10 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi); int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count); int __init f2fs_create_garbage_collection_cache(void); void f2fs_destroy_garbage_collection_cache(void); - +/* victim selection function for cleaning and SSR */ +int get_victim_by_default(struct f2fs_sb_info *sbi, unsigned int *result, + int gc_type, int type, + char alloc_mode, unsigned long long age); /* * recovery.c */ diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index f1e0e01a5dd1..f3f0020633ad 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -741,7 +741,7 @@ static int f2fs_gc_pinned_control(struct inode *inode, int gc_type, * When it is called from SSR segment selection, it finds a segment * which has minimum valid blocks and removes it from dirty seglist. */ -static int get_victim_by_default(struct f2fs_sb_info *sbi, +int get_victim_by_default(struct f2fs_sb_info *sbi, unsigned int *result, int gc_type, int type, char alloc_mode, unsigned long long age) { @@ -937,10 +937,6 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, return ret; } -static const struct victim_selection default_v_ops = { - .get_victim = get_victim_by_default, -}; - static struct inode *find_gc_inode(struct gc_inode_list *gc_list, nid_t ino) { struct inode_entry *ie; @@ -1671,8 +1667,8 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, int ret; down_write(&sit_i->sentry_lock); - ret = DIRTY_I(sbi)->v_ops->get_victim(sbi, victim, gc_type, - NO_CHECK_TYPE, LFS, 0); + ret = get_victim_by_default(sbi, victim, gc_type, + NO_CHECK_TYPE, LFS, 0); up_write(&sit_i->sentry_lock); return ret; } @@ -1969,8 +1965,6 @@ static void init_atgc_management(struct f2fs_sb_info *sbi) void f2fs_build_gc_manager(struct f2fs_sb_info *sbi) { - DIRTY_I(sbi)->v_ops = &default_v_ops; - sbi->gc_pin_file_threshold = DEF_GC_FAILED_PINNED_FILES; /* give warm/cold data area from slower device */ diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index cb8aacbc5df6..c9e674fe477b 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2881,7 +2881,6 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, int alloc_mode, unsigned long long age) { struct curseg_info *curseg = CURSEG_I(sbi, type); - const struct victim_selection *v_ops = DIRTY_I(sbi)->v_ops; unsigned segno = NULL_SEGNO; unsigned short seg_type = curseg->seg_type; int i, cnt; @@ -2890,7 +2889,8 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, sanity_check_seg_type(sbi, seg_type); /* f2fs_need_SSR() already forces to do this */ - if (!v_ops->get_victim(sbi, &segno, BG_GC, seg_type, alloc_mode, age)) { + if (!get_victim_by_default(sbi, &segno, BG_GC, + seg_type, alloc_mode, age)) { curseg->next_segno = segno; return 1; } @@ -2917,7 +2917,8 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, for (; cnt-- > 0; reversed ? i-- : i++) { if (i == seg_type) continue; - if (!v_ops->get_victim(sbi, &segno, BG_GC, i, alloc_mode, age)) { + if (!get_victim_by_default(sbi, &segno, BG_GC, + i, alloc_mode, age)) { curseg->next_segno = segno; return 1; } diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index d66c9b636708..89619969ec85 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -289,7 +289,6 @@ enum dirty_type { }; struct dirty_seglist_info { - const struct victim_selection *v_ops; /* victim selction operation */ unsigned long *dirty_segmap[NR_DIRTY_TYPE]; unsigned long *dirty_secmap; struct mutex seglist_lock; /* lock for segment bitmaps */ @@ -300,12 +299,6 @@ struct dirty_seglist_info { bool enable_pin_section; /* enable pinning section */ }; -/* victim selection function for cleaning and SSR */ -struct victim_selection { - int (*get_victim)(struct f2fs_sb_info *, unsigned int *, - int, int, char, unsigned long long); -}; - /* for active log information */ struct curseg_info { struct mutex curseg_mutex; /* lock for consistency */