]> git.hungrycats.org Git - linux/commitdiff
Btrfs: abort transaction if we don't find the block group
authorJosef Bacik <jbacik@fb.com>
Fri, 12 Dec 2014 20:00:21 +0000 (15:00 -0500)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Sun, 8 Mar 2015 04:03:27 +0000 (23:03 -0500)
We shouldn't BUG_ON() if there is corruption.  I hit this while testing my block
group patch and the abort worked properly.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
(cherry picked from commit 70314796cf523fd96fbdb1d4c78fc51912a1621d)

fs/btrfs/extent-tree.c

index adb3fa6051c9973686196f5f15963015d16cc11b..52fbaa2864f1305c66ebd09975b90ac9b3f8bbe6 100644 (file)
@@ -3139,9 +3139,11 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
        struct extent_buffer *leaf;
 
        ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1);
-       if (ret < 0)
+       if (ret) {
+               if (ret > 0)
+                       ret = -ENOENT;
                goto fail;
-       BUG_ON(ret); /* Corruption */
+       }
 
        leaf = path->nodes[0];
        bi = btrfs_item_ptr_offset(leaf, path->slots[0]);
@@ -3149,11 +3151,9 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
        btrfs_mark_buffer_dirty(leaf);
        btrfs_release_path(path);
 fail:
-       if (ret) {
+       if (ret)
                btrfs_abort_transaction(trans, root, ret);
-               return ret;
-       }
-       return 0;
+       return ret;
 
 }