Skip to content

Commit 7ac1e46

Browse files
adam900710kdave
authored andcommitted
btrfs: Don't panic when we can't find a root key
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 <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent c53839f commit 7ac1e46

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/btrfs/root-tree.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
137137
goto out;
138138
}
139139

140-
if (ret != 0) {
141-
btrfs_print_leaf(path->nodes[0]);
142-
btrfs_crit(fs_info, "unable to update root key %llu %u %llu",
143-
key->objectid, key->type, key->offset);
144-
BUG_ON(1);
140+
if (ret > 0) {
141+
btrfs_crit(fs_info,
142+
"unable to find root key (%llu %u %llu) in tree %llu",
143+
key->objectid, key->type, key->offset,
144+
root->root_key.objectid);
145+
ret = -EUCLEAN;
146+
btrfs_abort_transaction(trans, ret);
147+
goto out;
145148
}
146149

147150
l = path->nodes[0];

0 commit comments

Comments
 (0)