Commit e5df9573 authored by Mark Fasheh's avatar Mark Fasheh Committed by David Sterba

btrfs: Go readonly on bad extent refs in update_ref_for_cow()

update_ref_for_cow() will BUG_ON() after it's call to
btrfs_lookup_extent_info() if no existing references are found.  Since refs
are computed directly from disk, this should be treated as a corruption
instead of a logic error.
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.de>
parent 4ed1d16e
...@@ -333,7 +333,11 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, ...@@ -333,7 +333,11 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
buf->len, &refs, &flags); buf->len, &refs, &flags);
if (ret) if (ret)
return ret; return ret;
BUG_ON(refs == 0); if (refs == 0) {
ret = -EROFS;
btrfs_std_error(root->fs_info, ret);
return ret;
}
} else { } else {
refs = 1; refs = 1;
if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment