Skip to content

Commit d7b549d

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: add carve_out sysfs node
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>
1 parent f7f8932 commit d7b549d

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,3 +836,13 @@ Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
836836
Description: It reclaims the given KBs of file-backed pages registered by
837837
ioctl(F2FS_IOC_DONATE_RANGE).
838838
For example, writing N tries to drop N KBs spaces in LRU.
839+
840+
What: /sys/fs/f2fs/<disk>/carve_out
841+
Date: March 2025
842+
Contact: "Daeho Jeong" <daehojeong@google.com>
843+
Description: For several zoned storage devices, vendors will provide extra space which
844+
was used for device level GC than specs and F2FS can use this space for
845+
filesystem level GC. To do that, we can reserve the space using
846+
reserved_blocks. However, it is not enough, since this extra space should
847+
not be shown to users. So, with this new sysfs node, we can hide the space
848+
by substracting reserved_blocks from total bytes.

fs/f2fs/f2fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,9 @@ struct f2fs_sb_info {
18131813
u64 committed_atomic_block;
18141814
u64 revoked_atomic_block;
18151815

1816+
/* carve out reserved_blocks from total blocks */
1817+
bool carve_out;
1818+
18161819
#ifdef CONFIG_F2FS_FS_COMPRESSION
18171820
struct kmem_cache *page_array_slab; /* page array entry */
18181821
unsigned int page_array_slab_size; /* default page array slab size */

fs/f2fs/super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,8 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf)
18491849
buf->f_blocks = total_count - start_count;
18501850

18511851
spin_lock(&sbi->stat_lock);
1852-
1852+
if (sbi->carve_out)
1853+
buf->f_blocks -= sbi->current_reserved_blocks;
18531854
user_block_count = sbi->user_block_count;
18541855
total_valid_node_count = valid_node_count(sbi);
18551856
avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM;

fs/f2fs/sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,7 @@ F2FS_SBI_GENERAL_RW_ATTR(max_read_extent_count);
11221122
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
11231123
F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
11241124
#endif
1125+
F2FS_SBI_GENERAL_RW_ATTR(carve_out);
11251126

11261127
/* STAT_INFO ATTR */
11271128
#ifdef CONFIG_F2FS_STAT_FS
@@ -1309,6 +1310,7 @@ static struct attribute *f2fs_attrs[] = {
13091310
ATTR_LIST(warm_data_age_threshold),
13101311
ATTR_LIST(last_age_weight),
13111312
ATTR_LIST(max_read_extent_count),
1313+
ATTR_LIST(carve_out),
13121314
NULL,
13131315
};
13141316
ATTRIBUTE_GROUPS(f2fs);

0 commit comments

Comments
 (0)