Skip to content

Commit a87911c

Browse files
lorddoskiasgregkh
authored andcommitted
btrfs: unlock extents in btrfs_zero_range in case of quota reservation errors
commit 4f6a49d upstream. If btrfs_qgroup_reserve_data returns an error (i.e quota limit reached) the handling logic directly goes to the 'out' label without first unlocking the extent range between lockstart, lockend. This results in deadlocks as other processes try to lock the same extent. Fixes: a7f8b1c ("btrfs: file: reserve qgroup space after the hole punch range is locked") CC: [email protected] # 5.10+ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 91bc329 commit a87911c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/btrfs/file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3151,8 +3151,11 @@ static int btrfs_zero_range(struct inode *inode,
31513151
goto out;
31523152
ret = btrfs_qgroup_reserve_data(inode, &data_reserved,
31533153
alloc_start, bytes_to_reserve);
3154-
if (ret)
3154+
if (ret) {
3155+
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart,
3156+
lockend, &cached_state);
31553157
goto out;
3158+
}
31563159
ret = btrfs_prealloc_file_range(inode, mode, alloc_start,
31573160
alloc_end - alloc_start,
31583161
i_blocksize(inode),

0 commit comments

Comments
 (0)