btrfs: don't use ctl->free_space for max_extent_size
authorJosef Bacik <jbacik@fb.com>
Thu, 11 Oct 2018 19:54:09 +0000 (15:54 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:15:15 +0000 (11:15 -0800)
commit7509d4f9ad5ee2b6061f2073dfb5e3f48216c09f
tree341a3e547a024e3268f2e56768179171360568e6
parent65d41e98fd715f93b9d79e4583fdb5db7a176c44
btrfs: don't use ctl->free_space for max_extent_size

commit fb5c39d7a887108087de6ff93d3f326b01b4ef41 upstream.

max_extent_size is supposed to be the largest contiguous range for the
space info, and ctl->free_space is the total free space in the block
group.  We need to keep track of these separately and _only_ use the
max_free_space if we don't have a max_extent_size, as that means our
original request was too large to search any of the block groups for and
therefore wouldn't have a max_extent_size set.

CC: stable@vger.kernel.org # 4.14+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent-tree.c