]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix reclaim counter leak of space_info objects
authorFilipe Manana <fdmanana@suse.com>
Tue, 7 Apr 2020 10:38:49 +0000 (11:38 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 8 Apr 2020 17:11:19 +0000 (19:11 +0200)
commit1ec0e7a3a825b32746d017bc014570df9a36ae55
treec0f923bb98b5b7f04e00cba98ea58ad75409902a
parent959632016dfd5f5939959912aeb1e9a477ec4467
btrfs: fix reclaim counter leak of space_info objects

Whenever we add a ticket to a space_info object we increment the object's
reclaim_size counter witht the ticket's bytes, and we decrement it with
the corresponding amount only when we are able to grant the requested
space to the ticket. When we are not able to grant the space to a ticket,
or when the ticket is removed due to a signal (e.g. an application has
received sigterm from the terminal) we never decrement the counter with
the corresponding bytes from the ticket. This leak can result in the
space reclaim code to later do much more work than necessary. So fix it
by decrementing the counter when those two cases happen as well.

Fixes: 04b075ca5ef25e ("btrfs: account ticket size at add/delete time")
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/space-info.c