From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0A88926F46F; Thu, 2 Jul 2026 16:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011077; cv=none; b=Ev1vDYrbgcsd9vTFGGzbn1RuPmDu5vgW54zXXGNOCVxh1umklgx4ljvmhxG46+7ou0dvyUe580MdRsxfkoAPhq3bnL8HXPQ9qStPoP1xCjN8CTM5H4cavRSJdRNqIbkG5n2terButtPZFjWUsdoQY7O02F9IKrbtP37SBfMeIKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011077; c=relaxed/simple; bh=HdhbYby+KIT2Tju2Oy26LwHRiIGN8sa9isy8X2w9UOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oXsDrApUw1oJqdCdlli42pv1eZlNK1Th/ZXYjuVVUw8bN8fspe9xKlFZeU0I1ijqk6hBlfJM676AOU6T6VPpsoYg5UMGchqe3QTXsY+yjOz8a1XHIMxc12vMmHj7BJsQHvqjAYgimR6al8yyX92j8fEGg2Vj0CvGC5rNX4REJRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ToUCDmfz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ToUCDmfz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 706921F00A3A; Thu, 2 Jul 2026 16:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783011075; bh=L5FeyoKA6CXlp82pNnwaDFpkZgOLcxgruTTSgyP7AQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ToUCDmfzGkwiQnD+0OK0t2pIGgWiDVS95UwtVrnf6HZQ/YwgO6LnDbp4av2NTsW4j PATh70UaB11vP5ztf0Iaai7nK7QKt5voksEPJTFRuB6CvYGoSPB5NfPXh2s08IOR3j jptsdjnVxN20K+j5ghFDADBewVU2GLedTngad53s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chao Yu , Yongpeng Yang , Jaegeuk Kim Subject: [PATCH 6.6 140/175] f2fs: fix incorrect FI_NO_EXTENT handling in __destroy_extent_node() Date: Thu, 2 Jul 2026 18:20:41 +0200 Message-ID: <20260702155118.756316471@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155115.766838875@linuxfoundation.org> References: <20260702155115.766838875@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yongpeng Yang commit 1f70ddb28a3c71df124da5fa4040c808116d6bb9 upstream. When __destroy_extent_node() sets the inode flag FI_NO_EXTENT, it does not reset the length of the largest extent to 0 and update the inode folio. Since modifications to the extent tree are disallowed afterward, the cached largest extent may become stale. This can trigger the following error in xfstests generic/388: F2FS-fs (dm-0): sanity_check_extent_cache: inode (ino=1761) extent info [220057, 57, 6] is incorrect, run fsck to fix In the f2fs_drop_inode path, __destroy_extent_node() does not need to guarantee that et->node_cnt is 0, because concurrency with writeback is expected in this path, and writeback may update the extent cache. This patch reverts commit ed78aeebef05 ("f2fs: fix node_cnt race between extent node destroy and writeback"), and remove the unnecessary zero check of et->node_cnt. Fixes: ed78aeebef05 ("f2fs: fix node_cnt race between extent node destroy and writeback") Cc: stable@vger.kernel.org Reported-by: Chao Yu Suggested-by: Chao Yu Signed-off-by: Yongpeng Yang Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/extent_cache.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -87,10 +87,9 @@ static bool __may_extent_tree(struct ino if (!__init_may_extent_tree(inode, type)) return false; - if (is_inode_flag_set(inode, FI_NO_EXTENT)) - return false; - if (type == EX_READ) { + if (is_inode_flag_set(inode, FI_NO_EXTENT)) + return false; if (is_inode_flag_set(inode, FI_COMPRESSED_FILE) && !f2fs_sb_has_readonly(F2FS_I_SB(inode))) return false; @@ -603,14 +602,10 @@ static unsigned int __destroy_extent_nod while (atomic_read(&et->node_cnt)) { write_lock(&et->lock); - if (!is_inode_flag_set(inode, FI_NO_EXTENT)) - set_inode_flag(inode, FI_NO_EXTENT); node_cnt += __free_extent_tree(sbi, et, nr_shrink); write_unlock(&et->lock); } - f2fs_bug_on(sbi, atomic_read(&et->node_cnt)); - return node_cnt; } @@ -640,12 +635,12 @@ static void __update_extent_tree_range(s write_lock(&et->lock); - if (is_inode_flag_set(inode, FI_NO_EXTENT)) { - write_unlock(&et->lock); - return; - } - if (type == EX_READ) { + if (is_inode_flag_set(inode, FI_NO_EXTENT)) { + write_unlock(&et->lock); + return; + } + prev = et->largest; dei.len = 0;