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

This appears tricky, however we have a reference count on the
destination root, so if this fails we need to continue on in the loop to
make sure the properly cleanup is done.

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

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 2f1acc9aea9e..941b4dd96dd0 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -6278,8 +6278,12 @@ int btrfs_recover_log_trees(struct btrfs_root 
*log_root_tree)
                }
 
                wc.replay_dest->log_root = log;
-               btrfs_record_root_in_trans(trans, wc.replay_dest);
-               ret = walk_log_tree(trans, log, &wc);
+               ret = btrfs_record_root_in_trans(trans, wc.replay_dest);
+               if (ret)
+                       btrfs_handle_fs_error(fs_info, ret,
+                               "Couldn't record the root in the transaction.");
+               else
+                       ret = walk_log_tree(trans, log, &wc);
 
                if (!ret && wc.stage == LOG_WALK_REPLAY_ALL) {
                        ret = fixup_inode_link_counts(trans, wc.replay_dest,
-- 
2.26.2

Reply via email to