From patchwork Tue Nov 29 04:15:23 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: 27074 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp122500wrr; Mon, 28 Nov 2022 20:27:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BEA0UwSWmCizqaFAbDAUHRXr0o2jGfCMgtRxhop/tlluHlFWFk2CJasx2tVBbKCuos2KG X-Received: by 2002:a05:6402:5412:b0:460:e19c:15a3 with SMTP id ev18-20020a056402541200b00460e19c15a3mr33105001edb.252.1669696029601; Mon, 28 Nov 2022 20:27:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669696029; cv=pass; d=google.com; s=arc-20160816; b=NG2JtIKV3iEJuVTSC/rXAF/BtMSHFUlAD9ldSMMdexlagM6WnK/6XK3HAreq7TosJs klG/L0woP+FiNnE5tmSBOmoPYT5rUVlaHqD4y5zY38Irl6QiEVnbIau8NEjgaHFfhHsz kp5qEACRshGt5aTOS85gkhzdoly5jAY9VQMZ0z7dVO528357xq6ROWYR0Ek42hmj+DvL yiUfXRlQvm/XufeRwfAX7CLPqBojEgf4Nww8KWJaA9WUFTT7Az1UbPZSWUyF0AECbzlL LeXP/fE12praCLri8DSPsRkIiMMFUm9tFBKwpdV3EkQ6p61qb+i4zHXXWa1XK4w8VCHl OJcA== 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=VkjS6ES/OUvm2rR7karX8J46E8nxqSPRoAmfZ0+wbAw=; b=vU4K8HxJimBCIN0cLm5ioxIbU9lYuGj8i+TKbXvYSmdWZUAFhpXINgHgFH1wfmiILo qhuNoIkJ+0c4oM3rJ+73S84Geyv17BEskR6amg6O6F34ympm+8o/5H2oxX09vs4P0nyN /gD3a863IdLLdjewPf3aio6zfJKsg1qRh0+RUwfbGwnG5iLWCak2jkDxibDoAgLq+8r+ dXOhiefKlqy6P9wZe6uA7aJfN041Ye2Ri8UvPwM72FDnntP4tZ9GXFDM/HDbBf44ODTT XBu5B5yhsiG8SyivLJP/dKnboYNfAGSqCY1NXRSB8orwwpWvtkpjpiltZ+nqkBO86BfA kGVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=MkQVjHmw; 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 jg8-20020a170907970800b0078dcddc1b8csi12139530ejc.788.2022.11.28.20.26.46; Mon, 28 Nov 2022 20:27:09 -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=MkQVjHmw; 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 S235584AbiK2EPv (ORCPT + 99 others); Mon, 28 Nov 2022 23:15:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235156AbiK2EPl (ORCPT ); Mon, 28 Nov 2022 23:15:41 -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 87BEF4D5FE for ; Mon, 28 Nov 2022 20:15:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYVjGj0A+zP9Hpr0IHtX4Yj8J4FZ1t1XS+F1Y5ogPdspUJTGQPuixl3gLA+vtG/O4HpwBCF2uXKMj3TciV4ZSsLPIFXByfmg1tAFBFeFjLFYhn0NkklLeHANmY+rvkKoD3Z0ma/Mh0KUHhIj5VSn9oqe5p6Z4JJ1zHtmIjH/nyrW1aweWK8HYFDrG7FNTQleuMXMsZBDXev2J6SbQw4vZoWagHmvfpaaROASWcG8/9H/6xWjNbZnbB3sBQW+gTD0wBj0Md/yDzEA5JjiswoetdnHSXgCqb6Z9ltsTiqJQj5JoEcBh/nTSXeGs6sIea5s1kHKpuZijUngDTmyZJHbaA== 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=VkjS6ES/OUvm2rR7karX8J46E8nxqSPRoAmfZ0+wbAw=; b=i6iFGLHkTrZf8t2WTAsnBsiTh0lk76wqyGhu+FuuiCNyGjH/e+bhY+vGF3yrh2hJyK3KhL89Rv5YZH/ABtoyo8jyeVlLx8U1YM8QYrBynDqkJ92pYEY7ax9hWBstp2+f7mi2pyqEDEk79m8fJgk0wFaP6vVGAc+15tl8GOUXM55+6IqCLUm74+REefrPDTISnIDjhA/53NfxK5GbVfGPZ2rgYNpd5FdgJ3PyHbavfHmqW8WboVK2An3L8KBx+ASN4L8gxM3GIbJZ4EuubhC+d9ZITSrjRvRKGiU2DzEelZMO9fnzaBjakwW2HFAG5ggGkrMGiGAFPZRtcjn168CMDg== 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=VkjS6ES/OUvm2rR7karX8J46E8nxqSPRoAmfZ0+wbAw=; b=MkQVjHmwaxcpw+k+ftL4Q1JjlWkcXDyMR48Xi72427PBVICp3yYg1xzERUvROZSBzMSYxUTFANj6FYsiAo4/mptrWtKwcoULpBJ0CpZA/iFqbjHmG8a2B2nTtexULRgfFMd6NB7yNHLQfEtNWBZEWFv1RSMffML6z/+Z4KJoJi8rO7fNvqcU+Uca0U2x9sPWTn9SSKILMpqDzTwgC6w4dMKPiSZdMnUGZvYf5pf68GYjjhhhO79wZPZSb3Y0o8nirIm8o5dCyHuzslJtRFgSYF/sEXhMJQFpNeIwv15S6TCMvurWXKd6V2wq2uWrcyxMbrWpuVba35Pt9W4FdTwa9w== 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 TY0PR06MB5657.apcprd06.prod.outlook.com (2603:1096:400:277::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 04:15:37 +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 04:15:37 +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 1/2] f2fs: fix some format WARNING in debug.c and sysfs.c Date: Tue, 29 Nov 2022 12:15:23 +0800 Message-Id: <20221129041524.81235-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI2PR01CA0045.apcprd01.prod.exchangelabs.com (2603:1096:4:193::19) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5657:EE_ X-MS-Office365-Filtering-Correlation-Id: ee1abe3a-a49b-403d-5335-08dad1c05dfc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ERtfGVaSvXC4c+/7D7iyMLsgJ8GoIcEnhGFdg1cw5jkdf67FGZt4doBQh6hULzrqIk2UVYHU4BuXJNmb1e1i7/Oo8IC//gft3+h7kpzSj2KuepL783MDZFLn8mG1o2BYnAJdgK2Zlz83bbr/Y0Wxp+QqD/At7MLXUvVOU2CYQVGbllizLyh4MHiBsFbcnYf2A77ZvkYF5fewXlf2UB0iGpAp9S815blfYxpGv7jjiWrnR9rixHiSDwUoOG/OJDzj6sYtqe8noX5yuM9B5DEp7shmTcYfGpSIDAxL4hQJ0mJOQedqE36X2PEVfFhk42XRr6f+BPf2PaQQppTsV4zAocw+BgSZoth+CGGgVZUczK3eIu6PYEXA7Ib55WmEzQCh0MVeE4I2yWKzULXeRoRvgCZkg9I2FUWxBQkQY2ekGKogZ++pUUrHkJ5K2OjkFDmVd0B532FpMY+o4YPmxFsnxsTCKZFS46ViQCNX57702kuiI6QRLYe5iKNaGkf7RYq+eHmfHXhUukTp+YoYbA3+nkWV5kCR52m05LeV/JK3NwO/QqvWsgUXQA8efZNjNF/bsHAv39sstkq5ccxrtKnua14ykGtncKQM4a13MSLW+qMdlN6DtP5DhEpNKYvHPcUpvUfM06xfPvf2q7za+Rf7eAwrhyF9jJT2Lp3lLhQOLASnTKtHhxXj25aLoCfKoTpt 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)(136003)(39860400002)(366004)(346002)(396003)(451199015)(2906002)(41300700001)(66556008)(66946007)(66476007)(8676002)(36756003)(4326008)(316002)(186003)(8936002)(45080400002)(5660300002)(6512007)(26005)(86362001)(478600001)(107886003)(6666004)(6486002)(6506007)(52116002)(2616005)(1076003)(38350700002)(83380400001)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: urowANbL9KSd1Dhbe2niM/wMeeCF0wWktToqKV7+bYY0V10HRm+qWxF3YBnrfrX1RKBibthpT9iKVeg0Afh8Oux3tCSLtVrvjAqyd4I37khdYN8Sm9aqvvBHC2nvQG1iM1O4d/eid5/pS968VYanvqHZY8QB5cDgL3PVyQQ+FPYyND+JJgMAaPtXrj7GpVtky4oWOobPMIhpysYzk4EpyTitbWht0/QYVcILXiVaciITvQBT8mjtDZ+/pA3tAMch+ZZaGn2fLIH3yS81cCyEBFruUQ6hdSJUr5Mb325zVj/B1A9F6ZE/XxMmdeGhFlq+oFB6yAqkXR9bwuBabgTkgrwwG7RLPDa3yj76bnX0Vymrb/AINRWS0aJ4Yzy/zwHdyjkF6IdI1B/5FEFjvrCgZKQrvFJ6X40COLbs/jSltm62rLrBAl6mrZ/c+GZKWpeWEBYZqdE+56xlSzO20p6//RyCatqJJupoDtRnxrLzwa9p12KW5Mn94A5scc/ACGD+aGwbNv3TQlvrapLviz4zaGpN+V+7n+pNX1ETRi3f3bwxsyTZpOopc0CyLkSBVqKQQelY3QwbaMukQ4sFOZioj1pXD5krLXpVX0xudXvwKHsf5BP3pRfjAOmPt9RiOKeUerTE5HnGdtVtZ+tGZDB4R/pX0gMRv2oMyaE6KyGYPF9VWv3CM4kyi7gsAiYDkCahouUG7eOR+iQVlaJb+ThUD7oV2GvMbDNB91Q84WXq6wX2qrL/FQUVx9vfZFNu9+wuCQ+K5G0tUOL0uZ+Wj65Je9Gjv2sqnW0+vYKp/BS9iGIlx6qL5lNI++lnixItFEC3XfXoK5h/tSlwKUZxjhDTiRv8qmwG/l/xoy2W7gWFGqLuPfILhWohyn9MU/dYxWQBMfV1Qiw92zclPujaGQzIXajZEj97VUGc+UTAHEfymVoSpEhLBKm1S9BXTzGZ1CpXl5GDiIl49LyqEAyX42YthO5Xp55KP3qHRtK8NukzBbu/W/fhdgleUe1M5v4dUdz4muiZv9GhzMSYHAWXe0/fQiHqJckiSNMXTiXS1SGddztVGKHK5tmOcA8QKjz1e3YARY+OOGHquoUJa0OHkrWIEjXMBPMnm5Xy5FRb3Zg8kdEN96hUGFv8hhohOzuGQjbSt6sZ4xUSr4Zk46w9AtOxjClwNI4cu+Zn33bxej+O3siGb2XLaFKG0HSgnvlX3W7mgE41wncDU2DT7+ImPmA8noPFSb2Ia9X1hHMNT7ukRbpFEsEboBbtc9n/0LR9FY37PU77hqJdQeRG5NZaGicUwtd0cQPOSSKBnlycc3gnBDd7a+E12CDLUfnKvql2OxFblSxbgOaqzpKTiAvMO+A/EdfH3FL3AVecg+Nee0EwJf7kQfAY6ehq5mfYDZdZsAI2DjZZvvRsEg49fYXNxcy4rQOiBdEor/SHDyNkiW74Ne+Bmpdvwxpjgql/xCZgj44pLvrnwwDuzKkx4J9OPtX6UIt3Qi1FPD/0sePRLfO1EhbAzHruAu3BFnzketFpBWn2B/NHkPYjRV28a3a5c1vFfw8DfQigDOLgAcQwtSdV0sjKfH3mrL+qheU0+ZTpoqcS X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee1abe3a-a49b-403d-5335-08dad1c05dfc X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 04:15:36.8183 (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: EMgb40yo2mBWq+XFie5PAM0foDTfrzyOWIdY4M1bevTNH/Ez0xEH5+Psfruku+u88KQ5Zod5hH5tOwPckONaOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5657 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?1750803184017079686?= X-GMAIL-MSGID: =?utf-8?q?1750803184017079686?= To fix: WARNING: function definition argument 'struct f2fs_attr *' should also have an identifier name + ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *); WARNING: return sysfs_emit(...) formats should include a terminating newline + return sysfs_emit(buf, "(none)"); WARNING: Prefer 'unsigned int' to bare use of 'unsigned' + unsigned npages = NODE_MAPPING(sbi)->nrpages; WARNING: Missing a blank line after declarations + unsigned npages = COMPRESS_MAPPING(sbi)->nrpages; + si->page_mem += (unsigned long long)npages << PAGE_SHIFT; WARNING: quoted string split across lines + seq_printf(s, "CP merge (Queued: %4d, Issued: %4d, Total: %4d, " + "Cur time: %4d(ms), Peak time: %4d(ms))\n", Signed-off-by: Yangtao Li --- fs/f2fs/debug.c | 45 +++++++++++++++++++++++---------------------- fs/f2fs/sysfs.c | 10 +++++----- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index a216dcdf6941..733b1bd37404 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -301,18 +301,19 @@ static void update_mem_info(struct f2fs_sb_info *sbi) si->page_mem = 0; if (sbi->node_inode) { - unsigned npages = NODE_MAPPING(sbi)->nrpages; + unsigned long npages = NODE_MAPPING(sbi)->nrpages; si->page_mem += (unsigned long long)npages << PAGE_SHIFT; } if (sbi->meta_inode) { - unsigned npages = META_MAPPING(sbi)->nrpages; + unsigned long npages = META_MAPPING(sbi)->nrpages; si->page_mem += (unsigned long long)npages << PAGE_SHIFT; } #ifdef CONFIG_F2FS_FS_COMPRESSION if (sbi->compress_inode) { - unsigned npages = COMPRESS_MAPPING(sbi)->nrpages; + unsigned long npages = COMPRESS_MAPPING(sbi)->nrpages; + si->page_mem += (unsigned long long)npages << PAGE_SHIFT; } #endif @@ -460,28 +461,28 @@ static int stat_show(struct seq_file *s, void *v) si->meta_count[META_NAT]); seq_printf(s, " - ssa blocks : %u\n", si->meta_count[META_SSA]); - seq_printf(s, "CP merge (Queued: %4d, Issued: %4d, Total: %4d, " - "Cur time: %4d(ms), Peak time: %4d(ms))\n", - si->nr_queued_ckpt, si->nr_issued_ckpt, - si->nr_total_ckpt, si->cur_ckpt_time, - si->peak_ckpt_time); + seq_puts(s, "CP merge:\n"); + seq_printf(s, " - Queued : %4d\n", si->nr_queued_ckpt); + seq_printf(s, " - Issued : %4d\n", si->nr_issued_ckpt); + seq_printf(s, " - Total : %4d\n", si->nr_total_ckpt); + seq_printf(s, " - Cur time : %4d(ms)\n", si->cur_ckpt_time); + seq_printf(s, " - Peak time : %4d(ms)\n", si->peak_ckpt_time); seq_printf(s, "GC calls: %d (BG: %d)\n", si->call_count, si->bg_gc); seq_printf(s, " - data segments : %d (%d)\n", si->data_segs, si->bg_data_segs); seq_printf(s, " - node segments : %d (%d)\n", si->node_segs, si->bg_node_segs); - seq_printf(s, " - Reclaimed segs : Normal (%d), Idle CB (%d), " - "Idle Greedy (%d), Idle AT (%d), " - "Urgent High (%d), Urgent Mid (%d), " - "Urgent Low (%d)\n", - si->sbi->gc_reclaimed_segs[GC_NORMAL], - si->sbi->gc_reclaimed_segs[GC_IDLE_CB], - si->sbi->gc_reclaimed_segs[GC_IDLE_GREEDY], - si->sbi->gc_reclaimed_segs[GC_IDLE_AT], - si->sbi->gc_reclaimed_segs[GC_URGENT_HIGH], - si->sbi->gc_reclaimed_segs[GC_URGENT_MID], - si->sbi->gc_reclaimed_segs[GC_URGENT_LOW]); + seq_puts(s, " - Reclaimed segs :\n"); + seq_printf(s, " - Normal : %d\n", si->sbi->gc_reclaimed_segs[GC_NORMAL]); + seq_printf(s, " - Idle CB : %d\n", si->sbi->gc_reclaimed_segs[GC_IDLE_CB]); + seq_printf(s, " - Idle Greedy : %d\n", + si->sbi->gc_reclaimed_segs[GC_IDLE_GREEDY]); + seq_printf(s, " - Idle AT : %d\n", si->sbi->gc_reclaimed_segs[GC_IDLE_AT]); + seq_printf(s, " - Urgent High : %d\n", + si->sbi->gc_reclaimed_segs[GC_URGENT_HIGH]); + seq_printf(s, " - Urgent Mid : %d\n", si->sbi->gc_reclaimed_segs[GC_URGENT_MID]); + seq_printf(s, " - Urgent Low : %d\n", si->sbi->gc_reclaimed_segs[GC_URGENT_LOW]); seq_printf(s, "Try to move %d blocks (BG: %d)\n", si->tot_blks, si->bg_data_blks + si->bg_node_blks); seq_printf(s, " - data blocks : %d (%d)\n", si->data_blks, @@ -505,11 +506,11 @@ static int stat_show(struct seq_file *s, void *v) si->nr_dio_read, si->nr_dio_write); seq_printf(s, " - IO_R (Data: %4d, Node: %4d, Meta: %4d\n", si->nr_rd_data, si->nr_rd_node, si->nr_rd_meta); - seq_printf(s, " - IO_W (CP: %4d, Data: %4d, Flush: (%4d %4d %4d), " - "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n", + seq_printf(s, " - IO_W (CP: %4d, Data: %4d, Flush: (%4d %4d %4d), ", si->nr_wb_cp_data, si->nr_wb_data, si->nr_flushing, si->nr_flushed, - si->flush_list_empty, + si->flush_list_empty); + seq_printf(s, "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n", si->nr_discarding, si->nr_discarded, si->nr_discard_cmd, si->undiscard_blks); seq_printf(s, " - atomic IO: %4d (Max. %4d)\n", diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index a4745d596310..024346f0e9ce 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -53,9 +53,9 @@ static const char *gc_mode_names[MAX_GC_MODE] = { struct f2fs_attr { struct attribute attr; - ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *); - ssize_t (*store)(struct f2fs_attr *, struct f2fs_sb_info *, - const char *, size_t); + ssize_t (*show)(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf); + ssize_t (*store)(struct f2fs_attr *a, struct f2fs_sb_info *sbi, + const char *buf, size_t len); int struct_type; int offset; int id; @@ -232,13 +232,13 @@ static ssize_t encoding_show(struct f2fs_attr *a, (sb->s_encoding->version >> 8) & 0xff, sb->s_encoding->version & 0xff); #endif - return sysfs_emit(buf, "(none)"); + return sysfs_emit(buf, "(none)\n"); } static ssize_t mounted_time_sec_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { - return sysfs_emit(buf, "%llu", SIT_I(sbi)->mounted_time); + return sysfs_emit(buf, "%llu\n", SIT_I(sbi)->mounted_time); } #ifdef CONFIG_F2FS_STAT_FS From patchwork Tue Nov 29 04:15:24 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: 27075 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp122584wrr; Mon, 28 Nov 2022 20:27:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf67VqjgfJEyGxtq0jJROcbl2+ebCACmtcc5KHQUEfhLqmjmGn1SpORFGLH3GxYHDc5RKIo0 X-Received: by 2002:a17:907:8749:b0:7c0:7c6c:d484 with SMTP id qo9-20020a170907874900b007c07c6cd484mr5008034ejc.752.1669696047489; Mon, 28 Nov 2022 20:27:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669696047; cv=pass; d=google.com; s=arc-20160816; b=EkFFalXtUeaz2j1PVRlpNVug8qtO+hkupFYr3ma9cCyr+RXrmNafq+1ImnLgPxK+0B qdAonTA/FEBnCYDlfs2UqgHmmqG7gZJIiq7T5vr0ALEckesa9UUd9EuV+aF87aY+u+E9 nt6trhF74lcLBK8oD5GA8VecWJGzpD14yCjAFFLQN8A8ekTjV7bZ2Kbq05b+vxHtZSiQ 7U3q9mW77jGsUPy63hYA8Mt8IRRoBfDhgiyxzccPn0UGDaWzSCMO480ZT+0ADUwgjC0P 5P201HIDX0TyKWHo3PFjdFQ5PKgxJgsvs7ZHn44SskU6WBVJLJKM45pdh30uJaLPNKGN vQCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YamOh4SEsO4oRecUplCdHJK0jSGNqylVeVtmwLy33xg=; b=UY4cvgKPIx42YXl06U+i7gqDR1PJYPwIUWvZRCWKBes2+adsKiUP8dyTOHX9EpER6U xF/98azLDqZ5EWuNWHz9ZF+rz6dwH9x5eYyMa+RfSN2PGYgcs6mMoV6WvtAFG/4fRNSt QiwltllDhV7sveUEG74rK/ejfbwIUvwzgprS0uu3veJv8FnVZ+T07zd3ZXOfwGlP46NG y8/Oo8YMJO6qNbsGFjfShLKy+AyJK6BJ+jL/KYb5hOXP2b+Yhxb+lAjX/TAhezGiGQoy U26iF3ReJuS+NgxHH/VF4mnThYTczbTKpQdCgRynCyCRkSJF4W+VXd7GnnmE5Dir2ZYs tbBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=l8gTuznX; 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 s16-20020a056402165000b0046b3408c731si3375324edx.143.2022.11.28.20.27.04; Mon, 28 Nov 2022 20:27:27 -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=l8gTuznX; 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 S235593AbiK2EP5 (ORCPT + 99 others); Mon, 28 Nov 2022 23:15:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235259AbiK2EPm (ORCPT ); Mon, 28 Nov 2022 23:15:42 -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 58BBD4EC11 for ; Mon, 28 Nov 2022 20:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVY57Hzp5LnCrjtk9uxqyVBOEOiZWoN8iPs2dbzmHHbNRA3Ko88E+LwlnQhAAFX9JviNYKBAQ6qpfAxKXZvGebh+K5z/IpVQf4DoD3kZxPz7akScGK2BM4MTyIP1ZjZ3KI2J9/Zqk9kqBAbqXSRP/uWF3wx56sQWcYbf5m8rsEPKkMzGAYUOWCrjL+Q34E/57PH5u4g8H5TYImOMcrRkxM+7pTS8qASH2x2JNJFgJdq9RwrScbdcYIMBFu8vk2xMZ1JMPhBIJBlFtP0Ba57SFynBY4eWrMdkwqnpOghO8Jo5d6+jxFRmKm5DcxufTUDeFup3120UWTgbGlll3pk/AA== 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=YamOh4SEsO4oRecUplCdHJK0jSGNqylVeVtmwLy33xg=; b=Xr0i8dTI5aYoz4oBvs1yocPncXCh1zrcbEqmtg/3tkcQ+EyAa4sjQnkkN1CJGkBJCyPfpu0OBnM2TUkKCcK98UFFJBqvrE89Ibn2j0GU7tn0MFg+hB/Rt+E4zOxuF99CDMsIZ+BIPOP3nu9K8M/AZR/dSmdX0BFNFxZWAVtoBrfpzCDKxexoChl/pbHSFE93N6zCUTpEQGkeoGVjTufxwNa8qVXAxWoLh89/DfNIvA0329batHD5e6opwlT+H6f1t8sh/GHym1DlzAa12AkWTJFl9Lve8+1Mg/x64wfCKXxamYrnARb6c0v76FRgacjT34sXgc3R/KQjmaH3Wj/cnw== 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=YamOh4SEsO4oRecUplCdHJK0jSGNqylVeVtmwLy33xg=; b=l8gTuznXNWP68hICKpKTeSlczYIt/7oBc13UfYfOU6aDX8I1qmcPbPQP8UPz0bPWU4StnzXayC3txd7VFdNRA7Z14JPL3u4Dxk1pBKmFtmXFiJeGXW9Pu1gbuV7Y+L1EfLgq4pvqnWAgboULaC6yeRRupMpZVZkF00I1Y95LbRFtPbH45Ismg4iX6WCZBS67edSZFJ45UxS7WHPFOhnIFV33ljhxs1Y6BJCGGtiRBCh0gYaZFBoKyLSmKHzUyG5eVFucwSVwp9DCzh5Q0tHhOfcotWn/D3505YQJRu8oHNrC1hcKmizqHhZytRG6GHAeTzUEOJlpbHJiuZIqwa04lw== 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 TY0PR06MB5657.apcprd06.prod.outlook.com (2603:1096:400:277::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 04:15:39 +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 04:15:39 +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 2/2] f2fs: add support for counting the average time of submit discard cmd Date: Tue, 29 Nov 2022 12:15:24 +0800 Message-Id: <20221129041524.81235-2-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221129041524.81235-1-frank.li@vivo.com> References: <20221129041524.81235-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR01CA0045.apcprd01.prod.exchangelabs.com (2603:1096:4:193::19) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5657:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c2bfb4e-1bc7-4c11-ba0a-08dad1c05f96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hv19nD6dd1HNvgRH8odvBoZIn/gVB6cov8WYsBSndZ23xNu3biW+2nqKu9PVNRUZMHS5Z0kewX96w6dRijIdLiem0mswD93P0CbAWTF3nFvAQ/vthLGmX9IGYBMA0j2BImDAy9yV4E0CQuS1ghSxkIAu8jAWBP0M0OnGKxsEFV8EFb/EsZfRzNo6drh3fxxHyzf+0bqaun1zG7TI4il0MRGIeYBscBeh9LY46UmVWlN7u/jnTraRVFbqpXqNNKtHS1LKLSYyolVe+XCPbJ+zznEf3iOHcH4QhLNQMREFiJjGjMAJLUd9/qo5yTcGjd3dpDgMWI1zIfWUnhkJlGpjjNJogGATeqX+kx+xALUvKknkt5t7nDHyClGswWbzqt/A8kkfJURdfkP3D1BTZb3EyhfZObVELPsxbZ0wbvAJsIijRK2WJtYoEMn35OaKgbHMLQw1m82ZXeD207h++6FQjtA+LuhT1dGpknhBoFq7AqOiziN5BSA2dxPOCkC3AwRiJuZbia1o+sCkKELG3FKQ5IvDHCPaOTyttOj/FuzKtbPaw/YcNdXTyA5RK/FMtpuSEzhX/KvfURBJhpd1+wP1JyghXn+/GLAs6EGU1iwY1DZpNBN1Wir2izaVjYp3moiB+UZaAXYNjVdf9Fpz3fUEsvm/3AvsiMPbH1Q0ebsaYQqMLEq9EawI/DGPingWe1Cf 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)(136003)(39860400002)(366004)(346002)(396003)(451199015)(2906002)(41300700001)(66556008)(66946007)(66476007)(8676002)(36756003)(4326008)(316002)(186003)(8936002)(5660300002)(6512007)(26005)(86362001)(478600001)(107886003)(6666004)(6486002)(6506007)(52116002)(2616005)(1076003)(38350700002)(83380400001)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EWGhgx80c5pCH7zxTggscB79d6tIX7vkNzBIV/JbKyfc3miFFbEI7F7o0A+PKfgWEzMovnr0hhTqGavwLvea5pMY3WqR4eiyApwMR+krDQKjIiTMqDLH/zFfUMdMBOrdNAj3JswWOAVkoQbzcVxIZZUQ25qvh5GI8J6lXsPMLefX0xTSm+WaWgdS32aFeqsiP9iY8nd5B9T/k/BxTfNkoYUaqx9Uq7CvKWLEPaeySC8JIgPAVCH3A0VGSwMkGuQBfK4Ahih2ZenJ0hGF1KpWVcKSATV8vPth5Uc9A03lMnVudn0S4NhMfV3jdO44tBDa8fcgEMgjCUORyaKgrLkcU5X4y2DLTTnkp6CNg9ggvGFm24VOFN0JGvPuWSJwnlWLUtIjNEf/8T47qDP5lnH2qAPO5kGYkOsc7jxGS47DughKrsNkNAvV7h79vxpkWlmhtFEH6sYQFGF8vOPqRUE/20mq8rgdW1GdJuegzs45LMmr5i0SKwZwKud0kADRKw00aJ/V2keZKzemWkJAapf2o7mc5pctHpcRYt0adcUiuP2udXsb1twDzk5onetPfzMSBcGAcInfSLLP9SmLPj+q7KDL95iKztgP3hD8xR+BEKkbN2JFFrlF8Wi9znKYFLC/ObrrtcVNNNzmc3RfsTlAe5cdS9bOITHblsApk/STqwydn6snIFrps8twTiE9kAUChsxtpmHnMxFVjIpYRhEJVuTklpMJpcWXMkUYL9P3AYcXfhMhE5hYm3/2m1NkrJGOYed44PaP0GhUVTQfJ8Nrf18WdaPaHGkDZbXqoNEZWVHKnCj0fnyTHZbtQMS5jVkD/p0+cgJjqPampw8o7LttrhqzvC2LWX8+RKbCBZonpYswY589AVRa3BPVy/v5S4eLDvqTkjQM2RIF5zzQA1hfd1JiOZA19t2Jvmfzxrs3n1jwEWOJwHRfhPgfZIod8nK8girHY/JcekyiYVFR9JPINHCJF5H2p6qMTByI6QxupbFNlT4f70xNybXSaxlhTqg84GkbWoYLtLE0Sw5q/xet38soZfs5AIotZNsYxGmJnzoz08mGzZivCUkHm1asLA+UC7EH+73bspx9d3rydOgHDieuTtaxcVMMakG7ArO5s9yJpAr32neJcCD9crtd/Dc4XmHMai7rPnbSfZTtUlKnP/9tG+1i3Cr17gR5OUT4puKXsoDKzAe90EBYywBf2+SZvME0afI3D19dnsknriQ514+G7Hbl1dkXZfUruiNncPbVmxI5VYnEdtiwj1AO/6QCX/EkWWTESWpLLDUvg55REsH3N07dLN6xfTlMqSsFEcdx6dCTNZD2PzHA40TzmTwlXagYNV+vJ0pG4RuFACjulc873mgDZEio3z3S57nZvyVz1n5ttVuQ/vLe+1SQ9gdiGiH3bRmtVmLF5kcv5s2QlayDLmS7Jap/FEb7ibzcfFNk+1hOOFCFAso8ktrAXVsszfszDsNpbjPx0f1StILm2bm5zIwLnzzMdnD9nhOg0hxrSsjtKs2GPlrZHvoJOqdkIqkGGf2OCxE/r2CSVLsSWiVDcTa29WaNVKA4zYLA5XK0JmPTVnNZVHanWvhv5/2A X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c2bfb4e-1bc7-4c11-ba0a-08dad1c05f96 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 04:15:39.5079 (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: 2FCirnqLUOFjPlsscw1iVbEI+DitCbU1Vkk424w5uXOXERBr3NwsdmrafhPU5miSnODJ+PwmafTEzof6Gb3NPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5657 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?1750803202396779599?= X-GMAIL-MSGID: =?utf-8?q?1750803202396779599?= This patch adds support for counting the average time of submit discard command, and we can see its value in debugfs. Signed-off-by: Yangtao Li --- fs/f2fs/debug.c | 7 +++++-- fs/f2fs/f2fs.h | 5 +++++ fs/f2fs/segment.c | 18 ++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 733b1bd37404..eed3edfc5faf 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -109,6 +109,9 @@ static void update_general_status(struct f2fs_sb_info *sbi) llist_empty(&SM_I(sbi)->fcc_info->issue_list); } if (SM_I(sbi)->dcc_info) { + struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; + + si->discard_avg = dcc->discard_time_avg; si->nr_discarded = atomic_read(&SM_I(sbi)->dcc_info->issued_discard); si->nr_discarding = @@ -510,8 +513,8 @@ static int stat_show(struct seq_file *s, void *v) si->nr_wb_cp_data, si->nr_wb_data, si->nr_flushing, si->nr_flushed, si->flush_list_empty); - seq_printf(s, "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n", - si->nr_discarding, si->nr_discarded, + seq_printf(s, "Discard: (%4d %4d, avg:%4lldns)) cmd: %4d undiscard:%4u\n", + si->nr_discarding, si->nr_discarded, ktime_to_us(si->discard_avg), si->nr_discard_cmd, si->undiscard_blks); seq_printf(s, " - atomic IO: %4d (Max. %4d)\n", si->aw_cnt, si->max_aw_cnt); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index eb8c27c4e5fc..5a99759d10ac 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -370,6 +370,8 @@ struct discard_cmd { int error; /* bio error */ spinlock_t lock; /* for state/bio_ref updating */ unsigned short bio_ref; /* bio reference count */ + struct discard_cmd_control *dcc; /* global discard cmd control */ + ktime_t submit_start; /* submit start time */ }; enum { @@ -414,6 +416,8 @@ struct discard_cmd_control { unsigned int max_ordered_discard; /* maximum discard granularity issued by lba order */ unsigned int undiscard_blks; /* # of undiscard blocks */ unsigned int next_pos; /* next discard position */ + spinlock_t discard_time_lock; /* for discard time statistics */ + ktime_t discard_time_avg; /* issued discard cmd avg time */ atomic_t issued_discard; /* # of issued discard */ atomic_t queued_discard; /* # of queued discard */ atomic_t discard_cmd_cnt; /* # of cached cmd count */ @@ -3882,6 +3886,7 @@ struct f2fs_stat_info { int nr_dio_read, nr_dio_write; unsigned int io_skip_bggc, other_skip_bggc; int nr_flushing, nr_flushed, flush_list_empty; + ktime_t discard_avg; int nr_discarding, nr_discarded; int nr_discard_cmd; unsigned int undiscard_blks; diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 9486ca49ecb1..bc96b1afb308 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -931,6 +931,7 @@ static struct discard_cmd *__create_discard_cmd(struct f2fs_sb_info *sbi, list_add_tail(&dc->list, pend_list); spin_lock_init(&dc->lock); dc->bio_ref = 0; + dc->dcc = dcc; atomic_inc(&dcc->discard_cmd_cnt); dcc->undiscard_blks += len; @@ -1000,9 +1001,13 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, static void f2fs_submit_discard_endio(struct bio *bio) { struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private; + struct discard_cmd_control *dcc = dc->dcc; unsigned long flags; + ktime_t submit_time; + int nr_discarded; spin_lock_irqsave(&dc->lock, flags); + submit_time = ktime_sub(ktime_get(), dc->submit_start); if (!dc->error) dc->error = blk_status_to_errno(bio->bi_status); dc->bio_ref--; @@ -1012,6 +1017,14 @@ static void f2fs_submit_discard_endio(struct bio *bio) } spin_unlock_irqrestore(&dc->lock, flags); bio_put(bio); + + spin_lock_irqsave(&dcc->discard_time_lock, flags); + nr_discarded = atomic_read(&dcc->issued_discard); + dcc->discard_time_avg = div_u64(ktime_add(nr_discarded * dcc->discard_time_avg, + submit_time), + nr_discarded + 1); + atomic_inc(&dcc->issued_discard); + spin_unlock_irqrestore(&dcc->discard_time_lock, flags); } static void __check_sit_bitmap(struct f2fs_sb_info *sbi, @@ -1160,6 +1173,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, * right away */ spin_lock_irqsave(&dc->lock, flags); + dc->submit_start = ktime_get(); if (last) dc->state = D_SUBMIT; else @@ -1179,8 +1193,6 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, bio->bi_opf |= flag; submit_bio(bio); - atomic_inc(&dcc->issued_discard); - f2fs_update_iostat(sbi, NULL, FS_DISCARD, 1); lstart += len; @@ -2070,9 +2082,11 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) INIT_LIST_HEAD(&dcc->wait_list); INIT_LIST_HEAD(&dcc->fstrim_list); mutex_init(&dcc->cmd_lock); + spin_lock_init(&dcc->discard_time_lock); atomic_set(&dcc->issued_discard, 0); atomic_set(&dcc->queued_discard, 0); atomic_set(&dcc->discard_cmd_cnt, 0); + dcc->discard_time_avg = 0; dcc->nr_discards = 0; dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; dcc->max_discard_request = DEF_MAX_DISCARD_REQUEST;