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=1795046282; b=V8OPe9ZgdaMfY+zzZhs45vWo0kwlzA4iAMerC26cClaDYjUYAU3162jTRJQA5smW/DGi /6xcrgjQAH5kDgP8yW/93ozAev6Wm9emxUp5l5PR6/AbcDKclrLXPrQTjh8zDA3gpDdfm I8H3yqZmiLP2OrcpvJYDsbK3GI+aJ8BnCfz5KI2yHZ53jzhGtQhGd+h2gUlAG6eg9yVSH 1GH2kWXn5rW8IXoxhRh7VSMOSGV+2h/s5CIV5n7TZmQHQpYb+VPFhq+e1MeT9WPClMQ2v LQgZ3sBu8R9D8Qd7OvCZzp5hKr3yAod1kE3F7Qn672LrFlN4OHGt7nbO0UdinyXte9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795046282; 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=iupYC9IBM+fCLMrfxW9GH5caZq7zCwFnRj7OqUZjs0o=; b=YpqVEluCOv5Rllnlxo/gYVIvTPod3ExGuFtlF/uhqSS5pBiRxG3Y8K8d2Icmdi02RjCD K4jl+Yw3TRDsWoHhoEC4WDqg3Bd1S1XzbU18XSluRFDlCWxesEgFqrozxADXtsV3jxFmx B20hlzNOKbTv9Px+KbgWJ6W7Xf5yce8q2gouL9QOX1JYfXtWb023b/wTgNEmN0oTt2N8P ox+ib48TLnaYGg1Y4x6EJnzL8nE9l6gcMBKT6KnaBNxdmvcBYklL4SXJ2jpI4RsKzGMsE oeHvsI89dK0Qw8vo89Lt18E9Yo2rKZissw2Y/0xbJugHpfUKv5iZlhhRo+OWeY8CszA== 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=nStCw5wr; 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 44463606A31C; Wed, 18 Nov 2026 23:58:01 +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=nStCw5wr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4063F1F000C4; Wed, 18 Nov 2026 23:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795046281; bh=iupYC9IBM+fCLMrfxW9GH5caZq7zCwFnRj7OqUZjs0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nStCw5wrCDS1fl3ZPEdV0R8UyryAigmkSeKCwKFyGISJBVdlSPHFWjwWYFL4CeB0S k+9AHpmKmmj07Hoj2ObwQ4mRoq9YcTu34cfDSFpprf1BGLlYexOIQq0UgkPzDhGT7e Y4DguQfwauww0LEopN+IPk1uAqtwh17slLW8OcSI= 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.1 1225/2857] mm/shmem: stop retrying folios that cannot be split Date: Wed, 18 Nov 2026 15:37:39 +0100 Message-ID: <20261118150245.674781322@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@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.1-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 cfc573e04327c..c7939dde94f2d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1050,6 +1050,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)); } } index = folio->index + folio_nr_pages(folio) - 1; -- 2.53.0