Skip to content

Commit e6ba61a

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: stable@vger.kernel.org # 5.10+ Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 37ffce9 commit e6ba61a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

fs/btrfs/file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3236,8 +3236,11 @@ static int btrfs_zero_range(struct inode *inode,
32363236
goto out;
32373237
ret = btrfs_qgroup_reserve_data(BTRFS_I(inode), &data_reserved,
32383238
alloc_start, bytes_to_reserve);
3239-
if (ret)
3239+
if (ret) {
3240+
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart,
3241+
lockend, &cached_state);
32403242
goto out;
3243+
}
32413244
ret = btrfs_prealloc_file_range(inode, mode, alloc_start,
32423245
alloc_end - alloc_start,
32433246
i_blocksize(inode),

0 commit comments

Comments
 (0)