Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2717795pxv; Sun, 11 Jul 2021 23:41:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy0bY2pz3KhZaY6nPtRfeJixHbSm61ddwxLBVlxYJTfx507I0EIzIujFsOy/nfUohUU0Vf X-Received: by 2002:a17:907:97c5:: with SMTP id js5mr51068391ejc.321.1626072084818; Sun, 11 Jul 2021 23:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072084; cv=none; d=google.com; s=arc-20160816; b=xJk+q1LqPI1yGcw3BXAY1y8a2bcjd5i3L9RlxLJAtODSBSf/S9g4QxqQhRYghcZO6w f2eYg058ivde0/50dBaamcaUq6iT89ruQ7YKkNtCRK9dVUr4xmHhoAPpMhpPkqYVdBUD fnXfu64v+tu5mbvnLQYmCBWAF3yWaRtHBWyBPwewOBuj2GUOfNjOygtLFRlNWD2d/dqe 17uJfCpW5ig1sHBVZVihl97mAP05DSqk/JkxS58Pxt5elI/tvgFmMYD9M0vjy7592HF7 bPFyEKPq0E8XRCgYkMWkZHPTCAo/HOUwjQRUMxbp5PVuz9kpx5ZfxqylcXcw+uk3ZhL9 SlQw== 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=5o3vOyN0fs/UeR4O0EZ4uLHHWMXBm8l+QdMYeCTGiOM=; b=MGWd4m4OCI9dso42VvPOAYvZhUhry4ghZH65bn/MQzuLOp0frjJ79WCgG6OAuZzHof 0cmPbL0T0G595IC093zDha27jhbOd8HfulaPEfYliuBG1fTcfT3j6eKqWg8v/UGX9Ud6 rZXAlNvgjr7by810dz8L4HD69lV1m3zOcI28E6DxPG6/3hRDucXVDBsQU18NF6krIEdB Hmm4E1JKcFxdfBgXEHNoimyl/QI5+HXPkeJ98ULAnTXeJhrd2G9frHgBoXhb36rTpLsV 9IQKV+u0tsrV4LmYjfvV0h1nGsTwZRLZqAcLhvLqpxZ1xPX3VNXTQW9DrEIiaWP3vYTV CACQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LW4fw1dR; 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 hs13si18213309ejc.150.2021.07.11.23.41.01; Sun, 11 Jul 2021 23:41:24 -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=LW4fw1dR; 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 S238187AbhGLGmU (ORCPT + 99 others); Mon, 12 Jul 2021 02:42:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:53518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235749AbhGLGcq (ORCPT ); Mon, 12 Jul 2021 02:32:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E15B1610E6; Mon, 12 Jul 2021 06:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071387; bh=+sZEZrHmHmdqH8UCcxerHUyNuFkWGKJIk6DG+Yq6UfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LW4fw1dRJyAtmAvcT7HFCNbf9YsXSAww3N/sEA1tkQ7hI9wkv8khojkuXFJ3ADe0D zt7J9PzkVLJ9I4Dfotz463jawlEKc8wezn+QYhTl66vqtDKVElmWd5kMi9fZspodka h/pqeCMUhJY7VgfkO4fWWPPsfwuJNFhYCF0Az/NY= 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.10 048/593] ext4: fix avefreec in find_group_orlov Date: Mon, 12 Jul 2021 08:03:28 +0200 Message-Id: <20210712060848.419000877@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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 @@ -402,7 +402,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. * @@ -411,7 +411,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 @@ -427,7 +427,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; @@ -446,9 +446,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);