f2fs: introduce inline extent mapping for inode data blocks
Subsystems (2)
v3 cover f2fs: introduce inline extent mapping for inode data blocks
From: Yongpeng Yang <[email protected]>
Changes since v2:
- Inline extent no longer covers direct block mappings. The inline extent area is now placed after struct f2fs_inode->i_extra_end, inside the i_extra_isize region. This removes the need for format conversion and for f2fs-tools to understand/modify the inline extent on-disk format.
- Split struct f2fs_inode->i_compr_blocks (was __le64) into __le32 i_compr_blocks + __le32 i_inline_ext_capacity, where i_inline_ext_capacity records the per-inode inline extent capacity.
- Dropped [RFC PATCH v2 1/5] "replace raw dnode pointer arithmetic with f2fs_data_blkaddr()": f2fs_truncate_data_blocks_range no longer needs changes to accommodate the redesigned inline extent.
- Dropped [RFC PATCH v2 3/5] "support setting inline extent flag via ioctl": format conversion between inline extent and the direct block address array is no longer needed.
- Re-ran the performance tests (see updated numbers below).
v2: https://lore.kernel.org/all/[email protected]/
Changes since v1:
- Introduce tracepoints for f2fs_iext_update_data_blkaddr and f2fs_iext_lookup_blkaddr to aid debugging (new patch 5/5).
- Bypass inline extent lookup for F2FS_GET_BLOCK_PRECACHE to ensure all mappings are loaded into the read extent cache.
- Unify the check for fofs exceeding direct_blocks range to use "fofs >= direct_blocks" consistently.
- Remove support for caching NULL_ADDR in inline extent area. If a fofs within [0, direct_blocks) is not found in inline extent, it implies NULL_ADDR. This simplifies merge and split logic.
- Fix f2fs_iext_enable_inline_extent to use PTR_ERR instead of -ENOMEM.
- Change f2fs_iext_convert_to_inline_extent return type to bool.
- Add benchmark data covering 4K/8K/32K/64K random read.
- Rename __is_extent_mergeable to __is_iextent_mergeable to avoid naming collision with extent cache code.
- Remove inode parameter from f2fs_iext_sanity_check (always NULL).
- Reduce #ifdef CONFIG_F2FS_INLINE_EXTENT nesting in node.c.
- Code style fixes to comply with kernel coding style.
v1: https://lore.kernel.org/all/[email protected]/
This patchset introduces an inline extent mapping mechanism for f2fs. Instead of storing individual block addresses for indirect-node blocks, this feature packs contiguous block ranges into compact extent entries stored directly in the inode, reducing indirect/double-indirect node page reads and enabling O(log n) block address lookup via binary search.
Design overview:
- The inline extent area is placed immediately after i_extra_end in the on-disk inode, within the i_extra_isize region. Its size (number of extent entries) is determined by the new field i_inline_ext_capacity.
- On-disk layout:
[i_extra_isize .. i_extra_end] [f2fs_iext_header | f2fs_extent[cap]]
|<------------------ i_extra_isize (in bytes) ------------------->|- Inline extent only caches mappings for indirect blocks (fofs >= ADDRS_PER_INODE). Direct block mappings continue to use i_addr[], so no format conversion is required.
- Per-inode capacity is decided at file creation time based on the configured file-extension matching rules (see sysfs below).
- Mutually exclusive with compression.
Patch 1: Core implementation -- data structures, extent operations
(lookup, insert, merge, split, truncate), and integration with the f2fs data/node/inode/recovery paths.
Patch 2: sysfs interface -- runtime enable/disable toggle and the file
extension list (with optional per-extension capacity) for automatic inline extent activation.
Patch 3: Tracepoints for inline extent lookup and update operations.
Test setup (Xiaomi smartphone, UFS 4.0 storage):
echo 1 > /sys/fs/f2fs/<dev>/inline_extent_enable
echo 'mp4:256' > /sys/fs/f2fs/<dev>/inline_extent_extension_list
fio --name=test --filename=data.mp4 --rw=write:4k --bs=64M \
--size=8G --ioengine=libaio --direct=1
sync
fio --name=test --filename=data.mp4 --rw=write --bs=64M \
--size=8G --ioengine=libaio --direct=1
sync
echo 3 > /proc/sys/vm/drop_caches
fio --name=buffer-read --ioengine=libaio --rw=randread --bs=$BS \
--size=8G --io_size=1G --numjobs=1 --filename=data.mp4Results (random read bandwidth, MiB/s):
+---------------------------------------------------+ | BS | baseline | inline ext | improvement | |--------+----------+------------+------------------| | 4K | 31.6 | 32.4 | +2.5% | | 8K | 55.4 | 58.5 | +5.6% | | 32K | 155.3 | 166.8 | +7.4% | | 64K | 229.8 | 255.3 | +11.1% | | 128K | 337.8 | 388 | +14.9% | +---------------------------------------------------+
The improvement comes from eliminating indirect/double-indirect node page reads during block address lookup -- indirect-block mappings are stored directly in the inode page and found via binary search.
Yongpeng Yang (3):
f2fs: introduce inline extent mapping for inode data blocks
f2fs: add sysfs interface for inline extent management
f2fs: introduce tracepoints for inline extent lookup and update
fs/f2fs/Kconfig | 18 + fs/f2fs/Makefile | 1 + fs/f2fs/data.c | 148 ++++++- fs/f2fs/debug.c | 4 + fs/f2fs/dir.c | 1 + fs/f2fs/f2fs.h | 44 ++- fs/f2fs/file.c | 1 + fs/f2fs/iextent.c | 759 ++++++++++++++++++++++++++++++++++++ fs/f2fs/iextent.h | 166 ++++++++ fs/f2fs/inline.c | 1 + fs/f2fs/inode.c | 41 +- fs/f2fs/namei.c | 67 ++++ fs/f2fs/node.c | 38 +- fs/f2fs/node.h | 4 + fs/f2fs/recovery.c | 15 + fs/f2fs/super.c | 29 ++ fs/f2fs/sysfs.c | 91 +++++ include/linux/f2fs_fs.h | 3 +- include/trace/events/f2fs.h | 79 ++++ 19 files changed, 1489 insertions(+), 21 deletions(-) create mode 100644 fs/f2fs/iextent.c create mode 100644 fs/f2fs/iextent.h
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH v3 1/3 f2fs: introduce inline extent mapping for inode data blocks
From: Yongpeng Yang <[email protected]>
Introduce an inline extent mapping mechanism that stores extent entries directly within the inode's extra attribute area. This eliminates indirect node lookups for frequently accessed file blocks.
Key design points:
- Inline extent area is placed after i_extra_end in the on-disk inode, within the i_extra_isize region. Its size is determined by the new field i_inline_ext_capacity (number of extent entries).
- Split the existing __le64 i_compr_blocks into __le32 i_compr_blocks + __le32 i_inline_ext_capacity to avoid enlarging the inode.
- Inline extent only caches mappings for indirect blocks (fofs >= ADDRS_PER_INODE). Direct block mappings continue to use i_addr[].
- Per-inode capacity is determined at file creation time based on extension matching rules.
- Supports a mount option inline_extent_size=<N> to set the default capacity for new inodes.
- Mutually exclusive with compression (compressed files cannot use inline extent).
The implementation includes:
- Binary search based extent lookup and insertion with merge/split support in fs/f2fs/iextent.c
- Integration with data block allocation and truncation paths
- Proper recovery handling (inline extent cleared during fsync replay)
- Kconfig option CONFIG_F2FS_INLINE_EXTENT to enable the feature
Test setup (Xiaomi smartphone, UFS 4.0 storage):
echo 1 > /sys/fs/f2fs/<dev>/inline_extent_enable
echo 'mp4:256' > /sys/fs/f2fs/<dev>/inline_extent_extension_list
fio --name=test --filename=data.mp4 --rw=write:4k --bs=64M \
--size=8G --ioengine=libaio --direct=1
sync
fio --name=test --filename=data.mp4 --rw=write --bs=64M \
--size=8G --ioengine=libaio --direct=1
sync
echo 3 > /proc/sys/vm/drop_caches
fio --name=buffer-read --ioengine=libaio --rw=randread --bs=$BS \
--size=8G --io_size=1G --numjobs=1 --filename=data.mp4Results (random read bandwidth, MiB/s):
+---------------------------------------------------+ | BS | baseline | inline ext | improvement | |--------+----------+------------+------------------| | 4K | 31.6 | 32.4 | +2.5% | | 8K | 55.4 | 58.5 | +5.6% | | 32K | 155.3 | 166.8 | +7.4% | | 64K | 229.8 | 255.3 | +11.1% | | 128K | 337.8 | 388 | +14.9% | +---------------------------------------------------+
---
v3:
- Modify inline extent format.
- Split struct f2fs_inode->i_compr_blocks (was __le64) into __le32 and __le32 i_inline_ext_capacity.
- Re-ran the performance tests.
v2:
- Bypass inline extent lookup for F2FS_GET_BLOCK_PRECACHE.
- Unify fofs range check to "fofs >= direct_blocks".
- Remove NULL_ADDR caching support; simplify merge/split logic.
- Change f2fs_iext_convert_to_inline_extent return type to bool.
- Rename __is_extent_mergeable to __is_iextent_mergeable.
- Remove inode parameter from f2fs_iext_sanity_check.
- Reduce #ifdef nesting in node.c.
- Add complete benchmark data (4K/8K/32K/64K).
- Code style fixes.
--- fs/f2fs/Kconfig | 18 + fs/f2fs/Makefile | 1 + fs/f2fs/data.c | 148 ++++++++- fs/f2fs/dir.c | 1 + fs/f2fs/f2fs.h | 44 ++- fs/f2fs/file.c | 1 + fs/f2fs/iextent.c | 712 ++++++++++++++++++++++++++++++++++++++++ fs/f2fs/iextent.h | 163 +++++++++ fs/f2fs/inline.c | 1 + fs/f2fs/inode.c | 41 ++- fs/f2fs/namei.c | 67 ++++ fs/f2fs/node.c | 38 ++- fs/f2fs/node.h | 4 + fs/f2fs/recovery.c | 15 + fs/f2fs/super.c | 29 ++ include/linux/f2fs_fs.h | 3 +- 16 files changed, 1265 insertions(+), 21 deletions(-) create mode 100644 fs/f2fs/iextent.c create mode 100644 fs/f2fs/iextent.h
fs/f2fs/Kconfig +18 -0
@@ -150,3 +150,21 @@ config F2FS_UNFAIR_RWSEM help Use unfair rw_semaphore, if system configured IO priority by block cgroup. + +config F2FS_INLINE_EXTENT + bool "F2FS inline extent" + depends on F2FS_FS + default y + help + Support the inline extent feature: leverage the inode's data block + address area to store extent-format mapping relationships, replacing + individual block addresses with compact extent entries to optimize + large file random reads. + +config F2FS_INLINE_EXTENT_DEBUG + bool "F2FS inline extent debug" + depends on F2FS_INLINE_EXTENT + default n + help + Support inline extent debug to stat code coverage and extents + consistency check.
fs/f2fs/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_F2FS_FS) += f2fs.o f2fs-y := dir.o file.o inode.o namei.o hash.o super.o inline.o f2fs-y += checkpoint.o gc.o data.o node.o segment.o recovery.o f2fs-y += shrinker.o extent_cache.o sysfs.o +f2fs-$(CONFIG_F2FS_INLINE_EXTENT) += iextent.o f2fs-$(CONFIG_F2FS_STAT_FS) += debug.o f2fs-$(CONFIG_F2FS_FS_XATTR) += xattr.o f2fs-$(CONFIG_F2FS_FS_POSIX_ACL) += acl.o
fs/f2fs/data.c +147 -1
189 lines not on this page · raw message
fs/f2fs/dir.c +1 -0
@@ -16,6 +16,7 @@#include "node.h" #include "acl.h" #include "xattr.h" +#include "iextent.h" #include <trace/events/f2fs.h> static inline bool f2fs_should_fallback_to_linear (struct inode *dir)
fs/f2fs/f2fs.h +42 -2
109 lines not on this page · raw message
fs/f2fs/file.c +1 -0
@@ -33,6 +33,7 @@#include "acl.h" #include "gc.h" #include "iostat.h" +#include "iextent.h" #include <trace/events/f2fs.h> #include <uapi/linux/f2fs.h>
fs/f2fs/iextent.c new file +712 -0
712 lines not on this page · raw message
fs/f2fs/iextent.h new file +163 -0
163 lines not on this page · raw message
fs/f2fs/inline.c +1 -0
@@ -13,6 +13,7 @@#include "f2fs.h" #include "node.h" +#include "iextent.h" #include <trace/events/f2fs.h> static bool support_inline_data (struct inode *inode)
fs/f2fs/inode.c +32 -9
87 lines not on this page · raw message
fs/f2fs/namei.c +67 -0
91 lines not on this page · raw message
fs/f2fs/node.c +30 -8
@@ -19,6 +19,7 @@#include "segment.h" #include "xattr.h" #include "iostat.h" +#include "iextent.h" #include <trace/events/f2fs.h> #define on_f2fs_build_free_nids (nm_i) mutex_is_locked(&(nm_i)->build_lock)
@@ -819,6 +820,7 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)nid_t nids[4 ];int level, i =0 ;int err =0 ; +bool lock_ifolio = false; level =get_node_path (dn->inode, index, offset, noffset);if (level <0 )
@@ -846,6 +848,8 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode) nids[1 ] =get_nid (parent, offset[0 ], true); dn->inode_folio = nfolio[0 ]; dn->inode_folio_locked = true; +if (f2fs_iext_support_inline_extent (dn->inode,NULL )) + lock_ifolio = true;/* get indirect or direct nodes */ for (i =1 ; i <= level; i++) {
@@ -888,8 +892,10 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode) done = true; }if (i ==1 ) { - dn->inode_folio_locked = false; -folio_unlock (parent); +if (!lock_ifolio) { + dn->inode_folio_locked = false; +folio_unlock (parent); + } }else {f2fs_folio_put (parent, true); }
@@ -899,7 +905,8 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode) NODE_TYPE_NON_INODE);if (IS_ERR (nfolio[i])) { err =PTR_ERR (nfolio[i]); -f2fs_folio_put (nfolio[0 ], false); +f2fs_folio_put (nfolio[0 ], + dn->inode_folio_locked); goto release_out; } }
@@ -945,7 +952,7 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode) release_pages:f2fs_folio_put (parent, true);if (i >1 ) -f2fs_folio_put (nfolio[0 ], false); +f2fs_folio_put (nfolio[0 ], dn->inode_folio_locked); release_out: dn->inode_folio =NULL ; dn->node_folio =NULL ;
@@ -1194,6 +1201,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)unsigned int nofs =0 ;struct dnode_of_data dn;struct folio *folio; +bool lock_ifolio = false;trace_f2fs_truncate_inode_blocks_enter (inode, from);
@@ -1217,7 +1225,11 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from) }set_new_dnode (&dn, inode, folio,NULL ,0 ); -folio_unlock (folio); +if (f2fs_iext_support_inline_extent (inode,NULL )) { + lock_ifolio = true; +f2fs_iext_truncate_from_blkaddr (inode, folio, from); + }else +folio_unlock (folio);switch (level) {case 0 :
@@ -1282,17 +1294,19 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)if (err <0 ) goto fail;if (offset[1 ] ==0 &&get_nid (folio, offset[0 ], true)) { -folio_lock (folio); +if (!lock_ifolio) +folio_lock (folio);BUG_ON (!is_node_folio (folio));set_nid (folio, offset[0 ],0 , true); -folio_unlock (folio); +if (!lock_ifolio) +folio_unlock (folio); } offset[1 ] =0 ; offset[0 ]++; nofs += err; } fail: -f2fs_folio_put (folio, false); +f2fs_folio_put (folio, lock_ifolio);trace_f2fs_truncate_inode_blocks_exit (inode, err);return err >0 ?0 : err; }
@@ -1612,6 +1626,14 @@ static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid, err = -EFSBADCRC ; goto out_err; } +#ifdef CONFIG_F2FS_INLINE_EXTENT +if (IS_INODE (folio) && +f2fs_iext_support_inline_extent (NULL , folio) && + !f2fs_iext_sanity_check (folio)) { + err = -EINVAL ; + goto out_err; + } +#endif page_hit: err =f2fs_sanity_check_node_footer (sbi, folio, nid, ntype, false);if (!err)
fs/f2fs/node.h +4 -0
@@ -259,6 +259,10 @@ static inline unsigned int ofs_of_node(const struct folio *node_folio)return flag >>OFFSET_BIT_SHIFT ; } +int f2fs_iext_data_blkaddr (struct inode *inode, +struct folio *node_folio,unsigned int offset, +block_t *blkaddr); +static inline __u64 cpver_of_node (const struct folio *node_folio) {struct f2fs_node *rn =F2FS_NODE (node_folio);
fs/f2fs/recovery.c +15 -0
@@ -13,6 +13,7 @@#include "f2fs.h" #include "node.h" #include "segment.h" +#include "iextent.h" /* * Roll forward recovery scenarios.
@@ -665,6 +666,20 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, } goto out; } +#ifdef CONFIG_F2FS_INLINE_EXTENT +if (f2fs_iext_support_inline_extent (inode, + dn.inode_folio)) { +f2fs_bug_on (F2FS_I_SB (inode), + !dn.inode_folio_locked); +f2fs_bug_on (F2FS_I_SB (inode), + !folio_test_locked (dn.inode_folio)); +f2fs_folio_wait_writeback (dn.inode_folio,NODE , true, true); +if (EXT_ENTRY_COUNT (iext_get_header (dn.inode_folio)) >0 ) { +f2fs_iext_init_inline_extent (inode, dn.inode_folio); +folio_mark_dirty (dn.inode_folio); + } + } +#endif f2fs_folio_wait_writeback (dn.node_folio,NODE , true, true);
fs/f2fs/super.c +29 -0
@@ -37,6 +37,7 @@#include "xattr.h" #include "gc.h" #include "iostat.h" +#include "iextent.h" #define CREATE_TRACE_POINTS #include <trace/events/f2fs.h>
@@ -235,6 +236,7 @@ enum { Opt_jqfmt, Opt_checkpoint, Opt_lookup_mode, + Opt_inline_extent_size, Opt_err, };
@@ -320,6 +322,7 @@ static const struct fs_parameter_spec f2fs_param_specs[] = {fsparam_s32 ("inline_xattr_size" , Opt_inline_xattr_size),fsparam_flag_no ("inline_data" , Opt_inline_data),fsparam_flag_no ("inline_dentry" , Opt_inline_dentry), +fsparam_u32 ("inline_extent_size" , Opt_inline_extent_size),fsparam_flag_no ("flush_merge" , Opt_flush_merge),fsparam_flag_no ("barrier" , Opt_barrier), fsparam_flag("fastboot", Opt_fastboot),
@@ -404,6 +407,7 @@ static match_table_t f2fs_checkpoint_tokens = {#define F2FS_SPEC_errors (1 << 23)#define F2FS_SPEC_lookup_mode (1 << 24)#define F2FS_SPEC_reserve_node (1 << 25) +#define F2FS_SPEC_inline_extent_size (1 << 26)struct f2fs_fs_context {struct f2fs_mount_info info;
@@ -850,6 +854,13 @@ static int f2fs_parse_param(struct fs_context *fc, struct fs_parameter *param)F2FS_CTX_INFO (ctx).inline_xattr_size = result.int_32; ctx->spec_mask |= F2FS_SPEC_inline_xattr_size;break ; +#ifdef CONFIG_F2FS_INLINE_EXTENT +case Opt_inline_extent_size: +ctx_set_opt (ctx,F2FS_MOUNT_INLINE_EXTENT_SIZE ); +F2FS_CTX_INFO (ctx).inline_extent_size = result.uint_32; + ctx->spec_mask |= F2FS_SPEC_inline_extent_size; +break ; +#endif #else case Opt_user_xattr:case Opt_inline_xattr:
@@ -1763,6 +1774,8 @@ static void f2fs_apply_options(struct fs_context *fc, struct super_block *sb)F2FS_OPTION (sbi).errors =F2FS_CTX_INFO (ctx).errors;if (ctx->spec_mask & F2FS_SPEC_lookup_mode)F2FS_OPTION (sbi).lookup_mode =F2FS_CTX_INFO (ctx).lookup_mode; +if (ctx->spec_mask & F2FS_SPEC_inline_extent_size) +F2FS_OPTION (sbi).inline_extent_size =F2FS_CTX_INFO (ctx).inline_extent_size;f2fs_apply_compression (fc, sb);f2fs_apply_test_dummy_encryption (fc, sb);
@@ -2432,6 +2445,11 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)seq_puts (seq,",inline_dentry" ); else seq_puts(seq, ",noinline_dentry"); +#ifdef CONFIG_F2FS_INLINE_EXTENT +if (test_opt (sbi,INLINE_EXTENT_SIZE )) +seq_printf (seq,",inline_extent_size=%u" , +F2FS_OPTION (sbi).inline_extent_size); +#endif if (test_opt (sbi,FLUSH_MERGE ))seq_puts (seq,",flush_merge" );else
@@ -5139,6 +5157,11 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)/* disallow all the data/node/meta page writes */ set_sbi_flag (sbi,SBI_POR_DOING ); +#ifdef CONFIG_F2FS_INLINE_EXTENT + err =f2fs_iext_info_init (sbi); +if (err) + goto free_bio_info; +#endif err =f2fs_init_write_merge_io (sbi);if (err) goto free_bio_info;
@@ -5499,6 +5522,9 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)utf8_unload (sb->s_encoding); sb->s_encoding =NULL ;#endif +#ifdef CONFIG_F2FS_INLINE_EXTENT +f2fs_iext_info_destroy (sbi); +#endif free_options:#ifdef CONFIG_QUOTA for (i =0 ; i <MAXQUOTAS ; i++)
@@ -5595,6 +5621,9 @@ static void kill_f2fs_super(struct super_block *sb)destroy_device_list (sbi);#ifdef CONFIG_DEBUG_LOCK_ALLOC lockdep_unregister_key (&sbi->cp_global_sem_key); +#endif +#ifdef CONFIG_F2FS_INLINE_EXTENT +f2fs_iext_info_destroy (sbi);#endif kfree (sbi); sb->s_fs_info =NULL ;
include/linux/f2fs_fs.h +2 -1
@@ -330,7 +330,8 @@ struct f2fs_inode {__le32 i_inode_checksum;/* inode meta checksum */ __le64 i_crtime;/* creation time */ __le32 i_crtime_nsec;/* creation time in nano scale */ -__le64 i_compr_blocks;/* # of compressed blocks */ +__le32 i_compr_blocks;/* # of compressed blocks */ +__le32 i_inline_ext_capacity;/* # of inline extent entries */ __u8 i_compress_algorithm;/* compress algorithm */ __u8 i_log_cluster_size;/* log of cluster size */ __le16 i_compress_flag;/* compress flag */
Signature · 1 line
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 8 lines · Yongpeng Yang
fs/f2fs/Kconfig | 18 + fs/f2fs/Makefile | 1 + fs/f2fs/data.c | 148 ++++++++- fs/f2fs/dir.c | 1 + fs/f2fs/f2fs.h | 44 ++- fs/f2fs/file.c | 1 + fs/f2fs/iextent.c | 712 ++++++++++++++++++++++++++++++++++++++++ fs/f2fs/iextent.h | 163 +++++++++
Hmmm, the code size is still a problem, too complicated to support all insertion, deletion, merging and splitting operations on inline extents.
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 10 lines · On 7/29/26 20:19, Chao Yu via Linux-f2fs-devel wrote:
Quoted 8 lines · Yongpeng Yang
fs/f2fs/Kconfig | 18 + fs/f2fs/Makefile | 1 + fs/f2fs/data.c | 148 ++++++++- fs/f2fs/dir.c | 1 + fs/f2fs/f2fs.h | 44 ++- fs/f2fs/file.c | 1 + fs/f2fs/iextent.c | 712 ++++++++++++++++++++++++++++++++++++++++ fs/f2fs/iextent.h | 163 +++++++++
Quoted 2 lines
Hmmm, the code size is still a problem, too complicated to support all insertion, deletion, merging and splitting operations on inline extents.
I simplify inline extent update implementation in v4. Please review this series:
https://lore.kernel.org/all/[email protected]/
Thanks,
Yongpeng
Quoted 8 lines
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH v3 2/3 f2fs: add sysfs interface for inline extent management
In reply to Yongpeng YangFrom: Yongpeng Yang <[email protected]>
Add sysfs interfaces for runtime management of the inline extent feature:
- inline_extent_extension_list: read/write the file extension list that triggers inline extent allocation. Format for writing:
"ext" or "ext:capacity" to add (with optional per-extension capacity), "!ext" to remove.
Reading shows all extensions with their capacity settings.
- inline_extent_enable: toggle inline extent allocation on/off at runtime (0 or 1).
- Export inline extent debug statistics (code coverage counters for merge, split, insert, evict operations) via /sys/kernel/debug/f2fs/status when CONFIG_F2FS_INLINE_EXTENT_DEBUG is enabled.
---
v3:
- Config per-inode capacity via sysfs.
--- fs/f2fs/debug.c | 4 +++ fs/f2fs/iextent.c | 38 ++++++++++++++++++++ fs/f2fs/iextent.h | 3 ++ fs/f2fs/sysfs.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+)
fs/f2fs/debug.c +4 -0
@@ -19,6 +19,7 @@#include "node.h" #include "segment.h" #include "gc.h" +#include "iextent.h" static LIST_HEAD (f2fs_stat_list);static DEFINE_SPINLOCK (f2fs_stat_lock);
@@ -758,6 +759,9 @@ static int stat_show(struct seq_file *s, void *v) si->ext_mem[EX_BLOCK_AGE] >> 10);seq_printf (s," - paged : %llu KB\n" , si->page_mem >>10 ); +#ifdef CONFIG_F2FS_INLINE_EXTENT_DEBUG +f2fs_iext_show_stat (sbi, s); +#endif }spin_unlock (&f2fs_stat_lock);return 0 ;
fs/f2fs/iextent.c +38 -0
@@ -6,6 +6,7 @@* http://www.mi.com/ */ #include <linux/f2fs_fs.h> +#include <linux/seq_file.h> #include "f2fs.h" #include "iextent.h"
@@ -710,3 +711,40 @@ int f2fs_iext_update_extension_list(struct f2fs_sb_info *sbi, const char *name,spin_unlock_irqrestore (&iext_info->iext_ext_lock, flag);return ret; } + +#ifdef CONFIG_F2FS_INLINE_EXTENT_DEBUG +void f2fs_iext_show_stat (struct f2fs_sb_info *sbi,struct seq_file *s) +{ +struct f2fs_iext_info *iext_info = sbi->iext_info; + +seq_printf (s,"Inline extent code coverage statistics:\n" +" - left_merge_count: %llu\n" +" - right_merge_count: %llu\n" +" - fast_right_merge_count: %llu\n" +" - lr_merge_count: %llu\n" +" - split_left_count: %llu\n" +" - split_right_count: %llu\n" +" - split_mid_count: %llu\n" +" - insert_new_ext_count: %llu\n" +" - overwrite_ext_count: %llu\n" +" - add_ext_count: %llu\n" +" - del_ext_count: %llu\n" +" - evict_last_ext_cnt: %llu\n" +" - truncate_last_ext_cnt: %llu\n" +" - drop_insert_new_ext_cnt: %llu\n" , +atomic64_read (&iext_info->left_merge_count), +atomic64_read (&iext_info->right_merge_count), +atomic64_read (&iext_info->fast_right_merge_count), +atomic64_read (&iext_info->lr_merge_count), +atomic64_read (&iext_info->split_left_count), +atomic64_read (&iext_info->split_right_count), +atomic64_read (&iext_info->split_mid_count), +atomic64_read (&iext_info->insert_new_ext_count), +atomic64_read (&iext_info->overwrite_ext_count), +atomic64_read (&iext_info->add_ext_count), +atomic64_read (&iext_info->del_ext_count), +atomic64_read (&iext_info->evict_last_ext_cnt), +atomic64_read (&iext_info->truncate_last_ext_cnt), +atomic64_read (&iext_info->drop_insert_new_ext_cnt)); +} +#endif
fs/f2fs/iextent.h +3 -0
@@ -160,4 +160,7 @@ int f2fs_iext_update_extension_list(struct f2fs_sb_info *sbi, const char *name, bool set, unsigned int capacity);int f2fs_iext_info_init (struct f2fs_sb_info *sbi);void f2fs_iext_info_destroy (struct f2fs_sb_info *sbi); +#ifdef CONFIG_F2FS_INLINE_EXTENT_DEBUG +void f2fs_iext_show_stat (struct f2fs_sb_info *sbi,struct seq_file *s); +#endif #endif
fs/f2fs/sysfs.c +91 -0
139 lines not on this page · raw message
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH v3 3/3 f2fs: introduce tracepoints for inline extent lookup and update
In reply to Yongpeng YangFrom: Yongpeng Yang <[email protected]>
Add tracepoints to aid performance analysis and debugging of the inline extent mechanism:
- trace_f2fs_iext_lookup_blkaddr_start: fired at the beginning of an inline extent lookup, recording the inode and logical block offset.
- trace_f2fs_iext_lookup_blkaddr_end: fired on successful lookup, recording the inode, logical offset, resolved physical block address, and extent length.
- trace_f2fs_iext_update_data_blkaddr: fired when updating a block mapping in the inline extent area, recording the inode, logical offset, and new physical block address.
These tracepoints can be used with ftrace/perf to measure inline extent cache hit rates and identify hot files benefiting from the feature.
--- fs/f2fs/iextent.c | 11 +++++- include/trace/events/f2fs.h | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-)
fs/f2fs/iextent.c +10 -1
@@ -10,6 +10,7 @@#include "f2fs.h" #include "iextent.h" +#include <trace/events/f2fs.h> /* * ASSERT - debug assertion for inline extent code.
@@ -482,12 +483,18 @@ int f2fs_iext_lookup_blkaddr(struct inode *inode, struct folio *ifolio,struct f2fs_iext_header *eh =iext_get_header (ifolio);struct f2fs_extent *last_ext =EXT_LAST_INDEX (eh); +trace_f2fs_iext_lookup_blkaddr_start (inode, fofs); +if (EXT_ENTRY_COUNT (eh) ==0 ||F2FS_EXT_LOGICAL_END (last_ext) < fofs) error = -ENOENT ;else error =__iext_lookup_data_blkaddr (inode, ifolio, fofs, blkaddr, len); +if (!error) +trace_f2fs_iext_lookup_blkaddr_end (inode, fofs, + *blkaddr, len ? *len :1 ); +return error; }
@@ -522,6 +529,8 @@ int f2fs_iext_update_data_blkaddr(struct inode *inode, struct folio *ifolio,struct f2fs_iext_info *iext_info = sbi->iext_info;#endif +trace_f2fs_iext_update_data_blkaddr (inode, fofs, blkaddr); + retry:ASSERT (sbi, retry_cnt >=0 );ASSERT (sbi,EXT_ENTRY_COUNT (eh) <= max_inline_extents);
@@ -747,4 +756,4 @@ void f2fs_iext_show_stat(struct f2fs_sb_info *sbi, struct seq_file *s)atomic64_read (&iext_info->truncate_last_ext_cnt), atomic64_read(&iext_info->drop_insert_new_ext_cnt)); } -#endif +#endif
include/trace/events/f2fs.h +79 -0
85 lines not on this page · raw message
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel