[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230227120127.ki3ydzdbi25d5wmp@quack3>
Date: Mon, 27 Feb 2023 13:01:27 +0100
From: Jan Kara <jack@...e.cz>
To: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Cc: linux-ext4@...r.kernel.org, Theodore Ts'o <tytso@....edu>,
Ritesh Harjani <riteshh@...ux.ibm.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Jan Kara <jack@...e.cz>, rookxu <brookxu.cn@...il.com>
Subject: Re: [PATCH v4 6/9] ext4: Fix best extent lstart adjustment logic in
ext4_mb_new_inode_pa()
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@li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com
>
> Signed-off-by: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Looks good to me. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
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@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists