btrfs: handle extent reference errors in do_relocation
authorJosef Bacik <josef@toxicpanda.com>
Fri, 12 Mar 2021 20:25:25 +0000 (15:25 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Apr 2021 15:25:21 +0000 (17:25 +0200)
We can already deal with errors appropriately from do_relocation, simply
handle any errors that come from changing the refs at this point
cleanly.  We have to abort the transaction if we fail here as we've
modified metadata at this point.

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/relocation.c

index 2663c4bf0948a0338e652c2ddef37f435a3079e5..2d82e5170e4c0c56587850239daabb2cbf1519f6 100644 (file)
@@ -2437,10 +2437,11 @@ static int do_relocation(struct btrfs_trans_handle *trans,
                        btrfs_init_tree_ref(&ref, node->level,
                                            btrfs_header_owner(upper->eb));
                        ret = btrfs_inc_extent_ref(trans, &ref);
-                       BUG_ON(ret);
-
-                       ret = btrfs_drop_subtree(trans, root, eb, upper->eb);
-                       BUG_ON(ret);
+                       if (!ret)
+                               ret = btrfs_drop_subtree(trans, root, eb,
+                                                        upper->eb);
+                       if (ret)
+                               btrfs_abort_transaction(trans, ret);
                }
 next:
                if (!upper->pending)