]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: change handle_fs_error in recover_log_trees to aborts
authorJosef Bacik <josef@toxicpanda.com>
Thu, 20 May 2021 14:46:01 +0000 (10:46 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 1 Jun 2021 18:59:52 +0000 (20:59 +0200)
During inspection of the return path for replay I noticed that we don't
actually abort the transaction if we get a failure during replay.  This
isn't a problem necessarily, as we properly return the error and will
fail to mount.  However we still leave this dangling transaction that
could conceivably be committed without thinking there was an error.
We were using btrfs_handle_fs_error() here, but that pre-dates the
transaction abort code.  Simply replace the btrfs_handle_fs_error()
calls with transaction aborts, so we still know where exactly things
went wrong, and add a few in some other un-handled error cases.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c

index ca597958c3ee3d3368798d2e852e10405fdb17ad..f387d292074516a33e5c2c2bbafd8ea685e2bb07 100644 (file)
@@ -6259,8 +6259,7 @@ again:
                ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0);
 
                if (ret < 0) {
-                       btrfs_handle_fs_error(fs_info, ret,
-                                   "Couldn't find tree log root.");
+                       btrfs_abort_transaction(trans, ret);
                        goto error;
                }
                if (ret > 0) {
@@ -6277,8 +6276,7 @@ again:
                log = btrfs_read_tree_root(log_root_tree, &found_key);
                if (IS_ERR(log)) {
                        ret = PTR_ERR(log);
-                       btrfs_handle_fs_error(fs_info, ret,
-                                   "Couldn't read tree log root.");
+                       btrfs_abort_transaction(trans, ret);
                        goto error;
                }
 
@@ -6306,8 +6304,7 @@ again:
 
                        if (!ret)
                                goto next;
-                       btrfs_handle_fs_error(fs_info, ret,
-                               "Couldn't read target root for tree log recovery.");
+                       btrfs_abort_transaction(trans, ret);
                        goto error;
                }
 
@@ -6315,14 +6312,15 @@ again:
                ret = btrfs_record_root_in_trans(trans, wc.replay_dest);
                if (ret)
                        /* The loop needs to continue due to the root refs */
-                       btrfs_handle_fs_error(fs_info, ret,
-                               "failed to record the log root in transaction");
+                       btrfs_abort_transaction(trans, ret);
                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,
                                                      path);
+                       if (ret)
+                               btrfs_abort_transaction(trans, ret);
                }
 
                if (!ret && wc.stage == LOG_WALK_REPLAY_ALL) {
@@ -6339,6 +6337,8 @@ again:
                         * could only happen during mount.
                         */
                        ret = btrfs_init_root_free_objectid(root);
+                       if (ret)
+                               btrfs_abort_transaction(trans, ret);
                }
 
                wc.replay_dest->log_root = NULL;