]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.4.247/btrfs-check-return-value-of-btrfs_commit_transaction-in-relocation.patch
Linux 5.4.247
[thirdparty/kernel/stable-queue.git] / releases / 5.4.247 / btrfs-check-return-value-of-btrfs_commit_transaction-in-relocation.patch
CommitLineData
425ebf0b
GKH
1From fb686c6824dd6294ca772b92424b8fba666e7d00 Mon Sep 17 00:00:00 2001
2From: Josef Bacik <josef@toxicpanda.com>
3Date: Fri, 12 Mar 2021 15:25:34 -0500
4Subject: btrfs: check return value of btrfs_commit_transaction in relocation
5
6From: Josef Bacik <josef@toxicpanda.com>
7
8commit fb686c6824dd6294ca772b92424b8fba666e7d00 upstream.
9
10There are a few places where we don't check the return value of
11btrfs_commit_transaction in relocation.c. Thankfully all these places
12have straightforward error handling, so simply change all of the sites
13at once.
14
15Reviewed-by: Qu Wenruo <wqu@suse.com>
16Signed-off-by: Josef Bacik <josef@toxicpanda.com>
17Reviewed-by: David Sterba <dsterba@suse.com>
18Signed-off-by: David Sterba <dsterba@suse.com>
19Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21---
22 fs/btrfs/relocation.c | 9 +++++----
23 1 file changed, 5 insertions(+), 4 deletions(-)
24
25--- a/fs/btrfs/relocation.c
26+++ b/fs/btrfs/relocation.c
27@@ -2511,7 +2511,7 @@ again:
28 list_splice(&reloc_roots, &rc->reloc_roots);
29
30 if (!err)
31- btrfs_commit_transaction(trans);
32+ err = btrfs_commit_transaction(trans);
33 else
34 btrfs_end_transaction(trans);
35 return err;
36@@ -4102,8 +4102,7 @@ int prepare_to_relocate(struct reloc_con
37 */
38 return PTR_ERR(trans);
39 }
40- btrfs_commit_transaction(trans);
41- return 0;
42+ return btrfs_commit_transaction(trans);
43 }
44
45 static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
46@@ -4263,7 +4262,9 @@ restart:
47 err = PTR_ERR(trans);
48 goto out_free;
49 }
50- btrfs_commit_transaction(trans);
51+ ret = btrfs_commit_transaction(trans);
52+ if (ret && !err)
53+ err = ret;
54 out_free:
55 ret = clean_dirty_subvols(rc);
56 if (ret < 0 && !err)