btrfs: Unlock extents in btrfs_zero_range in case of errors
PATCH 1/1 btrfs: Unlock extents in btrfs_zero_range in case of 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 processes try to lock the same extent.
--- fs/btrfs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/btrfs/file.c +4 -1
@@ -3259,8 +3259,11 @@ static int btrfs_zero_range(struct inode *inode, goto out; ret =btrfs_qgroup_reserve_data (BTRFS_I (inode), &data_reserved, alloc_start, bytes_to_reserve); -if (ret) +if (ret) { +unlock_extent_cached (&BTRFS_I (inode)->io_tree, lockstart, + lockend, &cached_state); goto out; + } ret = btrfs_prealloc_file_range(inode, mode, alloc_start, alloc_end - alloc_start, i_blocksize(inode),
Signature · 1 line
2.25.1
Quoted 7 lines · Nikolay Borisov
If
btrfs_qgroup_reserve_datareturns 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 processes try to lock the same extent.Fixes a7f8b1c2ac21 ("btrfs: file: reserve qgroup space after the hole punch range is locked")Signed-off-by Nikolay Borisov <[email protected]>
Thanks,
Qu
Quoted 22 lines
--- fs/btrfs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/btrfs/file.c +4
-1@@ -3259,8 +3259,11 @@ static int btrfs_zero_range(struct inode *inode, goto out; ret =btrfs_qgroup_reserve_data (BTRFS_I (inode), &data_reserved, alloc_start, bytes_to_reserve); -if (ret) +if (ret) { +unlock_extent_cached (&BTRFS_I (inode)->io_tree, lockstart, + lockend, &cached_state); goto out; + } ret = btrfs_prealloc_file_range(inode, mode, alloc_start, alloc_end - alloc_start, i_blocksize(inode),
Quoted 7 lines · Nikolay Borisov
If
btrfs_qgroup_reserve_datareturns 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 processes try to lock the same extent.Fixes a7f8b1c2ac21 ("btrfs: file: reserve qgroup space after the hole punch range is locked")Signed-off-by Nikolay Borisov <[email protected]>
Added to misc-next, thanks.