]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path
authorFilipe Manana <fdmanana@suse.com>
Mon, 29 Apr 2019 12:08:14 +0000 (13:08 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 9 May 2019 09:25:27 +0000 (11:25 +0200)
commit72bd2323ec87722c115a5906bc6a1b31d11e8f54
tree98542af39b8ce6b6894e45bf122e5acf115f407b
parentd7400ee1b476f201f8fb4264887d18bdb23ee352
Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path

Currently when we fail to COW a path at btrfs_update_root() we end up
always aborting the transaction. However all the current callers of
btrfs_update_root() are able to deal with errors returned from it, many do
end up aborting the transaction themselves (directly or not, such as the
transaction commit path), other BUG_ON() or just gracefully cancel whatever
they were doing.

When syncing the fsync log, we call btrfs_update_root() through
tree-log.c:update_log_root(), and if it returns an -ENOSPC error, the log
sync code does not abort the transaction, instead it gracefully handles
the error and returns -EAGAIN to the fsync handler, so that it falls back
to a transaction commit. Any other error different from -ENOSPC, makes the
log sync code abort the transaction.

So remove the transaction abort from btrfs_update_log() when we fail to
COW a path to update the root item, so that if an -ENOSPC failure happens
we avoid aborting the current transaction and have a chance of the fsync
succeeding after falling back to a transaction commit.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203413
Fixes: 79787eaab46121 ("btrfs: replace many BUG_ONs with proper error handling")
Cc: stable@vger.kernel.org # 4.4+
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/root-tree.c