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>
This commit is contained in:
Zhiguo Niu 2023-12-20 09:59:58 +08:00 committed by Jaegeuk Kim
parent 19ec1d31fa
commit c3c2d45b90
2 changed files with 49 additions and 0 deletions

View File

@ -498,6 +498,21 @@ Description: Show status of f2fs checkpoint in real time.
CP_RESIZEFS_FLAG 0x00004000
=============================== ==============================
What: /sys/fs/f2fs/<disk>/stat/issued_discard
Date: December 2023
Contact: "Zhiguo Niu" <zhiguo.niu@unisoc.com>
Description: Shows the number of issued discard.
What: /sys/fs/f2fs/<disk>/stat/queued_discard
Date: December 2023
Contact: "Zhiguo Niu" <zhiguo.niu@unisoc.com>
Description: Shows the number of queued discard.
What: /sys/fs/f2fs/<disk>/stat/undiscard_blks
Date: December 2023
Contact: "Zhiguo Niu" <zhiguo.niu@unisoc.com>
Description: Shows the total number of undiscard blocks.
What: /sys/fs/f2fs/<disk>/ckpt_thread_ioprio
Date: January 2021
Contact: "Daeho Jeong" <daehojeong@google.com>

View File

@ -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)
{
@ -1213,9 +1240,16 @@ ATTRIBUTE_GROUPS(f2fs_feat);
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);