]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
btrfs: handle logged extent failure properly
authorJosef Bacik <josef@toxicpanda.com>
Thu, 13 Feb 2020 15:47:30 +0000 (10:47 -0500)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Feb 2020 23:39:08 +0000 (00:39 +0100)
commitbd727173e4432fe6cb70ba108dc1f3602c5409d7
tree7dc5a69deb1a811d728b3bcfa21c7e23e8068f87
parent1e90315149f3fe148e114a5de86f0196d1c21fa5
btrfs: handle logged extent failure properly

If we're allocating a logged extent we attempt to insert an extent
record for the file extent directly.  We increase
space_info->bytes_reserved, because the extent entry addition will call
btrfs_update_block_group(), which will convert the ->bytes_reserved to
->bytes_used.  However if we fail at any point while inserting the
extent entry we will bail and leave space on ->bytes_reserved, which
will trigger a WARN_ON() on umount.  Fix this by pinning the space if we
fail to insert, which is what happens in every other failure case that
involves adding the extent entry.

CC: stable@vger.kernel.org # 5.4+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c