Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3647961rdh; Mon, 27 Nov 2023 22:50:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxu8hYHvKBxAYUbLDcTrIROiO/x6xhBQ8kiPLq1iMXc3gaubRVyLG1sGXRPjlvneluBYST X-Received: by 2002:a05:6a20:d704:b0:181:44c:d6a with SMTP id iz4-20020a056a20d70400b00181044c0d6amr22228892pzb.21.1701154200335; Mon, 27 Nov 2023 22:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701154200; cv=none; d=google.com; s=arc-20160816; b=TGVJYl47Mt3El4Oe6rutsQTJRJRFWCStALFnC4OZBqTspGPQLojwS+kmsu6jLxOd4D oLWxdXHKPS9jrb6sHfulRsJqF8H1iCNDz9JGiGVoJZZ8XyvORcPzHcjYLklSzUaxUC6E varrNOU3Ns3UfAOREPH0bYLi74YUCaemrrVD1FTR0yc24Hr9gWa2RwmYbsE0F16jCSbU 0FE2a0b8ZZrzvl2cFtTm91TquFnf5HOSyQwkH1VoIgRYv44qahf+dylgEEP1CguodHYj Xumx8ezEk1WxUONrYeMR6wP557o1zqlKa+sBpYopOCVpA4CAsf1jjIJIOazB9t9oxyHP xs0g== 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=4R3ZUlDLkPLQsSYazMZGQpoqTQbOIVeMp3U+E6+CHRU=; fh=MgWv5B5NbD26eVyLeacY2+aVUFYEaeHa7XY7x2Rcjj0=; b=IrQTut0zmxiF2eRJ66/dEwNDFqtr884t3T8S1Pw8/pks2zTd2jySgeQxuj6m+4iraD mSk72eqJ+EMXaPoct0DdA8Ez4KXiPuwnyBc/nGVi6T3MVfOs08ukmu2Aj0fQ6WtHpFSN bzwowNLIXbHL+DGYV4FNcZdqs6MC5kS1Bmj48W6EC5uuAC+tjloqkvuxiTuvzO50zvAs Pfesl2imvOgHGeugZMPOVUFyUcHMcSqznfDAjS7RQJoXc5kHoYwMWDCvfEI8ujM0DuYX 6rTJsZHYg1YcAgmX3n6Y97xoLgfv5qQ/et+Kdye7pRff7FuQpMuu3ryBqCk3EkuTZMSk 1aww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cl6-20020a056a02098600b005b9b68add8bsi12619392pgb.785.2023.11.27.22.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 22:50:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id C7CDC806007A; Mon, 27 Nov 2023 22:49:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343659AbjK1Gtn (ORCPT + 99 others); Tue, 28 Nov 2023 01:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbjK1Gtm (ORCPT ); Tue, 28 Nov 2023 01:49:42 -0500 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 119BBE1 for ; Mon, 27 Nov 2023 22:49:46 -0800 (PST) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3AS6mhXG087957; Tue, 28 Nov 2023 14:48:43 +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 4SfXvy5tlyz2K1r9S; Tue, 28 Nov 2023 14:43:10 +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; Tue, 28 Nov 2023 14:48:41 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH V2] f2fs: show more discard status by sysfs Date: Tue, 28 Nov 2023 14:48:16 +0800 Message-ID: <1701154096-23883-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 3AS6mhXG087957 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 27 Nov 2023 22:49:57 -0800 (PST) The current pending_discard attr just only shows the discard_cmd_cnt information. More discard status can be shown so that we can check them through sysfs when needed. Signed-off-by: Zhiguo Niu --- changes of v2: Improve the patch according to Chao's suggestions. --- --- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/sysfs.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 36c3cb5..c6970e5 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -498,6 +498,12 @@ Description: Show status of f2fs checkpoint in real time. CP_RESIZEFS_FLAG 0x00004000 =============================== ============================== +What: /sys/fs/f2fs//stat/discard_status +Date: November 2023 +Contact: "Zhiguo Niu" +Description: Show status of f2fs discard in real time, including + "issued discard","queued discard" and "undiscard blocks". + What: /sys/fs/f2fs//ckpt_thread_ioprio Date: January 2021 Contact: "Daeho Jeong" diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 417fae96..2b80116 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -134,6 +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 discard_status_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; + + if (!dcc) + return -EINVAL; + + return sysfs_emit(buf, "%llu, %llu, %u\n", + (unsigned long long)atomic_read( + &dcc->issued_discard), + (unsigned long long)atomic_read( + &dcc->queued_discard), + dcc->undiscard_blks); +} + static ssize_t pending_discard_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -1197,9 +1213,11 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, F2FS_GENERAL_RO_ATTR(sb_status); F2FS_GENERAL_RO_ATTR(cp_status); +F2FS_GENERAL_RO_ATTR(discard_status); static struct attribute *f2fs_stat_attrs[] = { ATTR_LIST(sb_status), ATTR_LIST(cp_status), + ATTR_LIST(discard_status), NULL, }; ATTRIBUTE_GROUPS(f2fs_stat); -- 1.9.1