From patchwork Thu Jan 12 19:14:04 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: 42719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4064175wrt; Thu, 12 Jan 2023 11:29:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVWbb7C+sNNBC5Bjn/35KtAEbHepT5WR1oyEF9GB2hoBWGRxOwpC3QWrueO0L8/eESFOUS X-Received: by 2002:a05:6a20:6730:b0:b6:53cf:8455 with SMTP id q48-20020a056a20673000b000b653cf8455mr7337714pzh.56.1673551781129; Thu, 12 Jan 2023 11:29:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673551781; cv=pass; d=google.com; s=arc-20160816; b=TEbwEQ7ITR0ZeyNPKsm17ytPGtdwycQhko/3i538Bu2BIAqCHlUJX27J1NZpIwFW6n Gci4CrA7FQr+DL2Cvn584qPgnxVcNyBkjwknHYF16pvp7EOLotT66/9k7h1k/f3QLsHs 3DtiYVo35rPd1/iuKxoBl3lN7OPM3mEiTuMX8zQeVv/NlpB07Zyozo6IH557SRPO3/89 Ts/TCIFeW/3B41vQw3VLKbvj/iAUYi7j6VmbJmlW0P83opAvy7QMNYOIDJ/2cz/Q1MH5 DMbxhM0FZboBJqFmM99KL2/XAnO/jPH1rItvGh8qfgfq4dQQrTHrbw5+b/cF5lOrP3IP 31UQ== 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=YSfuVr0ATpMuO4cP1MdBJD2VjwwBoUhd246okOdieSI=; b=oyWyfSOAjixHUZuUe8EOT7AFtkd0YPs+p1zHH5j1T0uEJH6Rg1w93syw3MnHfv9HCr /6d/LGsMmJpE43+AtbRzZQIWHi9nFEJ8BDhMbvr9v3yRB71N8QUfxMC9omFuzrcoFaP+ 41bRxzcqWYDL1NWoCIq8jn9PgJLYn5SfhXgEUlWtticg2CKsdwL4uXwOkDX805DqCeGF +jfb75STk7KicMvjDNLOKMOK80dSkrYa37Z39hNZIrgCcOBc/BGq12ws8R9a63Mnrgl2 Qx6HeDmr90znzeZvfyl8eou8+baPzBi26hH4qoISqhzKB1nnl3m6jbVjsEsrLGYWpz46 KTjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=kotXwY99; 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 12-20020a63104c000000b0044c3ec9ea71si18029888pgq.630.2023.01.12.11.29.28; Thu, 12 Jan 2023 11:29:41 -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=kotXwY99; 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 S234748AbjALTYm (ORCPT + 99 others); Thu, 12 Jan 2023 14:24:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233616AbjALTYP (ORCPT ); Thu, 12 Jan 2023 14:24:15 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2111.outbound.protection.outlook.com [40.107.117.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 982D22BE5 for ; Thu, 12 Jan 2023 11:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RjM7eIJhowpMghuJq/6r6ChFLJwG6vifGP6zSIrtbNrdgVpa/6bWeBx3V66AeEYrTYjjzq+ukSRNp5rOnDh0KTRokj1E3wtYoQJGTfeIrbWmb7L04ZVb4GyeaPe5Mm4RS11YSwpXWI1DX0Np33cmePQSHvBCVYfQkOVl4QyGsYravIu5/R6YgRMqS/n9WFMcQRy5cwClGJs6p2zsXzPgGbC7GKeqWAXN7IvNy8QPdraQ8Fjtl5tLPwpzFsEMjBpQvacugF83DkcD0NosocFB1cShBaDiQi9r+fXTYy9rt7L79+bAggYYmVhBJS9V90W9Dsv+kdd6ZCS6lVAVrDto2w== 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=YSfuVr0ATpMuO4cP1MdBJD2VjwwBoUhd246okOdieSI=; b=hXux5u6DoJIYr+Pb3QZVJ3nrBAijmUWtRT8rW4xCOxG25jdlzzwpKFOtaTMplffgaCa3GOSSDHattwQlarQ4ctBAuG4lwBodNO3nHzFCfIYG75ZUzECI50Gcl5U0keFHa/PVhcM7nkqllwc95b1GBQSBVrJJLuPlBDDVOZUmKznKQycqs3gDyspqYlGpj4AZAWYntfvdb3bd3HY0+uAHWadaxXCQGL2v59RYJ+K2O2094PtSbjU1vcRn44WZ+0hNiPeQs/lOs7546dBQAptkwTmFSnE8r9PB92326d1TMyoSqpfRJwiX2M5kPFyv+KnPhnO6OI7z3/1aPvMNBt9V9A== 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=YSfuVr0ATpMuO4cP1MdBJD2VjwwBoUhd246okOdieSI=; b=kotXwY996bnMFZsDZ3lWRSVtnHEbI1e1jowPIWHQihv0psZbc/0L2wm+fgTIA83kFg2SppZVI5zy75ilTSxeEUn0EMuLK2LfuTUvzo0C1jQZggUuLfMZXj5QBxMvVYumaX/SZxjhv+Bl1//8pePzyHUhNUKWVpQT72jWOyn+poL4mYCea8QshJdaNMU3gyMZptla4T/O9L0RPlc3wS0ojWLJGNjyyZ0DzX8u8OKfSuWf5Hm/RK+kt22GUXTc74kzGD/kUYNL9ke3OtM9BkUOvqo6dCZc/DPN7Ppc4RK8VxYMoF7E/m1bNKKZWrBqdgudxJ4YS7RFMDA2zxOfhIwcAA== 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 SI2PR06MB4202.apcprd06.prod.outlook.com (2603:1096:4:eb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 19:14:14 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Thu, 12 Jan 2023 19:14:14 +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: return true if all cmd were issued or no cmd need to be issued for f2fs_issue_discard_timeout() Date: Fri, 13 Jan 2023 03:14:04 +0800 Message-Id: <20230112191404.59020-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:3:18::21) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4202:EE_ X-MS-Office365-Filtering-Correlation-Id: f12d6343-34da-44d4-0cac-08daf4d13158 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kq5wRH44IIdzETuHe7oOsbve5haX5090U+yVjxjaOedzpx0pQ4ACmhV+vUVi2aOAmMiAGh7ukikBhHhej5Qlm9oj1jA/oy3xEFxCQTQSEAntiSoKw9b21P6K0lCSuV2yAqvLgNqkNPAoid6U/LPkOOnHobvL06b0zM9Po7rw/xZaWg78N8AK2bCKK5KCsEVZ3talvRDqwGtGamyoVI9TZOC35xVPgbgdCelaLHrovZsekYcBOn8U1gP976+TcynU6O8lyG3PaPnSoZ7HCZDWrNmiuhSmsmvfm/R1j6ggpwhKZPfv4FNduX/yXEftYH3G/6rraPIHYp6UNUUhIC2fF3HEHHhBWPNwwTgWG/vw7px585htBaaWEjMvr/Z42gLLYZdhDNbsBQdRRIXu9e8n5vmNByQkKkOslu4mo7CPoK6SvKrDyBrK5tI+Pnr03TKp310z88vj8s8w6V4l5lPaklNT+FDwVIPhGz3THsMSv/huuZFocnA1AxEioSL2mVRmTLmamCKppJu/HPLZEP/FyirMDHX+GAStLOT8YZ4Aq40CL3OtAb8siwr6pP3MzWquAeMmeA59tpDeSaeHosJqh5oTYtrWfUacDXWB1AO7OAdoZUY+hjp2Pv13DFwckzlwh0efi8m6Mt4w4mLHdEs4gHrXcmijjmrPScqhDNJubssM6wGMI1FUmy/JuV9fZj+KtzEQpTVyEOWPRMco+kNSQg== 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)(396003)(346002)(366004)(136003)(376002)(39860400002)(451199015)(2906002)(5660300002)(8936002)(26005)(36756003)(41300700001)(186003)(6512007)(66476007)(66946007)(66556008)(86362001)(4326008)(8676002)(38350700002)(38100700002)(52116002)(107886003)(2616005)(478600001)(6666004)(1076003)(83380400001)(6486002)(6506007)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SbPrbFZmN5c+soJLWk3JlIIBMnmTy7gGYW3reFUwmAA+6jWJ0i025i0dbLpOHp/6WiSV7ZQ81IMAY+1lTaHOhf0uaxjz5tVvh6gZ3aKDRZfvUTMqf4+meyzhirauRllj/fj1wb8r98dDJW7oBOBV75TcXOgnDQGzJ2QDM1nZXOhRrEfVs/eF85BFsQj8XZ47r65GP8X2/w/ZTfRxOk8f8/nwzfFB7OWlZfCSd69a0RSa06zVwdUadZoxMnnqTn68tTfANxSEJlZOrmvTBvJRfoGqr5rfQ9NfRtIlUYJTxt7FR8yW+Nkw0RjTRQuSYPg1paeOg6/WEzO3843uXBhwPo0pgRZ4tyf++/EfjsuHn0L3sW9w7adXlT6DrP2fX8g5UubL2d4BsS2U/Zy8U2uBpM27/rVkNysdXNGQuvtQWBOa15n7e700g521fYOMTvrxh/EQZG7xT4IxPhTz3sJlOGGf2GxyUD+HTbujKAmPDUrS1tD1G6c2IOsfBqiHaAXKB9i8eWWSxvAkecdKThllYy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rossTenant-Network-Message-Id: f12d6343-34da-44d4-0cac-08daf4d13158 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 19:14:14.1730 (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: qqqh7vDs723Wc5VcLuRB2VT6BFgGcgoKYDAtVY44EypBlDDIWyZZpl15CuYpSVtZUNbVE9cldKwi6NlxgS4h5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4202 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?1754846232633166479?= X-GMAIL-MSGID: =?utf-8?q?1754846232633166479?= f2fs_issue_discard_timeout() returns whether discard cmds are dropped, which does not match the meaning of the function. Let's change it to return whether all discard cmd are issued. After commit 4d67490498ac ("f2fs: Don't create discard thread when device doesn't support realtime discard"), f2fs_issue_discard_timeout() is alse called by f2fs_remount(). Since the comments of f2fs_issue_discard_timeout() doesn't make much sense, let's update it. Signed-off-by: Yangtao Li --- fs/f2fs/segment.c | 13 ++++++++++--- fs/f2fs/super.c | 7 +++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index bd1cd98fa6eb..9346209b7c94 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1650,7 +1650,14 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi) } } -/* This comes from f2fs_put_super */ +/** + * f2fs_issue_discard_timeout() - Issue all discard cmd within UMOUNT_DISCARD_TIMEOUT + * @sbi: the f2fs_sb_info data for discard cmd to issue + * + * When UMOUNT_DISCARD_TIMEOUT is exceeded, all remaining discard commands will be dropped + * + * Return true if issued all discard cmd or no discard cmd need issue, otherwise return false. + */ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi) { struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; @@ -1658,7 +1665,7 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi) bool dropped; if (!atomic_read(&dcc->discard_cmd_cnt)) - return false; + return true; __init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT, dcc->discard_granularity); @@ -1669,7 +1676,7 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi) __wait_all_discard_cmd(sbi, NULL); f2fs_bug_on(sbi, atomic_read(&dcc->discard_cmd_cnt)); - return dropped; + return !dropped; } static int issue_discard_thread(void *data) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 5fc83771042d..8f13798058f4 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1546,7 +1546,7 @@ static void f2fs_put_super(struct super_block *sb) { struct f2fs_sb_info *sbi = F2FS_SB(sb); int i; - bool dropped; + bool done; /* unregister procfs/sysfs entries in advance to avoid race case */ f2fs_unregister_sysfs(sbi); @@ -1576,9 +1576,8 @@ 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_realtime_discard_enable(sbi) && !sbi->discard_blks && !dropped) { + done = f2fs_issue_discard_timeout(sbi); + if (f2fs_realtime_discard_enable(sbi) && !sbi->discard_blks && done) { struct cp_control cpc = { .reason = CP_UMOUNT | CP_TRIMMED, };