@@ -157,7 +157,7 @@ enum criteria {
157157
158158 /*
159159 * Reads each block group sequentially, performing disk IO if
160- * necessary, to find find_suitable block group. Tries to
160+ * necessary, to find suitable block group. Tries to
161161 * allocate goal length but might trim the request if nothing
162162 * is found after enough tries.
163163 */
@@ -185,14 +185,8 @@ enum criteria {
185185
186186/* prefer goal again. length */
187187#define EXT4_MB_HINT_MERGE 0x0001
188- /* blocks already reserved */
189- #define EXT4_MB_HINT_RESERVED 0x0002
190- /* metadata is being allocated */
191- #define EXT4_MB_HINT_METADATA 0x0004
192188/* first blocks in the file */
193189#define EXT4_MB_HINT_FIRST 0x0008
194- /* search for the best chunk */
195- #define EXT4_MB_HINT_BEST 0x0010
196190/* data is being allocated */
197191#define EXT4_MB_HINT_DATA 0x0020
198192/* don't preallocate (for tails) */
@@ -213,15 +207,6 @@ enum criteria {
213207#define EXT4_MB_USE_RESERVED 0x2000
214208/* Do strict check for free blocks while retrying block allocation */
215209#define EXT4_MB_STRICT_CHECK 0x4000
216- /* Large fragment size list lookup succeeded at least once for
217- * CR_POWER2_ALIGNED */
218- #define EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED 0x8000
219- /* Avg fragment size rb tree lookup succeeded at least once for
220- * CR_GOAL_LEN_FAST */
221- #define EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED 0x00010000
222- /* Avg fragment size rb tree lookup succeeded at least once for
223- * CR_BEST_AVAIL_LEN */
224- #define EXT4_MB_CR_BEST_AVAIL_LEN_OPTIMIZED 0x00020000
225210
226211struct ext4_allocation_request {
227212 /* target inode for block we're allocating */
@@ -1608,16 +1593,14 @@ struct ext4_sb_info {
16081593 unsigned short * s_mb_offsets ;
16091594 unsigned int * s_mb_maxs ;
16101595 unsigned int s_group_info_size ;
1611- unsigned int s_mb_free_pending ;
1596+ atomic_t s_mb_free_pending ;
16121597 struct list_head s_freed_data_list [2 ]; /* List of blocks to be freed
16131598 after commit completed */
16141599 struct list_head s_discard_list ;
16151600 struct work_struct s_discard_work ;
16161601 atomic_t s_retry_alloc_pending ;
1617- struct list_head * s_mb_avg_fragment_size ;
1618- rwlock_t * s_mb_avg_fragment_size_locks ;
1619- struct list_head * s_mb_largest_free_orders ;
1620- rwlock_t * s_mb_largest_free_orders_locks ;
1602+ struct xarray * s_mb_avg_fragment_size ;
1603+ struct xarray * s_mb_largest_free_orders ;
16211604
16221605 /* tunables */
16231606 unsigned long s_stripe ;
@@ -1629,15 +1612,16 @@ struct ext4_sb_info {
16291612 unsigned int s_mb_order2_reqs ;
16301613 unsigned int s_mb_group_prealloc ;
16311614 unsigned int s_max_dir_size_kb ;
1632- /* where last allocation was done - for stream allocation */
1633- unsigned long s_mb_last_group ;
1634- unsigned long s_mb_last_start ;
16351615 unsigned int s_mb_prefetch ;
16361616 unsigned int s_mb_prefetch_limit ;
16371617 unsigned int s_mb_best_avail_max_trim_order ;
16381618 unsigned int s_sb_update_sec ;
16391619 unsigned int s_sb_update_kb ;
16401620
1621+ /* where last allocation was done - for stream allocation */
1622+ ext4_group_t * s_mb_last_groups ;
1623+ unsigned int s_mb_nr_global_goals ;
1624+
16411625 /* stats for buddy allocator */
16421626 atomic_t s_bal_reqs ; /* number of reqs with len > 1 */
16431627 atomic_t s_bal_success ; /* we found long enough chunks */
@@ -1646,12 +1630,10 @@ struct ext4_sb_info {
16461630 atomic_t s_bal_cX_ex_scanned [EXT4_MB_NUM_CRS ]; /* total extents scanned */
16471631 atomic_t s_bal_groups_scanned ; /* number of groups scanned */
16481632 atomic_t s_bal_goals ; /* goal hits */
1633+ atomic_t s_bal_stream_goals ; /* stream allocation global goal hits */
16491634 atomic_t s_bal_len_goals ; /* len goal hits */
16501635 atomic_t s_bal_breaks ; /* too long searches */
16511636 atomic_t s_bal_2orders ; /* 2^order hits */
1652- atomic_t s_bal_p2_aligned_bad_suggestions ;
1653- atomic_t s_bal_goal_fast_bad_suggestions ;
1654- atomic_t s_bal_best_avail_bad_suggestions ;
16551637 atomic64_t s_bal_cX_groups_considered [EXT4_MB_NUM_CRS ];
16561638 atomic64_t s_bal_cX_hits [EXT4_MB_NUM_CRS ];
16571639 atomic64_t s_bal_cX_failed [EXT4_MB_NUM_CRS ]; /* cX loop didn't find blocks */
@@ -3020,7 +3002,7 @@ int ext4_walk_page_buffers(handle_t *handle,
30203002 struct buffer_head * bh ));
30213003int do_journal_get_write_access (handle_t * handle , struct inode * inode ,
30223004 struct buffer_head * bh );
3023- bool ext4_should_enable_large_folio (struct inode * inode );
3005+ void ext4_set_inode_mapping_order (struct inode * inode );
30243006#define FALL_BACK_TO_NONDELALLOC 1
30253007#define CONVERT_INLINE_DATA 2
30263008
@@ -3064,9 +3046,9 @@ extern int ext4_punch_hole(struct file *file, loff_t offset, loff_t length);
30643046extern void ext4_set_inode_flags (struct inode * , bool init );
30653047extern int ext4_alloc_da_blocks (struct inode * inode );
30663048extern void ext4_set_aops (struct inode * inode );
3067- extern int ext4_writepage_trans_blocks (struct inode * );
30683049extern int ext4_normal_submit_inode_data_buffers (struct jbd2_inode * jinode );
30693050extern int ext4_chunk_trans_blocks (struct inode * , int nrblocks );
3051+ extern int ext4_chunk_trans_extent (struct inode * inode , int nrblocks );
30703052extern int ext4_meta_trans_blocks (struct inode * inode , int lblocks ,
30713053 int pextents );
30723054extern int ext4_zero_partial_blocks (handle_t * handle , struct inode * inode ,
@@ -3489,8 +3471,6 @@ struct ext4_group_info {
34893471 void * bb_bitmap ;
34903472#endif
34913473 struct rw_semaphore alloc_sem ;
3492- struct list_head bb_avg_fragment_size_node ;
3493- struct list_head bb_largest_free_order_node ;
34943474 ext4_grpblk_t bb_counters []; /* Nr of free power-of-two-block
34953475 * regions, index is order.
34963476 * bb_counters[3] = 5 means
@@ -3541,23 +3521,28 @@ static inline int ext4_fs_is_busy(struct ext4_sb_info *sbi)
35413521 return (atomic_read (& sbi -> s_lock_busy ) > EXT4_CONTENTION_THRESHOLD );
35423522}
35433523
3524+ static inline bool ext4_try_lock_group (struct super_block * sb , ext4_group_t group )
3525+ {
3526+ if (!spin_trylock (ext4_group_lock_ptr (sb , group )))
3527+ return false;
3528+ /*
3529+ * We're able to grab the lock right away, so drop the lock
3530+ * contention counter.
3531+ */
3532+ atomic_add_unless (& EXT4_SB (sb )-> s_lock_busy , -1 , 0 );
3533+ return true;
3534+ }
3535+
35443536static inline void ext4_lock_group (struct super_block * sb , ext4_group_t group )
35453537{
3546- spinlock_t * lock = ext4_group_lock_ptr (sb , group );
3547- if (spin_trylock (lock ))
3548- /*
3549- * We're able to grab the lock right away, so drop the
3550- * lock contention counter.
3551- */
3552- atomic_add_unless (& EXT4_SB (sb )-> s_lock_busy , -1 , 0 );
3553- else {
3538+ if (!ext4_try_lock_group (sb , group )) {
35543539 /*
35553540 * The lock is busy, so bump the contention counter,
35563541 * and then wait on the spin lock.
35573542 */
35583543 atomic_add_unless (& EXT4_SB (sb )-> s_lock_busy , 1 ,
35593544 EXT4_MAX_CONTENTION );
3560- spin_lock (lock );
3545+ spin_lock (ext4_group_lock_ptr ( sb , group ) );
35613546 }
35623547}
35633548
@@ -3612,6 +3597,7 @@ extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin);
36123597extern int ext4_get_max_inline_size (struct inode * inode );
36133598extern int ext4_find_inline_data_nolock (struct inode * inode );
36143599extern int ext4_destroy_inline_data (handle_t * handle , struct inode * inode );
3600+ extern void ext4_update_final_de (void * de_buf , int old_size , int new_size );
36153601
36163602int ext4_readpage_inline (struct inode * inode , struct folio * folio );
36173603extern int ext4_try_to_write_inline_data (struct address_space * mapping ,
@@ -3671,10 +3657,10 @@ static inline int ext4_has_inline_data(struct inode *inode)
36713657extern const struct inode_operations ext4_dir_inode_operations ;
36723658extern const struct inode_operations ext4_special_inode_operations ;
36733659extern struct dentry * ext4_get_parent (struct dentry * child );
3674- extern struct ext4_dir_entry_2 * ext4_init_dot_dotdot ( struct inode * inode ,
3675- struct ext4_dir_entry_2 * de ,
3676- int blocksize , int csum_size ,
3677- unsigned int parent_ino , int dotdot_real_len );
3660+ extern int ext4_init_dirblock ( handle_t * handle , struct inode * inode ,
3661+ struct buffer_head * dir_block ,
3662+ unsigned int parent_ino , void * inline_buf ,
3663+ int inline_size );
36783664extern void ext4_initialize_dirent_tail (struct buffer_head * bh ,
36793665 unsigned int blocksize );
36803666extern int ext4_handle_dirty_dirblock (handle_t * handle , struct inode * inode ,
0 commit comments