Re: [PATCH v4 6/9] ext4: Fix best extent lstart adjustment logic in ext4_mb_new_inode_pa()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri 17-02-23 17:44:15, Ojaswin Mujoo wrote:
> When the length of best extent found is less than the length of goal extent
> we need to make sure that the best extent atleast covers the start of the
> original request. This is done by adjusting the ac_b_ex.fe_logical (logical
> start) of the extent.
> 
> While doing so, the current logic sometimes results in the best extent's logical
> range overflowing the goal extent. Since this best extent is later added to the
> inode preallocation list, we have a possibility of introducing overlapping
> preallocations. This is discussed in detail here [1].
> 
> To fix this, replace the existing logic with the below logic for adjusting best
> extent as it keeps fragmentation in check while ensuring logical range of best
> extent doesn't overflow out of goal extent:
> 
> 1. Check if best extent can be kept at end of goal range and still cover
>    original start.
> 2. Else, check if best extent can be kept at start of goal range and still cover
>    original start.
> 3. Else, keep the best extent at start of original request.
> 
> Also, add a few extra BUG_ONs that might help catch errors faster.
> 
> [1] https://lore.kernel.org/r/Y+OGkVvzPN0RMv0O@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 
> Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Just one style nit below.

> +		/*
> +		 * Use the below logic for adjusting best extent as it keeps
> +		 * fragmentation in check while ensuring logical range of best
> +		 * extent doesn't overflow out of goal extent:
> +		 *
> +		 * 1. Check if best ex can be kept at end of goal and still
> +		 *    cover original start
> +		 * 2. Else, check if best ex can be kept at start of goal and
> +		 *    still cover original start
> +		 * 3. Else, keep the best ex at start of original request.
> +		 */
> +		new_bex_end = ac->ac_g_ex.fe_logical +
> +			EXT4_C2B(sbi, ac->ac_g_ex.fe_len);
> +		new_bex_start = new_bex_end - EXT4_C2B(sbi, ac->ac_b_ex.fe_len);
> +		if (ac->ac_o_ex.fe_logical >= new_bex_start)
> +				goto adjust_bex;
		^^^ The indentation looks too big here

-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux