btrfs_record_root_in_trans will return errors in the future, so handle
the error properly in start_transaction.

Reviewed-by: Qu Wenruo <w...@suse.com>
Signed-off-by: Josef Bacik <jo...@toxicpanda.com>
---
 fs/btrfs/transaction.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index acff6bb49a97..3a3a582063b4 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -741,7 +741,11 @@ start_transaction(struct btrfs_root *root, unsigned int 
num_items,
         * 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) {
+               btrfs_end_transaction(h);
+               return ERR_PTR(ret);
+       }
 
        return h;
 
-- 
2.26.2

Reply via email to