Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2832855pxv; Mon, 12 Jul 2021 03:04:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8F6h8He8Vs+nS8ak5q24XfthgzXOmVe3LxZZf7gikVMTRZ+hWcn84K0vwBQm8ImApbaUv X-Received: by 2002:a92:7a12:: with SMTP id v18mr10043525ilc.27.1626084265600; Mon, 12 Jul 2021 03:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084265; cv=none; d=google.com; s=arc-20160816; b=CxSYgQJMv7Na7SPRxmR2jLDbaVFCX+VeB3wYZKVecya+te9Aq8TDvMcV5QK5FBwDRy 64LDZYtCHBPsGsKdwwBL54t9N7xgpIZCRQPKB8nzJXLqXyHOfJ9/YsszhrPeWMWrhTKD ro2WLliugd5LXNzF9fMeYOp/soo4tYq9ojGEHt6lL3AH2wBwo7tp8b4AZMQPHj+gm2Mz l+lYwWKVQ822D6hVHRFSRi4I6lqCFGqTQs3HRXUA7rOHBYIh/5zhHf/ps8b1m8z47BLn dS0OD5PeqX6c+rYCR55jscwbQiUgi+3h647Vc+7bvlpely4TgJIkWyM2Da1jQCCSd57x 9ZBw== 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=ouR7rEQZWWGqoZBBfYxXXpICsZplOh6ZzY3ADNj8xK6d7GNuSIdbylfHv7ELmajV3a yomCDzlyUcc2Nifnt8UopWZqacoey57c7XKOkC+HmRXpsdFSh1P5tSk731CkeGFb3REC ZATVwINK2a3vnmDjqLKf67SRbcmFN53lCEf218bfLaUw7DoZ28IfSOvK3SQNPkvV+mpT qlz8CCGtNGORJwdLA6li+5pEaoJkN+b6lNXkslwQlX8Fc4hIhv7vV5Fq5rGDvd96/8Ho zcH0fm5rsz5A5yJLsNg+Xld4dHwxkR4/VEq3VMXzA+3gnRSvs3IHOgknGT+WmCiGCk9L AdJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nMmCedhM; 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 u12si17672578ilm.144.2021.07.12.03.04.13; Mon, 12 Jul 2021 03:04: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=nMmCedhM; 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 S1344480AbhGLHYa (ORCPT + 99 others); Mon, 12 Jul 2021 03:24:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239410AbhGLG5g (ORCPT ); Mon, 12 Jul 2021 02:57:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7FF66102A; Mon, 12 Jul 2021 06:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072888; bh=+sZEZrHmHmdqH8UCcxerHUyNuFkWGKJIk6DG+Yq6UfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nMmCedhM7WYO/8V4sw+WLtgd8lTIMImbR5dwXgTluCIb4vCjYwvyaJPxJbf52G3KM m4DZDGZjfbH4YkFk+SK3Xkw3qVZA98NGroovvpeyq7rBZUdmmHdQOdVyCxGBN0T+sI SO66uQCNPyBick9CSrjdXt9s2dYuQ0PUx9N58gK4= 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.12 055/700] ext4: fix avefreec in find_group_orlov Date: Mon, 12 Jul 2021 08:02:18 +0200 Message-Id: <20210712060932.481444040@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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);