Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp727044rdh; Thu, 23 Nov 2023 17:10:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNxXBGV+U9fFrb42mnSgNzyxoDCvav1Wu2QCSschx9cQce0Zj0ETkl1PmWZLYmMkVa1tG2 X-Received: by 2002:a17:903:454:b0:1cc:510b:36c with SMTP id iw20-20020a170903045400b001cc510b036cmr1118849plb.54.1700788212004; Thu, 23 Nov 2023 17:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700788211; cv=none; d=google.com; s=arc-20160816; b=eI1Yrg79s5T5i/fldYXVVEdd5iQn61GXje70eP3V+5Nv5I+pb6EKhVXD1NB9lTeqM/ YbyiO3hBCtRSL7PpC/Sqd3siF+TemqVyca4N23U3mT8rbENKSRrP9JlcRnY3c8LjxhBJ YtOoPuDf8yELVsihwS4w/pzS/rC1tonG6xejOORCTQsCPqEp2MJ7IBQWGOQSKumiboGe nhN4rUMO0gCu6bKLkdgM8aObJnDlwT5I15MU8cqiAEVmMEOFJzbuYodDYt8raFfB+Dd2 3yITR12RVe0juIlD+9Y/Oii15azhdKb7VRv57WlAO0r8H1BOkKPVQGeKzl/LeEgTtTKj 7Xww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=i+8SzhtrIW+qrRU4GxkBZJ0ehnst9ifSAaO16PUtH58=; fh=MgWv5B5NbD26eVyLeacY2+aVUFYEaeHa7XY7x2Rcjj0=; b=GNeH0E3HJqSYYgizi0eJWxI1L5X6Kc+hILVnEDnWeEik96d7k44Vr+jZGbwi329zVx 9Rcl31eSX89taHaLXKFO8NQlr/KcLIcA5HZouloHqHwzsAdN9FcpEB1ZSIJsUlbalG1d Dxybc7a8cfVDQB9VmRIMoLjUCTqSGrJtFue/mZwB3eGKNdDNJypFy6TZqf+WRuHDLl7f LsYw8rqzWHYNCedEXkQQeUbAwwWSPlA4Uf5KliESoJhMcClF+B71sV7ryNnyPrGfd84o ygO8e2ZxwZ4t4xrhmdcy3aBYaZu4lDCpb7LS3YSGkfrGWv9WhuBABYlRfyDu75t5woVf 7M1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z5-20020a170903018500b001cc6afede42si2307380plg.354.2023.11.23.17.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 17:10:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 88564805E2D7; Thu, 23 Nov 2023 17:10:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjKXBJu (ORCPT + 99 others); Thu, 23 Nov 2023 20:09:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjKXBJt (ORCPT ); Thu, 23 Nov 2023 20:09:49 -0500 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D1221BE for ; Thu, 23 Nov 2023 17:09:54 -0800 (PST) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3AO199em043798; Fri, 24 Nov 2023 09:09:09 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4SbxZ81N8sz2K5kLN; Fri, 24 Nov 2023 09:03:44 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 24 Nov 2023 09:09:06 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH] f2fs: show more discard stat by sysfs Date: Fri, 24 Nov 2023 09:08:48 +0800 Message-ID: <1700788128-29002-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.73.87] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 3AO199em043798 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 17:10:04 -0800 (PST) The current pending_discard attr just only shows the discard_cmd_cnt information, which is not very meaningful. More discard information can be shown so that we can check them through sysfs when needed. Signed-off-by: Zhiguo Niu --- fs/f2fs/sysfs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 417fae96..f98e680 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -134,13 +134,22 @@ static ssize_t cp_status_show(struct f2fs_attr *a, return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags)); } -static ssize_t pending_discard_show(struct f2fs_attr *a, +static ssize_t discard_stat_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { - if (!SM_I(sbi)->dcc_info) + struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; + + if (!dcc) return -EINVAL; - return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( - &SM_I(sbi)->dcc_info->discard_cmd_cnt)); + + return sysfs_emit(buf, "%llu, %llu, %llu, %u\n", + (unsigned long long)atomic_read( + &dcc->discard_cmd_cnt), + (unsigned long long)atomic_read( + &dcc->issued_discard), + (unsigned long long)atomic_read( + &dcc->queued_discard), + dcc->undiscard_blks); } static ssize_t gc_mode_show(struct f2fs_attr *a, @@ -1016,7 +1025,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, F2FS_GENERAL_RO_ATTR(encoding); F2FS_GENERAL_RO_ATTR(mounted_time_sec); F2FS_GENERAL_RO_ATTR(main_blkaddr); -F2FS_GENERAL_RO_ATTR(pending_discard); +F2FS_GENERAL_RO_ATTR(discard_stat); F2FS_GENERAL_RO_ATTR(gc_mode); #ifdef CONFIG_F2FS_STAT_FS F2FS_GENERAL_RO_ATTR(moved_blocks_background); @@ -1074,7 +1083,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, ATTR_LIST(discard_urgent_util), ATTR_LIST(discard_granularity), ATTR_LIST(max_ordered_discard), - ATTR_LIST(pending_discard), + ATTR_LIST(discard_stat), ATTR_LIST(gc_mode), ATTR_LIST(ipu_policy), ATTR_LIST(min_ipu_util), -- 1.9.1