From patchwork Tue Nov 29 13:40:18 2022 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: 27241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp343478wrr; Tue, 29 Nov 2022 05:44:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6YoG/Qew3pSvsD04F183fuf0Zxz9NEcruwzIE+D8s7iR8nbC0YGz2WBB8z/P7VEmjBcapu X-Received: by 2002:a17:906:c40d:b0:7af:1534:73c9 with SMTP id u13-20020a170906c40d00b007af153473c9mr31890019ejz.558.1669729448879; Tue, 29 Nov 2022 05:44:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669729448; cv=pass; d=google.com; s=arc-20160816; b=Jw7LJr7uhBmghKdOUpc9QqFzFQk8Finl6nuLHzBxmaeMasCcSnjA1x68f08ZcfMRmW R54cNWYfmSkYBXbAGrwaX37MiNtEroVDFoRhfZgTfo/soGJhBFIfpEuq7MOe0Cq+PGqn mxVUmO7S06OoFK6LeLwaLLRaqIKUHLpX/Eq9DMhylF+bu9I72EOA5QztmguwyvFMZv67 wqi0csiOPRgkGOoJGHDzBYHTf5hqxytiKYmeP10FvwD9B2evW9ENRxtEX0u/2knCVZWh jrgO+P4KrRIXqRqMWSWI1eM/2hC2KXE1LMv1DDpU3c5h0XFNFDiLTeYK7kO26+5Gmw+v HOkQ== 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=lN8sywuQV9rrPuV6+BPQUTe9Pz1aShp5pShrkBzzCGg=; b=gH6LaWD6CKgmszfzZGvzeXHbdFNTuGA0yQgJFJcmAHF1kMsUzf4Lr0asMd/mOyYBfS ZMRjeKKdzCDpqlAVuGg/FmvHauKKPIpbJNtoGhSc2ZZwIsZ3/cQpF0l+gov9ZIap3dw9 avcr5Ex9AoeCMY6VGkvWPmj/OvFMrHz12vXXozehmekZlKzGG5V0tau1GvmkBFV3Dhdx a9N83RCSXN14Sx06o+mjYZRtjcZ73UT+A3U8hP/9skCQis1u0Ncol/2BBOEnu/oGlFXN 0TKPJ8CzN4K5TCKvXc7Gr3C9Gol8N0J7wxSBt/GNifbSnO7Fjao0Wl6wtbLgdMCcFMns JwDw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=nL6tjQo4; 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 w17-20020a056402269100b004663240e1f7si13865558edd.620.2022.11.29.05.43.43; Tue, 29 Nov 2022 05:44:08 -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=@vivo.com header.s=selector2 header.b=nL6tjQo4; 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 S232992AbiK2Nkc (ORCPT + 99 others); Tue, 29 Nov 2022 08:40:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiK2Nka (ORCPT ); Tue, 29 Nov 2022 08:40:30 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2105.outbound.protection.outlook.com [40.107.117.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57B6C5ADCF for ; Tue, 29 Nov 2022 05:40:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SlDTP/bkqmVCO9iI6RdHrfehmsykfpkjVJ1Kv4Q8ILpMNy6juzOLbKHgGkxqsF1VCW7GguaI9i4LvYrgdMp/EhffWfFVmOM+kixoaMe2JWzpkjZF+r6Ex8Cz0Om0NzCT4yCQy/7ApHOGdLbbPlGZmkdIhi104urKsb9nu/FqLJUnKaT8qfgVfGDsAEyUeSvI4J3KZBFYS0x236Xd0s456/3Fp+B0qlLwbDl9Q5VUMv0DgKNulqJVK3Fg61hZWeam03G/g7r/i2tq1eydGO4hhDki6nlPJh44xIVCpNNVRLdlaimUsAUOTi5pxwpWgi6GcO6Enu4O8W/yu4T5r1khEA== 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=lN8sywuQV9rrPuV6+BPQUTe9Pz1aShp5pShrkBzzCGg=; b=Y5/H3BtDjuwPyrjkB1KoT91T+TJQZNzce45VTrQfa50Zp45pOR6Y0C6BBWB3jrrcWnW0B7+s8HRLl2oCFqO/cbNZfvNO7y+w+S8R76Mk5Z8jO8cBOGzrNO9Tx37pRZV2GboMU5bvRGNkyHStTwNe3VOy8Ojnjho0hY1P1EfOMhm071qSZ3CmV115wxJT6MWw3KpqcnFvtdHRt+yTjdvaHIDXPY8ZfVranMquKjjI1v1s8Wxfsa8uOx6/cLHwzuebdBorSsCh/zQqgny52lRY397XI7+e4Z38lQMNFsTp/VbjcnQCNJyZNwjKLWqN3B3PcWEkV37zhvhihxLrabmyOA== 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=lN8sywuQV9rrPuV6+BPQUTe9Pz1aShp5pShrkBzzCGg=; b=nL6tjQo4UijjV536MV+WJZVw2aKRgQ/YYJlkbQbNV6/VJ2QHnECelYpS5ru88+eDrvg7IC9JdPF3oT2frbOuMrTLO14mjiQ30clVoGar+vs22dr1mZG+kkeAL9pIHxlBft44hYDuyfy0HsKG1bdi06qy394JFLcIfkvyzWiZyAbYFfAxs4pKRGUdRSUylVwLHlzyVD5vFcDscCH1totM3+RUEaejMCQdzzYRp1YxHy7px3RBasKX5oTEDyqV4CYiyqeC5r2Ej/jT2pkh5n3DFX/Sa5D5mSldShOP/yeIEYr8EjmfrPG1LQeutz0DUNZ4x5KBpXShzctqEY+U2qQQSQ== 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 TY0PR06MB4984.apcprd06.prod.outlook.com (2603:1096:400:1ac::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 13:40:27 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::ef03:cbfb:f8ef:d88b]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::ef03:cbfb:f8ef:d88b%9]) with mapi id 15.20.5857.023; Tue, 29 Nov 2022 13:40:27 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] f2fs: issue discard when discard_cmd_cnt is not 0 in f2fs_put_super() Date: Tue, 29 Nov 2022 21:40:18 +0800 Message-Id: <20221129134018.34120-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR01CA0171.apcprd01.prod.exchangelabs.com (2603:1096:4:28::27) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB4984:EE_ X-MS-Office365-Filtering-Correlation-Id: b7d7987d-c662-4e02-ac43-08dad20f4627 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KSuJfLH0rwD8LbEPHrZQGumKEAB6gfqMW3SJ9ysLcZ1Dueo6cjbJ9NaycOPQv9Jl0TIIshdFG3Llz6WoiFNkgZ85yg32PXw22cLESvAiXhP7UteZPfVB8HzENejJ8rRhsYQU28+K5VmcjpfhrKIMuMOiMvVv6reDIh1arHTwzIslQG/L7IsBXLa+266OOO8y+CqzhHLZ3MeErp1MLo7Uf5DFEbjFFz64fzhj+Mgkx0fLCIrKwmB9yeAFtIr2AdYnLhNXSZq/5llaPElJuCIUatWgBFYOeI7iJBpgVHzrB6wNpMEKCoq+7NiYPhezuLGhUS3ZWoFq/1wHjWAXLJk0zfyZ8tHPz3mBIhO9KlW+JwOPD7UtFOMhMUylcZq7vQx7nwP25ECXLKYJ+JrRlMAFVDI36fXwAWnX+FTbdhOfGa8jaQLLu1vm9Qta85ph1IJwdVx459Epefn/aw7NtSRbl9BYoR9ORdpV2dDzIh6xaEa07FMrmupGN9l2QFYmZ17dSJjlpsHLHU5pW9+kiiUJMGBxCzCEAZr2dcM9UB9x4+wFtUcYlh131aZFShkvkpk0keSwK7RnOO86NhE+NIVJ+omeHlsoQZg4LtUkLcuRcD581X0axk219sdplDoVh1I8xwV8UBv5loeNvziwp2S+Gs7j0+o+BR3YYcRfAIWohLdYx/xw/De/89somYSx7flV 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:(13230022)(4636009)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199015)(2616005)(2906002)(83380400001)(107886003)(26005)(38100700002)(38350700002)(6486002)(66476007)(8676002)(66946007)(41300700001)(66556008)(36756003)(52116002)(6666004)(478600001)(6506007)(6512007)(186003)(5660300002)(8936002)(1076003)(4326008)(86362001)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HTC+w/Vy2qRyWtzbg9A5QDc7vRzLTDK/cnQtuC6RKEgUSzDlw/LJ8dHMO+VWJPk6Bz+g7YGHbGMTLYfGlyY5gDN4QBwif59iYth4WHP2Xn73Ni0gLe2dy9n8a0/gLWJNF+qoqriHj6X727P0PEdtT/ydjAdlwNOuuj4yyFa/JGWjlr153KgFWR5rSs6IwWzMikB5P2JzKUZelgQDFRxxLJMup6HC6+SrXO0qy+xzfuJqYib8k+xMmMYvqfo76HWowBZTt0X+Y7tAxWZHqza/2j5LWNNZNVqw3ra70Mg+QtwwEgUTw+3n7aF01D9ep3FJdzHbA0t5sKtkFzD1hONf0931TBwtMBwQ7kxCoLDCyISfBBgBgCP9Smakuv4/qY+Y6fFiN52798VCwes2B0RotfLAkeObQiWh5wLbYIK2F6+QjCZs0AeNmQquhUTrqI9bH49laWVaROyNvdi9op5t4bSdmjcaShsvKrdpcD22SGZlSQv6kP2rg8sLgRfMsGsARlsvU5HF0R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q4vglXif+JHZaj X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7d7987d-c662-4e02-ac43-08dad20f4627 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 13:40:27.0943 (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: eplMELSvHTGx3SlLRFv2DNEuBUDpSZn5WxwDcHG9x9JfOHSUar2ncIEK8eBMVDrdTVy6ZVNc8XDxORh8zDkV3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB4984 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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?1750838226191374490?= X-GMAIL-MSGID: =?utf-8?q?1750838226191374490?= No need to call f2fs_issue_discard_timeout() in f2fs_put_super, when no discard command requires issue. Since the caller of f2fs_issue_discard_timeout() usually judges the number of discard commands before using it. Let's move this logic to f2fs_issue_discard_timeout(). By the way, use f2fs_realtime_discard_enable to simplify the code. Signed-off-by: Yangtao Li --- fs/f2fs/segment.c | 6 ++++-- fs/f2fs/super.c | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 9486ca49ecb1..d5f150a08285 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1655,6 +1655,9 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi) struct discard_policy dpolicy; bool dropped; + if (!atomic_read(&dcc->discard_cmd_cnt)) + return false; + __init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT, dcc->discard_granularity); __issue_discard_cmd(sbi, &dpolicy); @@ -2110,8 +2113,7 @@ static void destroy_discard_cmd_control(struct f2fs_sb_info *sbi) * Recovery can cache discard commands, so in error path of * fill_super(), it needs to give a chance to handle them. */ - if (unlikely(atomic_read(&dcc->discard_cmd_cnt))) - f2fs_issue_discard_timeout(sbi); + f2fs_issue_discard_timeout(sbi); kfree(dcc); SM_I(sbi)->dcc_info = NULL; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 79bf1faf4161..71e6b2bea1f4 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1576,8 +1576,7 @@ static void f2fs_put_super(struct super_block *sb) /* be sure to wait for any on-going discard commands */ dropped = f2fs_issue_discard_timeout(sbi); - if ((f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) && - !sbi->discard_blks && !dropped) { + if (f2fs_realtime_discard_enable(sbi) && !sbi->discard_blks && !dropped) { struct cp_control cpc = { .reason = CP_UMOUNT | CP_TRIMMED, }; @@ -2408,8 +2407,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) } else { dcc = SM_I(sbi)->dcc_info; f2fs_stop_discard_thread(sbi); - if (atomic_read(&dcc->discard_cmd_cnt)) - f2fs_issue_discard_timeout(sbi); + f2fs_issue_discard_timeout(sbi); need_restart_discard = true; } }