]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
btrfs: Don't panic when we can't find a root key
authorQu Wenruo <wqu@suse.com>
Tue, 26 Feb 2019 08:33:56 +0000 (16:33 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:17 +0000 (19:02 +0200)
When we failed to find a root key in btrfs_update_root(), we just panic.

That's definitely not cool, fix it by outputting an unique error
message, aborting current transaction and return -EUCLEAN. This should
not normally happen as the root has been used by the callers in some
way.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/root-tree.c

index 893d12fbfda0761573b87acb790732b74c46ddc9..1b9a5d0de1392688ea78c3fdf421481223b70635 100644 (file)
@@ -137,11 +137,14 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
                goto out;
        }
 
-       if (ret != 0) {
-               btrfs_print_leaf(path->nodes[0]);
-               btrfs_crit(fs_info, "unable to update root key %llu %u %llu",
-                          key->objectid, key->type, key->offset);
-               BUG_ON(1);
+       if (ret > 0) {
+               btrfs_crit(fs_info,
+                       "unable to find root key (%llu %u %llu) in tree %llu",
+                       key->objectid, key->type, key->offset,
+                       root->root_key.objectid);
+               ret = -EUCLEAN;
+               btrfs_abort_transaction(trans, ret);
+               goto out;
        }
 
        l = path->nodes[0];