Re: [RFC PATCH] ext4: remove code that does not perform much optimization in find_group_orlov
From: Andreas Dilger
Date: Mon Jan 27 2020 - 16:44:29 EST
On Jan 27, 2020, at 3:13 AM, Liu Song <fishland@xxxxxxxxxx> wrote:
>
> From: Liu Song <liu.song11@xxxxxxxxxx>
>
> Even if "best_ndir" has already taken the final value, it still
> needs to traverse all the block groups. It is better to simplify
> the code and increase readability.
>
> Signed-off-by: Liu Song <liu.song11@xxxxxxxxxx>
> ---
> fs/ext4/ialloc.c | 15 +++------------
> 1 file changed, 3 insertions(+), 12 deletions(-)
>
> @@ -447,17 +447,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
> int best_ndir = inodes_per_group;
> int ret = -1;
>
> - if (qstr) {
> - hinfo.hash_version = DX_HASH_HALF_MD4;
> - hinfo.seed = sbi->s_hash_seed;
> - ext4fs_dirhash(parent, qstr->name, qstr->len, &hinfo);
> - grp = hinfo.hash;
> - } else
> - grp = prandom_u32();
> - parent_group = (unsigned)grp % ngroups;
> for (i = 0; i < ngroups; i++) {
> - g = (parent_group + i) % ngroups;
> - get_orlov_stats(sb, g, flex_size, &stats);
> + get_orlov_stats(sb, i, flex_size, &stats);
It isn't clear to me that this is an improvement? This means that *all*
new group allocations will start searching at group = 0, which will
increase contention on the early block groups. With the current code,
the starting block group is distributed across the filesystem, as it
is possible that there are multiple groups that have the same score.
We might consider to improve the group selection for non-rotational storage,
since we don't care as much about groups on the inner vs. outer tracks.
Cheers, Andreas
Attachment:
signature.asc
Description: Message signed with OpenPGP