From patchwork Wed Nov 23 13:25:02 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: 24983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2801709wrr; Wed, 23 Nov 2022 05:55:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4eraunzL+OZvYrp77kklcYQqJ1mF2BbUMCOsTkBWQ7I3rxfujmz1HpX87wpUrIq5MDRk8R X-Received: by 2002:a17:903:26cf:b0:186:e114:bea6 with SMTP id jg15-20020a17090326cf00b00186e114bea6mr8831184plb.88.1669211741209; Wed, 23 Nov 2022 05:55:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669211741; cv=pass; d=google.com; s=arc-20160816; b=uKyMTbcc76kb4crXPZdIbDIlFXLUz6fCW+O/B+lrDbRgwC852yw/9VTdzritjjU93i 3enTQpDcCwf82dXZ/HlOl+Efd49DtqN2RERoBTpK3yb8Vs5KresMMLjVE8iL1crbVAAk o8SwBJVYJCcmFl8IDjr+1mV1xTY2RnddSYPcP9H3eYEpDuL8ARbDtW7KgDkZE03sQLpL JmVRQThSPiXdjYghc1vkVzvRtIFL+5+JUVuj/X6AZj594ZT+RGzt+rV3Pp51ngeKa5w/ bjTYTLNnAS5JCv72rob5E3Dle3uRw1KoAj2fynTe/wpxFcArFiw6ahh6mMcVlBhPYCJh y8TQ== 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=V6RZHRvRat957QOJppzHSoWWgIQtYgkYdWiy0+6mMjw=; b=WGuUZMqRL+pBqBHsD1nT5ldRcvkcux5oGwK9KOi7pMfK76oZ5u93zvvrliuSdRXeJV Bka+fjDaWsolvEPjA3pY28u96Js2kiX/xdHDn8olEsbZvmczuXeAMl9LMshXgE5dV2Qj 1k2e0nf94nB4wMj+mYEYuY87q3tDTyBeED9GTJMYfi9XcqqoBrPa0yUDvfKmnXUDRr2S MOqs9V6tgaEl2Rrpu8ooAzE0VY1YjbPcRET6ysbQ3NskgATFi1elf3wLirW99xglfs1O JjqPLojqByp5A/VthBPM2RwbTo5B/tdoN9/3qgaH6tCqRybbm+k9dBTCHrMgYjj50etQ B4nA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=UP5+ogZu; 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 m16-20020a056a00081000b00571fc323489si17860057pfk.361.2022.11.23.05.55.25; Wed, 23 Nov 2022 05:55: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=UP5+ogZu; 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 S238818AbiKWNht (ORCPT + 99 others); Wed, 23 Nov 2022 08:37:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238978AbiKWNhJ (ORCPT ); Wed, 23 Nov 2022 08:37:09 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2129.outbound.protection.outlook.com [40.107.255.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E3E1716F1 for ; Wed, 23 Nov 2022 05:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PtSkzpBwQLyawi56RyH4MOZqsH08zkonE/O200jkM7zCzXY0ZuP9rMC6pmgV4WB9n01n3+Nlc4mWZxIPDIFx+NdKf2rBjENGY6wgF2Sg0Qwv3P5yHe8v9TO7yDz8E8OFkg04LDoOLnkVVBGDkSu+RzmkoAnqF+GBkIS6wdnrBSsmrI7epuroPH/Ql9bZAl17p3KIifq9YhxJQQnoKXcNEhaqKCvM1mIIP10Q5t7CXHQq4fK4x35xrZ0CLIk6Viu+5p1n+uZUKGwWQVfySf7URbebJwxJ6fYZLaqlySkmkTKKXAvhXkMRiP3YWpbWbbnv2L0/bcgBdqLUkjyLdjyiEQ== 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=V6RZHRvRat957QOJppzHSoWWgIQtYgkYdWiy0+6mMjw=; b=P7l7qSUepPo69dG+lNDtMfmoBMd2jNFNqb5mqKft6LlPTWW9liCrqCetLZy9uV7oqoIdHOkm3sJ5455LJv95m2VDpa7kYBqptfrFJYJYqFBP54HgiIKYQIz1TIP9zDdMm5yjIWrkDoIwqw9XIOH/uRSiAUwsgQAGg66eshUj9SWUssqRMxQvh8uieFxKa0zduZztrXkVdHe8Dk73QOyTPjgSvCcxtJwHpYD54TGCKEo3KAo+7wj+UmekbjIEwvbjxaUWyL8CJllhHpGrHh3jrNUX5SCUO8vW7jkUUwyt8BuS+W23+sHqGR/gS78TcV0bQj/iK9saZ9bIUinB3v0lXw== 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=V6RZHRvRat957QOJppzHSoWWgIQtYgkYdWiy0+6mMjw=; b=UP5+ogZulIKdhe2qW+JinZQXG7rlgR1FinAxQf6FMFa7qg/zRCv4z/uVAOfIbLwwnMTk08RG4rxYE/P9L3WcI1rNbDkQEfZqgHiH/AT/dURJ+2MWVmvceAEE4vgiPk/yLfKdRwSRak9Emo+Yp6yer09WteONmpCHU5vSGCjKFCbjGJdFvZqn06Wy65UD4xKq281DXwn+Lr8qYbvUpiUZ/0MXGGgNNLdSa4nc2QZQPO15mfHP2h9vHwHlSOFSVpaww+ii003X1w+xE7ks98rTIO6y8nNUxP9Y8MTfiVOPCOMx7NYqSaD3WoHQh/RP98VGTEzmySRd7m/buegOLFGQRQ== 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 SI2PR06MB3948.apcprd06.prod.outlook.com (2603:1096:4:fd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 13:25:14 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139%7]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 13:25: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: add support for counting the average time of submit discard cmd Date: Wed, 23 Nov 2022 21:25:02 +0800 Message-Id: <20221123132502.72078-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI2PR06CA0014.apcprd06.prod.outlook.com (2603:1096:4:186::11) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB3948:EE_ X-MS-Office365-Filtering-Correlation-Id: 18d25546-d9ff-4e50-d207-08dacd56276e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W8Yzv7Kh3zLMehWUlLXk63E7pC7c/ZAGep7l9kqxgNG6r9RxHbP7r4FKQhLKK6FdBfU1OIj+apxDuHu7eKi5TFfPeQWFCSx5K3UNTvPqzDXUzTOsxoll/rAK4WBY0MuTEEXb/HW+u9/DQZNPzjRaSJSZXL33smEUVAmUEa5qk5PFt4VlF7Z+XGxpzRh3p2MD6INllDL1T1fHVj9JOjCfRgOvOBsV04fNNpF7rWdX7L3U35pphNKAlrkjF0j8YsXj6Vy8mKiNpdLeqX1xGMJVGa+0jiavMY52Prwetzz7ZZb+ZtK459yT4/gTERZJDlAVVwRT1EVzsESwFYBme/qzHqRHVcJEO5eDqLPlQVL456NjjuP0dqQ+208ciLnMvBWx9cJXofpa/4nuCADPKiFq6hsT6Vczg3GlDkDPQRGcvKS1D8LmgUJQ0lZRYjF9vnTN/TJeSC2XlPojlhXfJGuB8ox19TkMTsxYKuntGnsC1ywui1lhRsLIF+7/3jNb1bnCK0SBzpNtCg3L5bNv0/FUYR/gJw1BRzJ7GSgKjiv2X3IGZUsfpYFeIoTfja5N9Mq1TjuLxSfMXuxKVzAo5B7FNcSMuYUvDD7Lt5gqBo1sNbJnQSR/DHsSQkbMtCEaYUw+ZxVgVkFMP2rxEFx2buTGWdOmoMp6vMF8Ncy9ngFCcT85QNBQo6zd7HsgyQ6GHZsj 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)(346002)(39860400002)(136003)(376002)(366004)(396003)(451199015)(36756003)(86362001)(26005)(38100700002)(38350700002)(186003)(2616005)(107886003)(2906002)(6512007)(1076003)(83380400001)(8936002)(5660300002)(52116002)(6506007)(478600001)(66556008)(6666004)(41300700001)(8676002)(66476007)(6486002)(316002)(66946007)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IXh11TEYXC3PBb+qDYaLdrJkD8f4vBCjLVHbTdXHTtSUFIhFllxP7btps5/sxNWWIqJh+Ky8s7781dBa9OyNufh2aD5brJon53N0gD6Clsm8nyP70b+V/LxrAttYdZg0zB/zBJe142DMviXQ4bRJN3swQ9qST91GGuXg/goDnkw8xnDeFAr/sWX36q+VBNraHrnj7iqYffanSbCIQ4th2adzc7B04fnC5gSZFIuNyEOdlrvUFL9PvgD329k91jXyyYh0/KwkkZWFTcPZ2N+dIk2so1y85J41TnrWBAQNJXRIxXiZJQpbTmgKcs8+wRPmu51Goz/+aX9MIb6Rs7YrqAyxdIoKUE4+3x9+ub7PJAKJpvl5sxd8Lh1zp+msFIJvOxZKSlTe5gth+IEno/0nCaDrTt1bm2oxtxbDEagxDxdcfe50v9EUbgYJvBkm/nuK6H6WXrwOFY9qTKEYzeny7g5q1ZZa6Pz2yoIz8ODf277GDtGUCxGPf+Wpl6TFHkLGicKgdJ2F7M3eXWPpwTxNGHJ9jmPh6XfLyGZmwb41hcWBhRwk9vPyyvnzENZmIVI8RBVeC1yDNEllFwNj3MgIR3WjOz6PfEIpkpQSjClKIZ1tRBXQnDFXheAG56la+VX5Ag0Y0mgt6oN1XdV0C76GW6ROZTZk+Yr38R2rdxaMdaf4v63tyLddpJiYGfcct9A4rTCpxkZVCcfxOhOeoRPcu5EwRGT/ldWyxNuQp+90eIiEqP8RwKl07ds/e2Mxav8k6SgXRIVnSgJRq7Kxfv+FU8zoehaE0FbtPA3z485rdZZ4ICF9QaA4cRJeNIB2OXiTpLHGRJ5KqWmC2yqQLj2vova/FjtKy6BlAK5OVzDuyXVrOMnhfS+wzRfC8KwMqxrWef0Qs6C9dtzYrkJlTgdJJVX3mFH1GRbDY7OgOq4XGXl4R9PDLTb/tyl3YmYTxiq2b/6HNI/DGg4CBU/d6Px6CzyA4cRzcbBzKuQuRNQ+bIGXNvhdEVYiUeHdqDmc1QGmwKY6+8sh6aLnVM54eqyRXMkwU9JP9nH7nMwsZYrSinNub9UdZpC13bN77ON/4cRjTHD6OHYAmxoOkZJPjb0PP3+KOKmA14a/Q7mNXb4dY5AfiVX/nYdqv8TV+n9bnUOzdFrAA6vOR4fTBPhCXxkgIe0ZLMC2Q9l4YvaY2E2/8rK3oNYuw5A6jycAG3eTucofWNRkXKFp2YuRvVJmN9j7J9VYrLvGkwZMXC7+fN5VXDI50pZhKwK79WCDtgBx5Z4cXVxJI9j1KL3f9KVJ3A0eCH2z7VLi2SOgpG0535OJJetSyPrL+t4kWLTydZkhC/bx8pHzuwtUmIsOc9nPuCALHsSIeJGa/xjeq4IHaKQaLB3faUy80NEFh0T3BgryRd1DNvAPxiTiSzo/qZJGNmmC+9vcLCh1YIA7/Su80YVPJtimuWV2kANJ/+cEacj6QhAM+IHdLURipTndHJnWGyWnKjBGJ5alV4V83q/74W8gZr+6FrWnnhLy5tPYHTh02BhKWrKTlIo+StdBX7a7NhQRoOKs214BcyiTZ+Jl4dl0v5vbllCXZ2It29oXG7qAtkMJ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18d25546-d9ff-4e50-d207-08dacd56276e X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 13:25:14.0989 (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: i0tTwedMJT2t08jwQdqPyMRj+MkrncF8XfgSx1LClqGgeQCFH/iPUIjQRSZYXzDaZKL6b3ZXmTiGx30Q4SWg7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB3948 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?1750295370802679707?= X-GMAIL-MSGID: =?utf-8?q?1750295370802679707?= 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 | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index a216dcdf6941..ede862cb178d 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 = @@ -506,11 +509,11 @@ static int stat_show(struct seq_file *s, void *v) 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", + "Discard: (%4d %4d avg:%4lldns)) cmd: %4d undiscard:%4u\n", si->nr_wb_cp_data, si->nr_wb_data, si->nr_flushing, si->nr_flushed, si->flush_list_empty, - si->nr_discarding, si->nr_discarded, + 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 f0833638f59e..6891467fdb6a 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -372,6 +372,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 { @@ -415,6 +417,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 */ @@ -3883,6 +3887,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 8b0b76550578..dd67e936615a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -936,6 +936,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; @@ -1005,9 +1006,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--; @@ -1017,6 +1022,13 @@ 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, @@ -1165,6 +1177,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 @@ -1184,8 +1197,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; @@ -2076,9 +2087,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;