Skip to content

Commit e2c8e92

Browse files
fdmananakdave
authored andcommitted
btrfs: fix wrong file range cleanup after an error filling dealloc range
If an error happens while running dellaloc in COW mode for a range, we can end up calling extent_clear_unlock_delalloc() for a range that goes beyond our range's end offset by 1 byte, which affects 1 extra page. This results in clearing bits and doing page operations (such as a page unlock) outside our target range. Fix that by calling extent_clear_unlock_delalloc() with an inclusive end offset, instead of an exclusive end offset, at cow_file_range(). Fixes: a315e68 ("Btrfs: fix invalid attempt to free reserved space on failure to cow range") CC: [email protected] # 4.14+ Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 213ff4b commit e2c8e92

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
@@ -1141,7 +1141,7 @@ static noinline int cow_file_range(struct inode *inode,
11411141
*/
11421142
if (extent_reserved) {
11431143
extent_clear_unlock_delalloc(inode, start,
1144-
start + cur_alloc_size,
1144+
start + cur_alloc_size - 1,
11451145
locked_page,
11461146
clear_bits,
11471147
page_ops);

0 commit comments

Comments
 (0)