Skip to content

Commit ae2e280

Browse files
author
Jaegeuk Kim
committed
f2fs: show number of pending discard commands
This information can be used to check how much time we need to give to issue all the discard commands. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent e64347a commit ae2e280

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ Contact: "Jaegeuk Kim" <[email protected]>
112112
Description: Set timeout to issue discard commands during umount.
113113
Default: 5 secs
114114

115+
What: /sys/fs/f2fs/<disk>/pending_discard
116+
Date: November 2021
117+
Contact: "Jaegeuk Kim" <[email protected]>
118+
Description: Shows the number of pending discard commands in the queue.
119+
115120
What: /sys/fs/f2fs/<disk>/max_victim_search
116121
Date: January 2014
117122
Contact: "Jaegeuk Kim" <[email protected]>

fs/f2fs/sysfs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ static ssize_t sb_status_show(struct f2fs_attr *a,
118118
return sprintf(buf, "%lx\n", sbi->s_flag);
119119
}
120120

121+
static ssize_t pending_discard_show(struct f2fs_attr *a,
122+
struct f2fs_sb_info *sbi, char *buf)
123+
{
124+
if (!SM_I(sbi)->dcc_info)
125+
return -EINVAL;
126+
return sprintf(buf, "%llu\n", (unsigned long long)atomic_read(
127+
&SM_I(sbi)->dcc_info->discard_cmd_cnt));
128+
}
129+
121130
static ssize_t features_show(struct f2fs_attr *a,
122131
struct f2fs_sb_info *sbi, char *buf)
123132
{
@@ -744,6 +753,7 @@ F2FS_GENERAL_RO_ATTR(unusable);
744753
F2FS_GENERAL_RO_ATTR(encoding);
745754
F2FS_GENERAL_RO_ATTR(mounted_time_sec);
746755
F2FS_GENERAL_RO_ATTR(main_blkaddr);
756+
F2FS_GENERAL_RO_ATTR(pending_discard);
747757
#ifdef CONFIG_F2FS_STAT_FS
748758
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
749759
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
@@ -812,6 +822,7 @@ static struct attribute *f2fs_attrs[] = {
812822
ATTR_LIST(main_blkaddr),
813823
ATTR_LIST(max_small_discards),
814824
ATTR_LIST(discard_granularity),
825+
ATTR_LIST(pending_discard),
815826
ATTR_LIST(batched_trim_sections),
816827
ATTR_LIST(ipu_policy),
817828
ATTR_LIST(min_ipu_util),

0 commit comments

Comments
 (0)