]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/btrfs-do-not-abort-transaction-at-btrfs_update_root-after-failure-to-cow-path.patch
Linux 4.14.123
[thirdparty/kernel/stable-queue.git] / queue-4.9 / btrfs-do-not-abort-transaction-at-btrfs_update_root-after-failure-to-cow-path.patch
1 From 72bd2323ec87722c115a5906bc6a1b31d11e8f54 Mon Sep 17 00:00:00 2001
2 From: Filipe Manana <fdmanana@suse.com>
3 Date: Mon, 29 Apr 2019 13:08:14 +0100
4 Subject: Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path
5
6 From: Filipe Manana <fdmanana@suse.com>
7
8 commit 72bd2323ec87722c115a5906bc6a1b31d11e8f54 upstream.
9
10 Currently when we fail to COW a path at btrfs_update_root() we end up
11 always aborting the transaction. However all the current callers of
12 btrfs_update_root() are able to deal with errors returned from it, many do
13 end up aborting the transaction themselves (directly or not, such as the
14 transaction commit path), other BUG_ON() or just gracefully cancel whatever
15 they were doing.
16
17 When syncing the fsync log, we call btrfs_update_root() through
18 tree-log.c:update_log_root(), and if it returns an -ENOSPC error, the log
19 sync code does not abort the transaction, instead it gracefully handles
20 the error and returns -EAGAIN to the fsync handler, so that it falls back
21 to a transaction commit. Any other error different from -ENOSPC, makes the
22 log sync code abort the transaction.
23
24 So remove the transaction abort from btrfs_update_log() when we fail to
25 COW a path to update the root item, so that if an -ENOSPC failure happens
26 we avoid aborting the current transaction and have a chance of the fsync
27 succeeding after falling back to a transaction commit.
28
29 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203413
30 Fixes: 79787eaab46121 ("btrfs: replace many BUG_ONs with proper error handling")
31 Cc: stable@vger.kernel.org # 4.4+
32 Signed-off-by: Filipe Manana <fdmanana@suse.com>
33 Reviewed-by: Anand Jain <anand.jain@oracle.com>
34 Signed-off-by: David Sterba <dsterba@suse.com>
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36
37 ---
38 fs/btrfs/root-tree.c | 4 +---
39 1 file changed, 1 insertion(+), 3 deletions(-)
40
41 --- a/fs/btrfs/root-tree.c
42 +++ b/fs/btrfs/root-tree.c
43 @@ -144,10 +144,8 @@ int btrfs_update_root(struct btrfs_trans
44 return -ENOMEM;
45
46 ret = btrfs_search_slot(trans, root, key, path, 0, 1);
47 - if (ret < 0) {
48 - btrfs_abort_transaction(trans, ret);
49 + if (ret < 0)
50 goto out;
51 - }
52
53 if (ret != 0) {
54 btrfs_print_leaf(root, path->nodes[0]);