Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: Remove the logic to trim inode PAs

Earlier, inode PAs were stored in a linked list. This caused a need to
periodically trim the list down inorder to avoid growing it to a very
large size, as this would severly affect performance during list
iteration.

Recent patches changed this list to an rbtree, and since the tree scales
up much better, we no longer need to have the trim functionality, hence
remove it.

Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/c409addceaa3ade4b40328e28e3b54b2f259689e.1679731817.git.ojaswin@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Ojaswin Mujoo and committed by
Theodore Ts'o
361eb69f 38727786

-31
-3
Documentation/admin-guide/ext4.rst
··· 489 489 multiple of this tuning parameter if the stripe size is not set in the 490 490 ext4 superblock 491 491 492 - mb_max_inode_prealloc 493 - The maximum length of per-inode ext4_prealloc_space list. 494 - 495 492 mb_max_to_scan 496 493 The maximum number of extents the multiblock allocator will search to 497 494 find the best extent.
-1
fs/ext4/ext4.h
··· 1613 1613 unsigned int s_mb_stats; 1614 1614 unsigned int s_mb_order2_reqs; 1615 1615 unsigned int s_mb_group_prealloc; 1616 - unsigned int s_mb_max_inode_prealloc; 1617 1616 unsigned int s_max_dir_size_kb; 1618 1617 /* where last allocation was done - for stream allocation */ 1619 1618 unsigned long s_mb_last_group;
-20
fs/ext4/mballoc.c
··· 3417 3417 sbi->s_mb_stats = MB_DEFAULT_STATS; 3418 3418 sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD; 3419 3419 sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS; 3420 - sbi->s_mb_max_inode_prealloc = MB_DEFAULT_MAX_INODE_PREALLOC; 3421 3420 /* 3422 3421 * The default group preallocation is 512, which for 4k block 3423 3422 * sizes translates to 2 megabytes. However for bigalloc file ··· 5601 5602 } 5602 5603 5603 5604 /* 5604 - * if per-inode prealloc list is too long, trim some PA 5605 - */ 5606 - static void ext4_mb_trim_inode_pa(struct inode *inode) 5607 - { 5608 - struct ext4_inode_info *ei = EXT4_I(inode); 5609 - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 5610 - int count, delta; 5611 - 5612 - count = atomic_read(&ei->i_prealloc_active); 5613 - delta = (sbi->s_mb_max_inode_prealloc >> 2) + 1; 5614 - if (count > sbi->s_mb_max_inode_prealloc + delta) { 5615 - count -= sbi->s_mb_max_inode_prealloc; 5616 - ext4_discard_preallocations(inode, count); 5617 - } 5618 - } 5619 - 5620 - /* 5621 5605 * release all resource we used in allocation 5622 5606 */ 5623 5607 static int ext4_mb_release_context(struct ext4_allocation_context *ac) 5624 5608 { 5625 - struct inode *inode = ac->ac_inode; 5626 5609 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); 5627 5610 struct ext4_prealloc_space *pa = ac->ac_pa; 5628 5611 if (pa) { ··· 5640 5659 if (ac->ac_flags & EXT4_MB_HINT_GROUP_ALLOC) 5641 5660 mutex_unlock(&ac->ac_lg->lg_mutex); 5642 5661 ext4_mb_collect_stats(ac); 5643 - ext4_mb_trim_inode_pa(inode); 5644 5662 return 0; 5645 5663 } 5646 5664
-5
fs/ext4/mballoc.h
··· 74 74 #define MB_DEFAULT_GROUP_PREALLOC 512 75 75 76 76 /* 77 - * maximum length of inode prealloc list 78 - */ 79 - #define MB_DEFAULT_MAX_INODE_PREALLOC 512 80 - 81 - /* 82 77 * Number of groups to search linearly before performing group scanning 83 78 * optimization. 84 79 */
-2
fs/ext4/sysfs.c
··· 214 214 EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); 215 215 EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request); 216 216 EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); 217 - EXT4_RW_ATTR_SBI_UI(mb_max_inode_prealloc, s_mb_max_inode_prealloc); 218 217 EXT4_RW_ATTR_SBI_UI(mb_max_linear_groups, s_mb_max_linear_groups); 219 218 EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb); 220 219 EXT4_ATTR(trigger_fs_error, 0200, trigger_test_error); ··· 263 264 ATTR_LIST(mb_order2_req), 264 265 ATTR_LIST(mb_stream_req), 265 266 ATTR_LIST(mb_group_prealloc), 266 - ATTR_LIST(mb_max_inode_prealloc), 267 267 ATTR_LIST(mb_max_linear_groups), 268 268 ATTR_LIST(max_writeback_mb_bump), 269 269 ATTR_LIST(extent_max_zeroout_kb),