]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: add carve_out sysfs node
authorDaeho Jeong <daehojeong@google.com>
Tue, 11 Mar 2025 18:29:31 +0000 (11:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 12:55:15 +0000 (13:55 +0100)
[ Upstream commit d7b549def0eb42a950eebd3bd5343f5c8088c305 ]

For several zoned storage devices, vendors will provide extra space
which was used for device level GC than specs and F2FS can use this
space for filesystem level GC. To do that, we can reserve the space
using reserved_blocks. However, it is not enough, since this extra
space should not be shown to users. So, with this new sysfs node,
we can hide the space by substracting reserved_blocks from total
bytes.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Stable-dep-of: e462fc48ceb8 ("f2fs: maintain one time GC mode is enabled during whole zoned GC cycle")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/f2fs.h
fs/f2fs/super.c
fs/f2fs/sysfs.c

index 81deae2af84d2a6b7b2999dfb3c86c9a246f3131..c7ebda8c677e50000d9e1934d25e75497f8fd88d 100644 (file)
@@ -835,3 +835,13 @@ Contact:   "Jaegeuk Kim" <jaegeuk@kernel.org>
 Description:   It reclaims the given KBs of file-backed pages registered by
                ioctl(F2FS_IOC_DONATE_RANGE).
                For example, writing N tries to drop N KBs spaces in LRU.
+
+What:          /sys/fs/f2fs/<disk>/carve_out
+Date:          March 2025
+Contact:       "Daeho Jeong" <daehojeong@google.com>
+Description:   For several zoned storage devices, vendors will provide extra space which
+               was used for device level GC than specs and F2FS can use this space for
+               filesystem level GC. To do that, we can reserve the space using
+               reserved_blocks. However, it is not enough, since this extra space should
+               not be shown to users. So, with this new sysfs node, we can hide the space
+               by substracting reserved_blocks from total bytes.
index f2f3e02b6fd4c845221ed5cfaf8202940b453e9d..08bab3de5c50d056a2d465daf01a1772f1714cb5 100644 (file)
@@ -1813,6 +1813,9 @@ struct f2fs_sb_info {
        u64 committed_atomic_block;
        u64 revoked_atomic_block;
 
+       /* carve out reserved_blocks from total blocks */
+       bool carve_out;
+
 #ifdef CONFIG_F2FS_FS_COMPRESSION
        struct kmem_cache *page_array_slab;     /* page array entry */
        unsigned int page_array_slab_size;      /* default page array slab size */
index 3be4e8bcbd138187a402f77e4d7240eaf83eb6fc..ee8352246ce477e45d272a182b40da45c79663dd 100644 (file)
@@ -1839,7 +1839,8 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_blocks = total_count - start_count;
 
        spin_lock(&sbi->stat_lock);
-
+       if (sbi->carve_out)
+               buf->f_blocks -= sbi->current_reserved_blocks;
        user_block_count = sbi->user_block_count;
        total_valid_node_count = valid_node_count(sbi);
        avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM;
index 5c4fd0f3acab729eea2477e187fb57fe4832860e..9b4768b1efac5b0adb0890d6d6c0d853af4db019 100644 (file)
@@ -1145,6 +1145,7 @@ F2FS_SBI_GENERAL_RW_ATTR(max_read_extent_count);
 F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
 F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
 #endif
+F2FS_SBI_GENERAL_RW_ATTR(carve_out);
 
 /* STAT_INFO ATTR */
 #ifdef CONFIG_F2FS_STAT_FS
@@ -1332,6 +1333,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(warm_data_age_threshold),
        ATTR_LIST(last_age_weight),
        ATTR_LIST(max_read_extent_count),
+       ATTR_LIST(carve_out),
        NULL,
 };
 ATTRIBUTE_GROUPS(f2fs);