Skip to content

Commit c3c2d45

Browse files
Zhiguo NiuJaegeuk Kim
authored andcommitted
f2fs: show more discard status by sysfs
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 <zhiguo.niu@unisoc.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 19ec1d3 commit c3c2d45

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,21 @@ Description: Show status of f2fs checkpoint in real time.
498498
CP_RESIZEFS_FLAG 0x00004000
499499
=============================== ==============================
500500

501+
What: /sys/fs/f2fs/<disk>/stat/issued_discard
502+
Date: December 2023
503+
Contact: "Zhiguo Niu" <zhiguo.niu@unisoc.com>
504+
Description: Shows the number of issued discard.
505+
506+
What: /sys/fs/f2fs/<disk>/stat/queued_discard
507+
Date: December 2023
508+
Contact: "Zhiguo Niu" <zhiguo.niu@unisoc.com>
509+
Description: Shows the number of queued discard.
510+
511+
What: /sys/fs/f2fs/<disk>/stat/undiscard_blks
512+
Date: December 2023
513+
Contact: "Zhiguo Niu" <zhiguo.niu@unisoc.com>
514+
Description: Shows the total number of undiscard blocks.
515+
501516
What: /sys/fs/f2fs/<disk>/ckpt_thread_ioprio
502517
Date: January 2021
503518
Contact: "Daeho Jeong" <daehojeong@google.com>

fs/f2fs/sysfs.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,33 @@ static ssize_t pending_discard_show(struct f2fs_attr *a,
143143
&SM_I(sbi)->dcc_info->discard_cmd_cnt));
144144
}
145145

146+
static ssize_t issued_discard_show(struct f2fs_attr *a,
147+
struct f2fs_sb_info *sbi, char *buf)
148+
{
149+
if (!SM_I(sbi)->dcc_info)
150+
return -EINVAL;
151+
return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read(
152+
&SM_I(sbi)->dcc_info->issued_discard));
153+
}
154+
155+
static ssize_t queued_discard_show(struct f2fs_attr *a,
156+
struct f2fs_sb_info *sbi, char *buf)
157+
{
158+
if (!SM_I(sbi)->dcc_info)
159+
return -EINVAL;
160+
return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read(
161+
&SM_I(sbi)->dcc_info->queued_discard));
162+
}
163+
164+
static ssize_t undiscard_blks_show(struct f2fs_attr *a,
165+
struct f2fs_sb_info *sbi, char *buf)
166+
{
167+
if (!SM_I(sbi)->dcc_info)
168+
return -EINVAL;
169+
return sysfs_emit(buf, "%u\n",
170+
SM_I(sbi)->dcc_info->undiscard_blks);
171+
}
172+
146173
static ssize_t gc_mode_show(struct f2fs_attr *a,
147174
struct f2fs_sb_info *sbi, char *buf)
148175
{
@@ -1213,9 +1240,16 @@ ATTRIBUTE_GROUPS(f2fs_feat);
12131240

12141241
F2FS_GENERAL_RO_ATTR(sb_status);
12151242
F2FS_GENERAL_RO_ATTR(cp_status);
1243+
F2FS_GENERAL_RO_ATTR(issued_discard);
1244+
F2FS_GENERAL_RO_ATTR(queued_discard);
1245+
F2FS_GENERAL_RO_ATTR(undiscard_blks);
1246+
12161247
static struct attribute *f2fs_stat_attrs[] = {
12171248
ATTR_LIST(sb_status),
12181249
ATTR_LIST(cp_status),
1250+
ATTR_LIST(issued_discard),
1251+
ATTR_LIST(queued_discard),
1252+
ATTR_LIST(undiscard_blks),
12191253
NULL,
12201254
};
12211255
ATTRIBUTE_GROUPS(f2fs_stat);

0 commit comments

Comments
 (0)