Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2862564pxv; Mon, 12 Jul 2021 03:52:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRXqi4ZwleerdM8aMJLlS+a2eZR2gVT7aSt4nbWZ981AxXHH4YPN4/4LRKau5e4VyvB/1H X-Received: by 2002:a92:509:: with SMTP id q9mr1716533ile.239.1626087137929; Mon, 12 Jul 2021 03:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626087137; cv=none; d=google.com; s=arc-20160816; b=dzsP+HhwwtkCZxN84+HUacUBE4gwIIVjK88nZgzlrEIKLjXUsm1agymz/dikj5PwS2 zyVwWCfgNdyEpbfMBxMCcYnsoXc1HgfLQ7c+eO2uBoaqDsY9M/jjiaVft3bp70yu2iLG vIRdsAGUCCWW37NBippRJCeyHkCsh8s+mj+4AMPZ87GldMEbrgzlJOwdkQUFFLiYNq89 bch48J1bhBia/qCsDl+jMYINdAwsp9Ev1Dt1dRDIihFeDoNkEFtyMj5uEP0j3Jzxvyfy uB807Lv2cEihNtOqD0j7BvWmE1WJyFeTeyqDzotiByZ3ES2RMjuD8AraEKz+hYGcd7Pi ZVyQ== 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=dmrciHSvyufS6WX6HinpkI+fxAtmSZQO2HK20DGnJhHBoQjQEPg3Qoqf/3Ar0UTaUI QAIarJGL+rIXkrTFpahEa0P5OsGGCLZ0p3e3WsK44RDcH1f1pPRXDi/7owIAZs8YnwLT U0FTn6zyqI8TcwMBYwkFfYws2R6VLBYa8XmYMvbqi5XRPUFLSHrWGJcN6Bqy1TqW3rS4 bwm1Ml0XoeoyM2nqBs0XGPuFUAwp1vPJvN5xAGvqF+dYA81ak8CP0WtWHVAbnpPSi7Bz 5qeJxPpgjtfAnYJbQv4Mn9yfPEG6r4DoXXFivPWG+mHSu2XBPoG0UXo5g5f0NQ7xo/US XkMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tAirRTjR; 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 a4si17408731ild.162.2021.07.12.03.52.05; Mon, 12 Jul 2021 03:52:17 -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=tAirRTjR; 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 S1356598AbhGLIQg (ORCPT + 99 others); Mon, 12 Jul 2021 04:16:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:51916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239360AbhGLHcQ (ORCPT ); Mon, 12 Jul 2021 03:32:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8213860BD3; Mon, 12 Jul 2021 07:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074966; bh=+sZEZrHmHmdqH8UCcxerHUyNuFkWGKJIk6DG+Yq6UfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tAirRTjRDnx6u8p9Qfl+TUfr4txWKmKW4yBcYN5l2ABSLKDoQHz9uwMIxmyJRPf7s jrDDw96HfXNrfdFrpgLumAtKrex5XC1e/MVSZdeBWvNesfocd+C7stymb38EB+WvFu 0UpTXSnOh3dL+m0BHBgBJBqirAkv8fz54ibjeFn8= 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.13 058/800] ext4: fix avefreec in find_group_orlov Date: Mon, 12 Jul 2021 08:01:21 +0200 Message-Id: <20210712060921.540927707@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060912.995381202@linuxfoundation.org> References: <20210712060912.995381202@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);