diff options
author | Josef Bacik | 2021-03-12 15:25:08 -0500 |
---|---|---|
committer | David Sterba | 2021-04-19 17:25:20 +0200 |
commit | 68075ea8d760d6136900a268d65b7fd072977ccb (patch) | |
tree | eded5f94222c61b7f7ebb53a0b2e914846f3bdc2 /fs/btrfs | |
parent | d18c7bd95c3d1adf5de385acc8c0bdb64b1a8d68 (diff) |
btrfs: handle btrfs_record_root_in_trans failure in start_transaction
btrfs_record_root_in_trans will return errors in the future, so handle
the error properly in start_transaction.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/transaction.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 97c5e7396bce..deb18646a1f0 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -746,7 +746,16 @@ got_it: * Thus it need to be called after current->journal_info initialized, * or we can deadlock. */ - btrfs_record_root_in_trans(h, root); + ret = btrfs_record_root_in_trans(h, root); + if (ret) { + /* + * The transaction handle is fully initialized and linked with + * other structures so it needs to be ended in case of errors, + * not just freed. + */ + btrfs_end_transaction(h); + return ERR_PTR(ret); + } return h; |