summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorTal Zussman <tz2294@columbia.edu>2026-10-15 10:43:14 -0400
committerDavid Sterba <dsterba@suse.com>2026-10-16 19:10:45 +0200
commitbca2cf55a7331e6b0ff95ad47fc2a7e8ecc7dc74 (patch)
tree258e800c0eb9b70415cb134d4561fcea63148d72 /fs/btrfs
parentcfeb5d28c0b877d1ef5fea50a2c20793c99464ae (diff)
btrfs: drop the extent maps of the written part of a failed ordered extent
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 <tz2294@columbia.edu> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/inode.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 343b6402bb35..271f6024b72b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3390,6 +3390,8 @@ out:
/*
* 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
@@ -3405,7 +3407,7 @@ out:
if (!btrfs_is_free_space_inode(inode)) {
u64 unwritten_start = start;
- if (truncated)
+ if (truncated && !ret)
unwritten_start += logical_len;
btrfs_drop_extent_map_range(inode, unwritten_start,