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=1796387922; b=2QOpk3ri8EJWeMZChP2I6eflzFgFkQjMJvykgflD4Mn4UG/3D/laZqYUYv/4dm2Pdyf1 NOg7a61cZIVL1zsfoBo3ZodrlL4eVrW78NitFNf0VypSBiyBLUDCIil8rqd6FOFc4Zk+O UcwlymMShfksqi6eqeV1MROLQJEHpfOFqIeQOZFGvhAVHPcIwQ04+AdXz93pK4fqyPh6z ea85FJfXJd+pa8El8SrWWCIEmrj3EP90mqIsdwwCE6C3oMKxw/pU2kgDrd6iVVMq8xT2a 72vESwdaznGeEirXvFtrU8e0lLSGEmhKtYjJ6qiG7jE0jYwWUJq/q/CL+qZNM/pnedQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387922; 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=dSQBJ950mGHfApjvzbL4NrHDUbtnxoGOvse0gh8wkpI=; b=Sh0DN2N4P3kYup3/DTFwr4xNGPbl0gW1fNOdxwL6Lz20QL0Sod6plR2EO4ginKJKPouQ mqmAU5SbTt7dVyNH4ImCiQrZltzgrEsKP986wIeMb5vpVetDNOKP1MW9hyJEeTsbwc9wG rmObkiP46OJkpjkI4cDcg8qnKfkM/y+ehQQy8/SY7obgNxN1zpnnLnVAaidbbwvdN0feG FcwxAtltNDI2R9MZgWJb9KPpkL1kqDfAbxefda30O1mOcrMacsRiq1Eoov4QZjYoOs09S xvWUpuUdd/5QggLNdcu8WvsmNxdgJiPBuwQXjOMVnEISqQxDqqgKhJoM9x0m1M3graA== 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=zKoa2w0M; 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 13BC2606A322; Fri, 4 Dec 2026 12:38:42 +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=zKoa2w0M Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A031F000C2; Fri, 4 Dec 2026 12:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387921; bh=dSQBJ950mGHfApjvzbL4NrHDUbtnxoGOvse0gh8wkpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zKoa2w0MjSFa6w6V4TD5yjYWCmnnZ/YfziLEBVoa0pMN3uAWy49Qkzc9nWLSTikiY PpusZ/LYT/7qDnLjWFE0D7V/n5008Vh+GIXajORh3tLr7sSyDMSNseXAXVYpbeNnQB yJv4kKoR69eSoi8vm4RV0B2YUOYTiu5pxvZ2008U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tal Zussman , David Sterba , Sasha Levin Subject: [PATCH 6.1 0406/1059] btrfs: drop the extent maps of the written part of a failed ordered extent Date: Fri, 4 Dec 2026 18:58:57 +0900 Message-ID: <20261204100654.855344943@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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: Tal Zussman [ Upstream commit bca2cf55a7331e6b0ff95ad47fc2a7e8ecc7dc74 ] If a truncated ordered extent fails to complete, the extent maps for the part that was written are kept while the extent itself is freed below. A later read can follow them to blocks that have been reallocated. Drop the maps for the whole range on error. Fixes: 77cef2ec5484 ("Btrfs: allow partial ordered extent completion") Assisted-by: LLM Signed-off-by: Tal Zussman Signed-off-by: David Sterba [ sashal: Wrapped the btrfs_drop_extent_map_range() call in a local drop_start that resets to start when truncated and ret, since unwritten_start is shared with clear_extent_uptodate() in this tree. ] Signed-off-by: Sasha Levin --- fs/btrfs/inode.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index abc834c828519..1c0486591c44f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3434,6 +3434,8 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) /* * Drop extent maps for the part of the extent we didn't write. + * On error the written part is freed below as well, so drop + * its maps too. * * We have an exception here for the free_space_inode, this is * because when we do btrfs_get_extent() on the free space inode @@ -3446,9 +3448,15 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) * we don't mess with the extent map tree in the NOCOW case, but * for now simply skip this if we are the free space inode. */ - if (!btrfs_is_free_space_inode(inode)) - btrfs_drop_extent_map_range(inode, unwritten_start, + if (!btrfs_is_free_space_inode(inode)) { + u64 drop_start = unwritten_start; + + if (truncated && ret) + drop_start = start; + + btrfs_drop_extent_map_range(inode, drop_start, end, false); + } /* * If the ordered extent had an IOERR or something else went -- 2.53.0