Skip to content

Commit deaf895

Browse files
adam900710kdave
authored andcommitted
btrfs: fix wrong length parameter for btrfs_cleanup_ordered_extents()
Inside nocow_one_range(), if the checksum cloning for data reloc inode failed, we call btrfs_cleanup_ordered_extents() to cleanup the just allocated ordered extents. But unlike extent_clear_unlock_delalloc(), btrfs_cleanup_ordered_extents() requires a length, not an inclusive end bytenr. This can be problematic, as the @EnD is normally way larger than @len. This means btrfs_cleanup_ordered_extents() can be called on folios out of the correct range, and if the out-of-range folio is under writeback, we can incorrectly clear the ordered flag of the folio, and trigger the DEBUG_WARN() inside btrfs_writepage_cow_fixup(). Fix the wrong parameter with correct length instead. Fixes: 94f6c5c ("btrfs: move ordered extent cleanup to where they are allocated") CC: [email protected] # 6.15+ Reviewed-by: Boris Burkov <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 15fc0be commit deaf895

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ static int nocow_one_range(struct btrfs_inode *inode, struct folio *locked_folio
20152015
* cleaered by the caller.
20162016
*/
20172017
if (ret < 0)
2018-
btrfs_cleanup_ordered_extents(inode, file_pos, end);
2018+
btrfs_cleanup_ordered_extents(inode, file_pos, len);
20192019
return ret;
20202020
}
20212021

0 commit comments

Comments
 (0)