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 A963C2D7DEF; Tue, 31 Mar 2026 17:07:49 +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=1774976869; cv=none; b=ZnBZCVq3Kf/I9zEtsrY3bVcP8q+RLPbLhlnn5vDohZDk1CxsRhNd3mYL6QQiqjFSzU6Hv+BPIqXdjRFUJYu3lvPZ4YcQYiq45mSRMbHmDQ8fs2OnkxyXdP+39J9c/XkLVIWgawa04nN7zkwUs76iem41+tyRC46DkqO/pJ954Ew= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976869; c=relaxed/simple; bh=5DSTJTihjZNS7Nesqpuqicpmhz/V9EyWQRGqvZhE92E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nEWXIWKsU7017yR9kfRbJK2XNe4qJZXXnmOFfFM1I8kVIr7xe+c/y1tMuCiGh8pGHspJ6IfiQxMssDQSug6cQcPSECiMoC6lsX9vtIEp7nfA3m2Yzz5SHPu/RYn9fuee0QDqAPuNrbULcMdsCnyju8k4AAr7WljCgoacVNWwWsI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tI1ahDct; 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="tI1ahDct" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40022C19423; Tue, 31 Mar 2026 17:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774976869; bh=5DSTJTihjZNS7Nesqpuqicpmhz/V9EyWQRGqvZhE92E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tI1ahDct+s1dLvz45HEpvK0UU0S6uCQu+zFQ8jgSUeBfLmoGOEML3de0he/8ieDja fP1YLR0SchKf0dZZMZ1nqohDdSUpXKoRistyHWczOhnyTVSYrz4cju0P3ErvXcl41u Wf97ViMV4Tho2i+2YMySNmxyVPQahAN178Cz/xdM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Zhang Yi , Theodore Tso , stable@kernel.org Subject: [PATCH 6.18 259/309] ext4: make recently_deleted() properly work with lazy itable initialization Date: Tue, 31 Mar 2026 18:22:42 +0200 Message-ID: <20260331161803.102951915@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161753.468533260@linuxfoundation.org> References: <20260331161753.468533260@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit bd060afa7cc3e0ad30afa9ecc544a78638498555 upstream. recently_deleted() checks whether inode has been used in the near past. However this can give false positive result when inode table is not initialized yet and we are in fact comparing to random garbage (or stale itable block of a filesystem before mkfs). Ultimately this results in uninitialized inodes being skipped during inode allocation and possibly they are never initialized and thus e2fsck complains. Verify if the inode has been initialized before checking for dtime. Signed-off-by: Jan Kara Reviewed-by: Zhang Yi Link: https://patch.msgid.link/20260216164848.3074-3-jack@suse.cz Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/ialloc.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -686,6 +686,12 @@ static int recently_deleted(struct super if (unlikely(!gdp)) return 0; + /* Inode was never used in this filesystem? */ + if (ext4_has_group_desc_csum(sb) && + (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) || + ino >= EXT4_INODES_PER_GROUP(sb) - ext4_itable_unused_count(sb, gdp))) + return 0; + bh = sb_find_get_block(sb, ext4_inode_table(sb, gdp) + (ino / inodes_per_block)); if (!bh || !buffer_uptodate(bh))