]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit - fs/btrfs/space-info.h
btrfs: handle space_info::total_bytes_pinned inside the delayed ref itself
authorJosef Bacik <josef@toxicpanda.com>
Fri, 15 Jan 2021 21:48:55 +0000 (16:48 -0500)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 15 Mar 2021 14:09:42 +0000 (15:09 +0100)
commit290693c88168451775881b2cb2bcc240a95bf91e
tree3f8dc446c231af2d48acdccdae2fd85840cc1464
parent25f4538e20d2375121b864f731c2607f70064570
btrfs: handle space_info::total_bytes_pinned inside the delayed ref itself

commit 2187374f35fe9cadbddaa9fcf0c4121365d914e8 upstream.

Currently we pass things around to figure out if we maybe freeing data
based on the state of the delayed refs head.  This makes the accounting
sort of confusing and hard to follow, as it's distinctly separate from
the delayed ref heads stuff, but also depends on it entirely.

Fix this by explicitly adjusting the space_info->total_bytes_pinned in
the delayed refs code.  We now have two places where we modify this
counter, once where we create the delayed and destroy the delayed refs,
and once when we pin and unpin the extents.  This means there is a
slight overlap between delayed refs and the pin/unpin mechanisms, but
this is simply used by the ENOSPC infrastructure to determine if we need
to commit the transaction, so there's no adverse affect from this, we
might simply commit thinking it will give us enough space when it might
not.

CC: stable@vger.kernel.org # 5.10
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
fs/btrfs/block-group.c
fs/btrfs/delayed-ref.c
fs/btrfs/delayed-ref.h
fs/btrfs/extent-tree.c
fs/btrfs/space-info.h