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=1796385113; b=YCqAX23po19Z7F4N1esJu2n4Vga2J/1ndbp8P3DzysXreBSqHOKK9bfmzwc/yR/LmiNk LhU9VuFVqJGtom6LTmIsr796Q5oN4PHzQ6KeNHRHIyIYKwrhkk4d4/l5KZjqjaBShV4oF tS0OknUSh58IYqvkO54wGqx9SSzplZE5X4dftlqnt+Jl3MQejqi9ZEUtu2CvOPOrosfLY qr5N4Eo1WMknFkFWl/z3Zt6yZfGhfDtSOBI4g5hqWUp6wvbL4N1EkZN22Kx4abVek2BUR W2vhIscznRzHMRI3HPZzR47V+qXHHGNE8pV63K70ya49vKd8YEzcoXK5Qc2pl4EAvSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385113; 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=LqWfXN9Hw1zyp1IB0HpsR+C7RXdjGHQiIGZRHQbGDzY=; b=XcXrPrcMK5aPw5StCK2mXpZxynM0pF25Q4HnHef2yQqbrOJPNVA6nv7P7dUILsjF7iKF EN0SvKR+OWcdKxXXu7193cbY8EBliLRK687FJpnHvMK2wxDXohwbqd0ZvKi4fyO/43A/S VZ0RjYwWlGl7UItOuryyqQP2T/WUASsJSW5gsSU/ryMUM6mXwH01jHaArLJeScaeu81Gz GQlLv6Qr6n685INc20WlYagUpCeWeGAuquDt9TqS9kWpFPHZqZ9JyUqg5jFOd873vyjrQ Swl61625eLt3uu/D/DZvcTLLYgJAJs+mw+RQRCYx03BSssVW/XdlQllDmzS96PJEU1g== 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=a9DTXWSj; 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 16C01606A339; Fri, 4 Dec 2026 11:51:53 +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=a9DTXWSj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86EBD1F00933; Fri, 4 Dec 2026 11:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385112; bh=LqWfXN9Hw1zyp1IB0HpsR+C7RXdjGHQiIGZRHQbGDzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a9DTXWSjTZbCeqZZUQyPrRkTM2xhfGBkAYQfVWjUgiGz3xqQQWGQsDVc65WYUFRlz ifkZMZgA1ITfsrIgWGfpDsLhJA/Vu03lzpQKghnOFw9/z81nZOnBVAzma/agvObh4L eKbyH7M+lh/uL3gZkNwSCTK2GkM1C8unc9mvykf8= 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.6 0424/1167] btrfs: drop the extent maps of the written part of a failed ordered extent Date: Fri, 4 Dec 2026 18:57:31 +0900 Message-ID: <20261204100713.063895858@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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: adjusted the hunk to the existing unwritten_start declaration at the top of the if (ret || truncated) block, so the condition change also widens the clear_extent_uptodate() range on error. ] Signed-off-by: Sasha Levin --- fs/btrfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b6d40f0f0fb28..b99f485ce0516 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3329,12 +3329,14 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent) &ordered_extent->flags)) mapping_set_error(ordered_extent->inode->i_mapping, -EIO); - if (truncated) + if (truncated && !ret) unwritten_start += logical_len; clear_extent_uptodate(io_tree, unwritten_start, end, NULL); /* * 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 -- 2.53.0