f2fs: expose # of overprivision segments
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 2 Mar 2021 01:28:16 +0000 (17:28 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 12 Mar 2021 21:16:44 +0000 (13:16 -0800)
This is useful when checking conditions during checkpoint=disable in Android.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/sysfs.c

index 9fa5a52..4aa8f38 100644 (file)
@@ -409,3 +409,8 @@ Description:        Give a way to change checkpoint merge daemon's io priority.
                I/O priority "3". We can select the class between "rt" and "be",
                and set the I/O priority within valid range of it. "," delimiter
                is necessary in between I/O class and priority number.
+
+What:          /sys/fs/f2fs/<disk>/ovp_segments
+Date:          March 2021
+Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
+Description:   Shows the number of overprovision segments.
index e38a7f6..0c391ab 100644 (file)
@@ -91,6 +91,13 @@ static ssize_t free_segments_show(struct f2fs_attr *a,
                        (unsigned long long)(free_segments(sbi)));
 }
 
+static ssize_t ovp_segments_show(struct f2fs_attr *a,
+               struct f2fs_sb_info *sbi, char *buf)
+{
+       return sprintf(buf, "%llu\n",
+                       (unsigned long long)(overprovision_segments(sbi)));
+}
+
 static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
                struct f2fs_sb_info *sbi, char *buf)
 {
@@ -629,6 +636,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
 F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
 F2FS_GENERAL_RO_ATTR(dirty_segments);
 F2FS_GENERAL_RO_ATTR(free_segments);
+F2FS_GENERAL_RO_ATTR(ovp_segments);
 F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
 F2FS_GENERAL_RO_ATTR(features);
 F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
@@ -715,6 +723,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(ckpt_thread_ioprio),
        ATTR_LIST(dirty_segments),
        ATTR_LIST(free_segments),
+       ATTR_LIST(ovp_segments),
        ATTR_LIST(unusable),
        ATTR_LIST(lifetime_write_kbytes),
        ATTR_LIST(features),