Skip to content

Commit 4f6a49d

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: unlock extents in btrfs_zero_range in case of quota reservation errors
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]>
1 parent aedb9d9 commit 4f6a49d

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
@@ -3260,8 +3260,11 @@ static int btrfs_zero_range(struct inode *inode,
32603260
goto out;
32613261
ret = btrfs_qgroup_reserve_data(BTRFS_I(inode), &data_reserved,
32623262
alloc_start, bytes_to_reserve);
3263-
if (ret)
3263+
if (ret) {
3264+
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart,
3265+
lockend, &cached_state);
32643266
goto out;
3267+
}
32653268
ret = btrfs_prealloc_file_range(inode, mode, alloc_start,
32663269
alloc_end - alloc_start,
32673270
i_blocksize(inode),

0 commit comments

Comments
 (0)