Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3761108pxv; Mon, 19 Jul 2021 08:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Es7lrBE3mAZxSIMyuI2qI0iMHTa87wQ5zBea8DfzJody7m9r+hnTYrcVDjxyBjS2KwHr X-Received: by 2002:a05:6e02:78c:: with SMTP id q12mr18162917ils.243.1626707365469; Mon, 19 Jul 2021 08:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707365; cv=none; d=google.com; s=arc-20160816; b=KCcLEE20i1VHX997DOgqcuXahBaFYYfMlMzLp+kOWQK8xhsUg/BfBG8ewMypIXHVT+ Pg5jzcbUi/fpGlC5ldahb5eDfACF3vC4oGEYooB7vp0yPDKMYsRi+jn2XX3e1lqUrp3w lmxpj/ieOMdW4rmdaGDw8xV4gJ47tP1urwFHnfT+VtkBP6ULcYqEK1hKYiYb3H3kJwtf Y/fIs73SwZBflNmVGlBzXY0oPzJ5rBAXSqrKOWge7hudJB6oVuShaaosESAdSotdDoKX YwKwOoVPurskh+RYQnx/kFrC9Q2LF+lgF7/pPrNDOR+5CHqly4+rPHyX43IriEzQz+dG A1Zw== 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=phYZb9mKbcCoNZ3lUgDsPIuxapGeyKaP2HiY7kd1mvM=; b=ibgY2aFTWuy/wHw20QXHfJkKzqqoTs95n8mS/Dzq3DDTi4H8uO5Mu9xSff41UtDsRU p0ilfDF6C+WYNZ9Y7LgCvzCNcYAnKHJaBMGDHSa+03pDz2nerPH1VVHyalbQRqMpya+t wsLnA/FaFtrYumc4t4o7jRcBTdl3/tns5I6eQqlmXROXVLQFvHkW4/ODVDbx+xVu2Ah9 BCNNhwlnig4PfLEM5dX/BW5yooU2+xTBi2qUpEwZCcC5YSger3Sao7qKyi81fyNdnbGO X6PoOaEZvd9PQTm3V+/ta1ai84TjkIzwbF60lQwG66FJzvMgLa7VZYPbclEDYF+xUiD9 4wDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QX3uaSYb; 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 n24si18917626ioz.5.2021.07.19.08.09.13; Mon, 19 Jul 2021 08:09:25 -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=QX3uaSYb; 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 S242808AbhGSO0k (ORCPT + 99 others); Mon, 19 Jul 2021 10:26:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:37024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243871AbhGSOYd (ORCPT ); Mon, 19 Jul 2021 10:24:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C43B661287; Mon, 19 Jul 2021 15:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707058; bh=2cj57QhkvUfRxKbwrHmZUz2KpRz8mxUdCYhyEkAQwMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QX3uaSYboy4VwQ0Kv+Gc1PzMaPTKp60pK9IPL4gxSReoftX2IWeEEvrHdH2iyH89u WIuhOOINRBk+BIOYJ24CYUfdtTIKauM8g/gOEVg5mzGLkWDZX7tt3DEkuvp8dQl2Kw YaMAYRrD7Z/1JR3YVqx08ttjHSsyLBM+eX08gloI= 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 4.9 015/245] ext4: fix avefreec in find_group_orlov Date: Mon, 19 Jul 2021 16:49:17 +0200 Message-Id: <20210719144940.881726332@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 @@ -405,7 +405,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. * @@ -414,7 +414,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 @@ -430,7 +430,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; @@ -449,9 +449,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);