* [PATCH] f2fs: show # of dirty segments via sysfs
@ 2017-10-24 8:36 Jaegeuk Kim
2017-10-24 9:47 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2017-10-24 8:36 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch adds one sysfs entry to show # of dirty segments which can be
used for gc timing by user.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/sysfs.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index ca74bfdfd4eb..e09e59cc678a 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -63,6 +63,13 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)
return NULL;
}
+static ssize_t dirty_segments_show(struct f2fs_attr *a,
+ struct f2fs_sb_info *sbi, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%llu\n",
+ (unsigned long long)(dirty_segments(sbi)));
+}
+
static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
@@ -283,6 +290,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable);
F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
#endif
+F2FS_GENERAL_RO_ATTR(dirty_segments);
F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
F2FS_GENERAL_RO_ATTR(features);
@@ -326,6 +334,7 @@ static struct attribute *f2fs_attrs[] = {
ATTR_LIST(inject_rate),
ATTR_LIST(inject_type),
#endif
+ ATTR_LIST(dirty_segments),
ATTR_LIST(lifetime_write_kbytes),
ATTR_LIST(features),
ATTR_LIST(reserved_blocks),
--
2.14.0.rc1.383.gd1ce394fe2-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] f2fs: show # of dirty segments via sysfs
2017-10-24 8:36 [PATCH] f2fs: show # of dirty segments via sysfs Jaegeuk Kim
@ 2017-10-24 9:47 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2017-10-24 9:47 UTC (permalink / raw)
To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
On 2017/10/24 16:36, Jaegeuk Kim wrote:
> This patch adds one sysfs entry to show # of dirty segments which can be
> used for gc timing by user.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
> ---
> fs/f2fs/sysfs.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index ca74bfdfd4eb..e09e59cc678a 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -63,6 +63,13 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)
> return NULL;
> }
>
> +static ssize_t dirty_segments_show(struct f2fs_attr *a,
> + struct f2fs_sb_info *sbi, char *buf)
> +{
> + return snprintf(buf, PAGE_SIZE, "%llu\n",
> + (unsigned long long)(dirty_segments(sbi)));
> +}
> +
> static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
> struct f2fs_sb_info *sbi, char *buf)
> {
> @@ -283,6 +290,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable);
> F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
> F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
> #endif
> +F2FS_GENERAL_RO_ATTR(dirty_segments);
> F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
> F2FS_GENERAL_RO_ATTR(features);
>
> @@ -326,6 +334,7 @@ static struct attribute *f2fs_attrs[] = {
> ATTR_LIST(inject_rate),
> ATTR_LIST(inject_type),
> #endif
> + ATTR_LIST(dirty_segments),
> ATTR_LIST(lifetime_write_kbytes),
> ATTR_LIST(features),
> ATTR_LIST(reserved_blocks),
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-24 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24 8:36 [PATCH] f2fs: show # of dirty segments via sysfs Jaegeuk Kim
2017-10-24 9:47 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).