Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp295939rdb; Tue, 19 Dec 2023 18:02:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtpZCUermU7p4A9ZJFT3HQ1sVkaVGkogn1WBLIFO3SFcCNI6YvgAMrl+wk38JATKPn2o6h X-Received: by 2002:a05:620a:628a:b0:77f:59f:73d8 with SMTP id ov10-20020a05620a628a00b0077f059f73d8mr24793455qkn.76.1703037727035; Tue, 19 Dec 2023 18:02:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703037727; cv=none; d=google.com; s=arc-20160816; b=Wd4UcZXb7e81qpJezUJ/a5FiYrg8NfsYnI8jh8YRVx1L4FAaeHeMaB6w+QYVY5sJuD fb3rzaz8fX2s+Y5Fj50OIoAGVd4+Vfe+nOKukuo3vP+Rns+klKMeXAY1oVnUTOCY81yk aBBmcCznirSsc9wqBow0vad+bAr493grQ7y0qaAtt3HsRx8T58J6KWgyMBDjwKE1WZT6 hCJbl1oqcybAoqMh0vEvqqI4OSf/vAX8ZMsqR+CNtj7c0oLu5rCFBIcs4pxyQT2tgHip q+oMqUr6CiH1/KzdkWeeeGtmxQ00WaI79TD6lL20iClmOc6mzZ0XAhXqyHALSuQF47Rn rWDQ== 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=KxdjhZ7J3SG0B4NlCRLo1DMj5S6WCqugknKk4IQx274=; fh=JkrfyujbIDmycozXR7ZDiVuf6xBFur6C1+1NEIITJEI=; b=SZwGwTjowE9R4VLZLGHA2muqUV9VyOZLzlYqCaRAk8dTeh5TTsbErGJb09bSMmG0SU +CzD63bct4X8rmxM0G+nO+ojw+YW//3kzvasHawOLjGbsvyTIzm98JVF6DOjvl3zqo6u kwtSIfe/uwU54omn3jKAVv3IDEUArRqJ2fYkgmV8mbhP4cFYJZBk40jdbl9wAm1O9wLU zWBJ9rFtmeARJz/ydUelTJSPQ5p62It+0OmAsO50678niNGNnBjB24m70/aOz3JtfS4p /sI2bIXskjb1jjQSP5jOOd66cuaRg2CnGhCW/eoOYpQ7w6kFPrg8kdRg49n1VBIjChRi CMrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6277-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6277-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ea24-20020a05620a489800b0076ccd3dc9f2si29764795qkb.741.2023.12.19.18.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 18:02:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6277-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6277-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6277-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 C69061C24C0E for ; Wed, 20 Dec 2023 02:02:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05E9412B86; Wed, 20 Dec 2023 02:01:21 +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 5105E1173B for ; Wed, 20 Dec 2023 02:01:16 +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 3BK20NML067032; Wed, 20 Dec 2023 10:00:23 +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 4SvxSJ4c8cz2PpQ1x; Wed, 20 Dec 2023 09:54:08 +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; Wed, 20 Dec 2023 10:00:21 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH V5] f2fs: show more discard status by sysfs Date: Wed, 20 Dec 2023 09:59:58 +0800 Message-ID: <1703037598-4359-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 3BK20NML067032 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. changes of v4: Split to three entries changes of v5: move these entries from disk/xxx to disk/stat/xxx. --- --- Documentation/ABI/testing/sysfs-fs-f2fs | 15 +++++++++++++++ fs/f2fs/sysfs.c | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 4f1d4e6..99fa87a 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -498,6 +498,21 @@ Description: Show status of f2fs checkpoint in real time. CP_RESIZEFS_FLAG 0x00004000 =============================== ============================== +What: /sys/fs/f2fs//stat/issued_discard +Date: December 2023 +Contact: "Zhiguo Niu" +Description: Shows the number of issued discard. + +What: /sys/fs/f2fs//stat/queued_discard +Date: December 2023 +Contact: "Zhiguo Niu" +Description: Shows the number of queued discard. + +What: /sys/fs/f2fs//stat/undiscard_blks +Date: December 2023 +Contact: "Zhiguo Niu" +Description: Shows the total number of 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 7099ffa..c13eef0 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -143,6 +143,33 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, &SM_I(sbi)->dcc_info->discard_cmd_cnt)); } +static ssize_t issued_discard_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + if (!SM_I(sbi)->dcc_info) + return -EINVAL; + return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( + &SM_I(sbi)->dcc_info->issued_discard)); +} + +static ssize_t queued_discard_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + if (!SM_I(sbi)->dcc_info) + return -EINVAL; + return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( + &SM_I(sbi)->dcc_info->queued_discard)); +} + +static ssize_t undiscard_blks_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + if (!SM_I(sbi)->dcc_info) + return -EINVAL; + return sysfs_emit(buf, "%u\n", + SM_I(sbi)->dcc_info->undiscard_blks); +} + static ssize_t gc_mode_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -1206,9 +1233,16 @@ 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(issued_discard); +F2FS_GENERAL_RO_ATTR(queued_discard); +F2FS_GENERAL_RO_ATTR(undiscard_blks); + static struct attribute *f2fs_stat_attrs[] = { ATTR_LIST(sb_status), ATTR_LIST(cp_status), + ATTR_LIST(issued_discard), + ATTR_LIST(queued_discard), + ATTR_LIST(undiscard_blks), NULL, }; ATTRIBUTE_GROUPS(f2fs_stat); -- 1.9.1