f2fs: make gc_urgent and gc_segment_mode sysfs node readable

Changed a way of showing values of them to use strings.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Daeho Jeong
2022-03-18 12:13:23 -07:00
committed by Jaegeuk Kim
parent 5ff2f62946
commit 6df080eaa5

View File

@@ -41,6 +41,16 @@ enum {
ATGC_INFO, /* struct atgc_management */
};
static const char *gc_mode_names[MAX_GC_MODE] = {
"GC_NORMAL",
"GC_IDLE_CB",
"GC_IDLE_GREEDY",
"GC_IDLE_AT",
"GC_URGENT_HIGH",
"GC_URGENT_LOW",
"GC_URGENT_MID"
};
struct f2fs_attr {
struct attribute attr;
ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *);
@@ -320,8 +330,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
sbi->compr_new_inode);
#endif
if (!strcmp(a->attr.name, "gc_urgent"))
return snprintf(buf, PAGE_SIZE, "%s\n",
gc_mode_names[sbi->gc_mode]);
if (!strcmp(a->attr.name, "gc_segment_mode"))
return snprintf(buf, PAGE_SIZE, "%u\n", sbi->gc_segment_mode);
return snprintf(buf, PAGE_SIZE, "%s\n",
gc_mode_names[sbi->gc_segment_mode]);
if (!strcmp(a->attr.name, "gc_reclaimed_segments")) {
return snprintf(buf, PAGE_SIZE, "%u\n",