From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 333BC284881; Mon, 23 Mar 2026 16:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774282872; cv=none; b=jSm1em9KkSREFl7/7bNIH2tpn9StFrFUwDCZS3qUZiysF58SSRwUBMPlTbA5qkOzpUOe3vcNBhec6plLLpUKCQUkZubgCfN6hkBUdTjfaOX+yVbZGHe3lAdmRho44LH8/vxTQgZa2V2U9bSkCyYQLLNN5kygHo0xMRKRtjRLUlU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774282872; c=relaxed/simple; bh=vt0A5XXcITZJvYKEUl2sMY4D5KtCQ9qvabWGBtdclds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uk9Glt6GfAdZwe8gzfy9vUO+6bfznb8qSI57326rdZZ5/50kUUbIyON4WsfH0VvcSxdkPAVUpCAFSYRF4MWx0n1zkxYqApn2CmN7FvpMMJD7OEp7eK4FBbP9z0Nt00Kprk5+H6zJoVk4jawlbTpa1kJN00sr7v0iAQPcL2UfZsc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=T0jhOOWR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="T0jhOOWR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B86C3C4CEF7; Mon, 23 Mar 2026 16:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774282872; bh=vt0A5XXcITZJvYKEUl2sMY4D5KtCQ9qvabWGBtdclds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0jhOOWRtoxLZXyxr2sztzMa5HjVwGffkra/quNQNteC07kUC9W8YiiAxV9wRrI2g txDTvu3bGaKwEHZe8OB5dY0fCuzKBb2W97ddOEVoeW/KHIfMlQraLCe5OyBvi/KzzS 59X9om+VOAJ7kM5puRSeCreTgMs2C1AeT6lF5Ov4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Baokun Li , Zhang Yi , Jan Kara , Pedro Falcato , stable@kernel.org, Theodore Tso , Sasha Levin Subject: [PATCH 6.1 316/481] ext4: always allocate blocks only from groups inode can use Date: Mon, 23 Mar 2026 14:44:58 +0100 Message-ID: <20260323134532.802853873@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134525.256603107@linuxfoundation.org> References: <20260323134525.256603107@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ Upstream commit 4865c768b563deff1b6a6384e74a62f143427b42 ] For filesystems with more than 2^32 blocks inodes using indirect block based format cannot use blocks beyond the 32-bit limit. ext4_mb_scan_groups_linear() takes care to not select these unsupported groups for such inodes however other functions selecting groups for allocation don't. So far this is harmless because the other selection functions are used only with mb_optimize_scan and this is currently disabled for inodes with indirect blocks however in the following patch we want to enable mb_optimize_scan regardless of inode format. Reviewed-by: Baokun Li Reviewed-by: Zhang Yi Signed-off-by: Jan Kara Acked-by: Pedro Falcato Cc: stable@kernel.org Link: https://patch.msgid.link/20260114182836.14120-3-jack@suse.cz Signed-off-by: Theodore Ts'o [ Drop a few hunks not needed in older trees ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -871,6 +871,21 @@ mb_update_avg_fragment_size(struct super } } +static ext4_group_t ext4_get_allocation_groups_count( + struct ext4_allocation_context *ac) +{ + ext4_group_t ngroups = ext4_get_groups_count(ac->ac_sb); + + /* non-extent files are limited to low blocks/groups */ + if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))) + ngroups = EXT4_SB(ac->ac_sb)->s_blockfile_groups; + + /* Pairs with smp_wmb() in ext4_update_super() */ + smp_rmb(); + + return ngroups; +} + /* * Choose next group by traversing largest_free_order lists. Updates *new_cr if * cr level needs an update. @@ -2672,10 +2687,7 @@ ext4_mb_regular_allocator(struct ext4_al sb = ac->ac_sb; sbi = EXT4_SB(sb); - ngroups = ext4_get_groups_count(sb); - /* non-extent files are limited to low blocks/groups */ - if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))) - ngroups = sbi->s_blockfile_groups; + ngroups = ext4_get_allocation_groups_count(ac); BUG_ON(ac->ac_status == AC_STATUS_FOUND);