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 F264B16132A; Sun, 1 Mar 2026 02:01:05 +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=1772330466; cv=none; b=XlDTSm37cZs4XxAPn08AX/j06jVIrkPMJ3JQeDRKgpPmdQOxrFxzDKNK7AaoJLi6f25mT0Cu28jkS5+SklH9j3uyG9a8+BCC3qY6qDMm57leKEkbL/nc0v1Ze2/8ocEK5ywMxdoEmTigk9ScD3143FjIoPe1EhPjhtlhQsyQ79c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772330466; c=relaxed/simple; bh=/65fSYzHl0ingl2Ap1KRq0o6NxKTjbEl3og3Y3XRFhw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TPV1XEJI5Eb2Pcb0dSmCOzuUMiPDrXcmKrEreK464HsuQfVi1KbR78Abt/8nVHJHy8c1KgIPu/5LY2CUPlxaL70Uk0B4FstPr7b5lzsdH4wryw3Dr9O+vDvy9BktiyhWB8o+jAawl4XI0bsbjCtKi1ztNQhGtJwtK91ooXtr1OM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gF5L4rFv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gF5L4rFv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 091CFC19421; Sun, 1 Mar 2026 02:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772330465; bh=/65fSYzHl0ingl2Ap1KRq0o6NxKTjbEl3og3Y3XRFhw=; h=From:To:Cc:Subject:Date:From; b=gF5L4rFvboZd5w7RJ94bfFk50U1AwEH+cY4JLnwXmvvCu9LyCfp/pwQLqcI6mRelf 9ukocyprWM9askyhKrK3oUjIqV6B3qs5IX7K2gQ54dwerycanQJtezp6zlp/tOAZTk M3mKPIIwhjIlv26SejNPPjuCFq7UtfIlpFE1nlY4Sg4cMyLu4i81LK6ok/knQsZFzL 0J8l62ASa8wwtLRg6qtgy6Zp5pnp9xANBG6ACm1sDjGGKxHa17GN5XMiovE8onrdkP sdBjwJmlrvSjQ++QcPyDjUSKOEGBG808uAX915+95dD9ZusRBNG4uZDUbew4OMKP1e ewG420LqPPfSg== From: Sasha Levin To: stable@vger.kernel.org, jack@suse.cz Cc: Baokun Li , Zhang Yi , Pedro Falcato , stable@kernel.org, Theodore Ts'o , linux-ext4@vger.kernel.org Subject: FAILED: Patch "ext4: always allocate blocks only from groups inode can use" failed to apply to 5.10-stable tree Date: Sat, 28 Feb 2026 21:01:03 -0500 Message-ID: <20260301020103.1728070-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Hint: ignore X-stable: review Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Thanks, Sasha ------------------ original commit in Linus's tree ------------------ >From 4865c768b563deff1b6a6384e74a62f143427b42 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 14 Jan 2026 19:28:18 +0100 Subject: [PATCH] ext4: always allocate blocks only from groups inode can use 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 --- fs/ext4/mballoc.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index dd29558ad753b..910b454b4a21e 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -892,6 +892,21 @@ mb_update_avg_fragment_size(struct super_block *sb, struct ext4_group_info *grp) } } +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; +} + static int ext4_mb_scan_groups_xa_range(struct ext4_allocation_context *ac, struct xarray *xa, ext4_group_t start, ext4_group_t end) @@ -899,7 +914,7 @@ static int ext4_mb_scan_groups_xa_range(struct ext4_allocation_context *ac, struct super_block *sb = ac->ac_sb; struct ext4_sb_info *sbi = EXT4_SB(sb); enum criteria cr = ac->ac_criteria; - ext4_group_t ngroups = ext4_get_groups_count(sb); + ext4_group_t ngroups = ext4_get_allocation_groups_count(ac); unsigned long group = start; struct ext4_group_info *grp; @@ -951,7 +966,7 @@ static int ext4_mb_scan_groups_p2_aligned(struct ext4_allocation_context *ac, ext4_group_t start, end; start = group; - end = ext4_get_groups_count(ac->ac_sb); + end = ext4_get_allocation_groups_count(ac); wrap_around: for (i = ac->ac_2order; i < MB_NUM_ORDERS(ac->ac_sb); i++) { ret = ext4_mb_scan_groups_largest_free_order_range(ac, i, @@ -1001,7 +1016,7 @@ static int ext4_mb_scan_groups_goal_fast(struct ext4_allocation_context *ac, ext4_group_t start, end; start = group; - end = ext4_get_groups_count(ac->ac_sb); + end = ext4_get_allocation_groups_count(ac); wrap_around: i = mb_avg_fragment_size_order(ac->ac_sb, ac->ac_g_ex.fe_len); for (; i < MB_NUM_ORDERS(ac->ac_sb); i++) { @@ -1083,7 +1098,7 @@ static int ext4_mb_scan_groups_best_avail(struct ext4_allocation_context *ac, min_order = fls(ac->ac_o_ex.fe_len); start = group; - end = ext4_get_groups_count(ac->ac_sb); + end = ext4_get_allocation_groups_count(ac); wrap_around: for (i = order; i >= min_order; i--) { int frag_order; @@ -1182,11 +1197,7 @@ static int ext4_mb_scan_groups(struct ext4_allocation_context *ac) int ret = 0; ext4_group_t start; struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); - 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 = sbi->s_blockfile_groups; + ext4_group_t ngroups = ext4_get_allocation_groups_count(ac); /* searching for the right group start from the goal value specified */ start = ac->ac_g_ex.fe_group; -- 2.51.0