From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794591067; b=5CUo40485xwzS6uhCPPScpwUoXGKWXOr0M2eV/A235Tljg12LkrL3c+RAAKBTlQ3qwIW A0yB+M59kxlEpuwJ5kFyhNBdYxI8mS5qxgb/KJH/k6cTUMipcv6qeMpTLiWTz1AQYMO+I ++D4CTvUqNDNr+lylOO7XXzWme5ejt8Y4PRQHYr5SN0onHSk498At5jk36EUXEA75/tsh 0olbiTCFKX+Ol0ATn73uX1giIgIOSbP932N7krGN8AcPm8MdguW44twC3j2SeoraCKsuM irVWfhx9k+KhqYisLViKj/faschfoWpzDR+DkOT8mvr/2VlZ5t7nfG434JY8EpPP2Hw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794591067; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=cg3GuiBLguMgHiHvTk5s02u4QtJ0L9BBUBSZ9MIlqfM=; b=QXTor6CnDHUq1dOzxaj47kK3mRl91lgbFQeHDDrIRXgu7yk4k5ZFGg1cYwVLGX04XnBh 1R8cYpWMHjjXmn+mTj/dhele9aFY11NqJFwzAHN4JA8mZCXfEeoyGKGhqrs7yiMuO+KL3 +kB+Z+IS13Zg2BHRRsC3JyglzNlH3OG5OGD2R6ypYUk48bL7erNtKko5Y1mP7qwj7QboQ qcTVNPRUZm8qobj/5SxEukxbGdJDKTwpMWuOfdD20OjzMW0ltkeARCt2EzlCiUyOBt27r vOVrBjNM7h3R0mCgQEE9INqJl/xmxNEm11IBLapfI9W8VXmgTPaORNDGcJDm5NlAz3Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b+hfSMOO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EECDB606B354; Fri, 13 Nov 2026 17:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b+hfSMOO Received: by smtp.kernel.org (Postfix) with ESMTPSA id A090A1F000C4; Fri, 13 Nov 2026 17:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794591066; bh=cg3GuiBLguMgHiHvTk5s02u4QtJ0L9BBUBSZ9MIlqfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b+hfSMOOIoISWzkrDtuiy8Ae3wjWe89frIIHETXCaWpSlTerJt61BlK6u1tD9zCJY +7lpUJPji5tvj/s7u3xnj7te7K3Re+ijZRdMvDcbgK5/smpGY/IJWD//3potqbN/PC InU3Irpt3nCaePV3K/Gq3/9FsK3dnJlqfRXgk9ck= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , "Gregory Price (Meta)" , Zi Yan , Balbir Singh , "David Hildenbrand (Arm)" , Sasha Levin Subject: [PATCH 6.12 225/670] mm/shmem: stop retrying folios that cannot be split Date: Fri, 13 Nov 2026 10:46:29 -0500 Message-ID: <20261113153819.501267436@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153811.177190860@linuxfoundation.org> References: <20261113153811.177190860@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit a842a1f947da8a7020e72f885ffbf2ce6a93685f ] A fault or collapse can insert a large folio crossing EOF after shmem_undo_range() has handled the boundary folios. If splitting that folio fails, truncate_inode_partial_folio() retains it when it is dirty. The final scan then repeatedly finds it because it restarts from an unchanged start. Truncation keeps the inode lock and ignores fatal signals while looping. A concurrent unlink() can then block other directory operations while holding the directory lock and waiting for the file's lock. Advance start past the retained folio, whose truncated part has already been zeroed. Do not move start backwards if the failed split has shrunk the folio. Fix generated by an LLM and sent by Chris Mason in private. Fixes: 55ac8bbe358b ("mm/shmem: fix race in shmem_undo_range w/THP") Cc: stable@vger.kernel.org Signed-off-by: Chris Mason Tested-by: Gregory Price (Meta) [ david: split fixes, simplify descriptions, adjust comments ] Reviewed-by: Zi Yan Reviewed-by: Balbir Singh Link: https://patch.msgid.link/20261029-fixes_shmem-v4-7-392fc715d8f6@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Sasha Levin --- mm/shmem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 4d01fc877e768..7061d2217306b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1171,6 +1171,15 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, index = start; break; } + } else if (folio->mapping) { + /* + * Splitting failed, but the part in the + * range is already zeroed. The folio + * was not dropped, so skip it when + * restarting the scan to avoid retrying + * it forever. + */ + start = max(start, folio_next_index(folio)); } } folio_unlock(folio); -- 2.53.0