Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2706047pxv; Sun, 11 Jul 2021 23:18:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2b5MvZqLUytDFx/bo+rulZZT9eqthZ93JubaLsN8fqnjIpX7jr8d8gN5U/Q7mZK53tfwV X-Received: by 2002:a05:6638:328e:: with SMTP id f14mr12474987jav.41.1626070737885; Sun, 11 Jul 2021 23:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626070737; cv=none; d=google.com; s=arc-20160816; b=hcOqqkDJ0r1b6MnXMglJUVVI3GBnuPzBf6Vc/9vwyv8k/HyQLN+RLC9FyJOEU6lU/o AB6FlrowaGoUv5Fv8TIMghbAcfbZsdDpNuxgiijj152g4TqOw540aSHxtoq5BBF7Y17+ fR+BNaP0KNjI0jOX5stu01pAbns9xugT8+MNvDxcxXoJ+lz7Rwq8OrxPzVXEjyA5YCAH 6GKPw0rsEc/pqQtB7EG0SuIM9jufxki43boqglJ9qK/PQLNjtR9EjeG2ZUsIfUNl8ofM RkkEgDCW90jGyRipL4mc/NVasg5WutP3WSCkbW90W7CuV3/vCpaFcrdLqsRFQ5B68XFp 1QIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wz+8y0+Rky8faa/UiXSjGAZAA1AccXe9PQo0b2hP+Uw=; b=nnWu3WYDly9B/EIbzGcRPA+55Iy3D0WIf+vRt9FT9AHkkof8I7561kzgeI+ORGB9ta 75ES/L/K8pKyZj+aMnQWvQLCAujy/mWWN0h45gxfPF6nDv0vjZEXzRILpU7tCZqJ37zl 7Iu8zWflmfS4dDUwyricXzuJQ0G53OmOIFrw7rAne952J58DW0nNoUsdRuu1DjUy9Ok/ jnRxusGhrk4Qwc907jkI+yy3UROUWjDB+AwcWOb23O1SvIUyTMG9UdWAdEKD67KS8oHA fZ+b/miz/OKRHWASDZ6nj4NM0j7B1B2NJ+ewIPXzH1AveycUf8uUsxe1aDqec+83iabz ZZcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0PuVq2vk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si15744732ioj.45.2021.07.11.23.18.46; Sun, 11 Jul 2021 23:18:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0PuVq2vk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234092AbhGLGUl (ORCPT + 99 others); Mon, 12 Jul 2021 02:20:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:39102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbhGLGT7 (ORCPT ); Mon, 12 Jul 2021 02:19:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A353610CD; Mon, 12 Jul 2021 06:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070632; bh=IY2rngyphraxDeqp9Jdnyl3vQlKE/WaO6UG0Ub0Hu1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0PuVq2vkDCXuxMsx2PG1R/Blz586Xp1JdmbpNjIFbCGsNPlS4IsIQTBeLPH7kDgQx YuJbhE75PQUqnHdVqxdvV4Ru7SZj1TsoCvopeQYgjxcgWygoTjymVjlaus3tF+Y9nP ky1DvOEapqP6zjUN1i5PqVjj8fGc/u3VSEKNd9DA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Pan Dong , Theodore Tso Subject: [PATCH 5.4 030/348] ext4: fix avefreec in find_group_orlov Date: Mon, 12 Jul 2021 08:06:54 +0200 Message-Id: <20210712060704.803628990@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pan Dong commit c89849cc0259f3d33624cc3bd127685c3c0fa25d upstream. The avefreec should be average free clusters instead of average free blocks, otherwize Orlov's allocator will not work properly when bigalloc enabled. Cc: stable@kernel.org Signed-off-by: Pan Dong Link: https://lore.kernel.org/r/20210525073656.31594-1-pandong.peter@bytedance.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/ialloc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -394,7 +394,7 @@ static void get_orlov_stats(struct super * * We always try to spread first-level directories. * - * If there are blockgroups with both free inodes and free blocks counts + * If there are blockgroups with both free inodes and free clusters counts * not worse than average we return one with smallest directory count. * Otherwise we simply return a random group. * @@ -403,7 +403,7 @@ static void get_orlov_stats(struct super * It's OK to put directory into a group unless * it has too many directories already (max_dirs) or * it has too few free inodes left (min_inodes) or - * it has too few free blocks left (min_blocks) or + * it has too few free clusters left (min_clusters) or * Parent's group is preferred, if it doesn't satisfy these * conditions we search cyclically through the rest. If none * of the groups look good we just look for a group with more @@ -419,7 +419,7 @@ static int find_group_orlov(struct super ext4_group_t real_ngroups = ext4_get_groups_count(sb); int inodes_per_group = EXT4_INODES_PER_GROUP(sb); unsigned int freei, avefreei, grp_free; - ext4_fsblk_t freeb, avefreec; + ext4_fsblk_t freec, avefreec; unsigned int ndirs; int max_dirs, min_inodes; ext4_grpblk_t min_clusters; @@ -438,9 +438,8 @@ static int find_group_orlov(struct super freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter); avefreei = freei / ngroups; - freeb = EXT4_C2B(sbi, - percpu_counter_read_positive(&sbi->s_freeclusters_counter)); - avefreec = freeb; + freec = percpu_counter_read_positive(&sbi->s_freeclusters_counter); + avefreec = freec; do_div(avefreec, ngroups); ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);