summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2020-05-27 11:15:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-22 09:05:26 +0200
commit789555b22ba2e62fd197a17be075ec8314d0c0b2 (patch)
treebaa28481c20dcc283e941c7bdec9aee0dc7bdbb8 /fs/btrfs/inode.c
parent74bee8344b7defb5dd41de37290df51bc9e12f5e (diff)
downloadlinux-stable-789555b22ba2e62fd197a17be075ec8314d0c0b2.tar.gz
linux-stable-789555b22ba2e62fd197a17be075ec8314d0c0b2.tar.bz2
linux-stable-789555b22ba2e62fd197a17be075ec8314d0c0b2.zip
btrfs: fix wrong file range cleanup after an error filling dealloc range
[ Upstream commit e2c8e92d1140754073ad3799eb6620c76bab2078 ] 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: a315e68f6e8b30 ("Btrfs: fix invalid attempt to free reserved space on failure to cow range") CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b4f295a058d8..887f9ebc2bc2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1136,8 +1136,8 @@ out_unlock:
*/
if (extent_reserved) {
extent_clear_unlock_delalloc(inode, start,
- start + cur_alloc_size,
- start + cur_alloc_size,
+ start + cur_alloc_size - 1,
+ start + cur_alloc_size - 1,
locked_page,
clear_bits,
page_ops);