Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp20935rdh; Mon, 18 Dec 2023 03:10:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNtYkaSqk+h0XMP1SOwN8b3UT4+kraPsvZZ9oBCL9yGxgzBcZI/rsarPO04gQhU/ODTJuK X-Received: by 2002:a05:620a:2a10:b0:77d:7a2b:2fd9 with SMTP id o16-20020a05620a2a1000b0077d7a2b2fd9mr24709522qkp.31.1702897808973; Mon, 18 Dec 2023 03:10:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702897808; cv=none; d=google.com; s=arc-20160816; b=y64T566hfpIP1eRYp4jp/IZfBUI3L1CY6HM1ZE9buyAvtGArJ6BMuNqn6bm/N+N+1A srDcnTekPROSEFOdiu4ydou/nbCZ1sO4jBQpgta4yf4Kj8DeehtKwXcgD5Kg6xrALRre n2rSPbFxyMN46BdWvQU7WG7p+DgIRJZM3B9yFw2OENZsXUjbuI2192jKTDSQb5Lu5g1s KUCi31QO0T6jYDbgHJR3agGhxzdIEILysjP6DWVJja2vOggm6Q3k62dhPl4UXSZzh9Dk kQPQ4VpweK3Q3yV8VZerarctZ9xPewhhGEajZO/I3R4G+mjK6SyDOnWr8zXGS0Nw8SWL LCpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=Vq0R1Bf7hdDaZIBm/mcoeYwfkcg5sSogtmrb344sl+s=; fh=JkrfyujbIDmycozXR7ZDiVuf6xBFur6C1+1NEIITJEI=; b=La+693bxkpGZzHG8En1eawz63TaNy/vw2xZxyHyliAX0rHGjrcaCJ4Nyick+rmVn+z aqS4a9xvXsDTqHLVyzp5Gqn+m5WJQHMdEr/uQo2DOEavbHMKf50ZDjnfBduLNJM9Hkmn KitmtGxavYFP9fVAVAhL3k1wUG+YUQocJiA0X8KR3TedADqsIUxs+eYPICVd/TTyJg9b iZ8umKe6t/H3RDRhGbhp0yXNqa4O8tFPyJ4BVW900OszFSM47WOCAiCnRUyV9I2P0sS2 mvu6M48rhMqVl4Tj85mXgymIjqvDWQxd8kO3sMoxQUafpPZknprWU4Pn8RFoZco9g9N+ gJ4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-3416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3416-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vu8-20020a05620a560800b0077f131c9abfsi23334371qkn.211.2023.12.18.03.10.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:10:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-3416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3416-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EC7541C2333A for ; Mon, 18 Dec 2023 11:09:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB0EA199DF; Mon, 18 Dec 2023 11:09:23 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E235199B9 for ; Mon, 18 Dec 2023 11:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3BIB8Ygh044195; Mon, 18 Dec 2023 19:08:34 +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 4Stxjq3bTwz2PjHGh; Mon, 18 Dec 2023 19:02:23 +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; Mon, 18 Dec 2023 19:08:33 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH V3] f2fs: show more discard status by sysfs Date: Mon, 18 Dec 2023 19:07:56 +0800 Message-ID: <1702897676-12851-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 3BIB8Ygh044195 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. changes of v3: Add a blank line for easy reading. --- --- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/sysfs.c | 19 +++++++++++++++++++ 2 files changed, 25 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..312a4dc 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,12 @@ 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