Skip to content

Commit

Permalink
btrfs: Go readonly on bad extent refs in update_ref_for_cow()
Browse files Browse the repository at this point in the history
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: Mark Fasheh <mfasheh@suse.de>
  • Loading branch information
Mark Fasheh authored and David Sterba committed Mar 22, 2012
1 parent 4ed1d16 commit e5df957
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
buf->len, &refs, &flags);
if (ret)
return ret;
BUG_ON(refs == 0);
if (refs == 0) {
ret = -EROFS;
btrfs_std_error(root->fs_info, ret);
return ret;
}
} else {
refs = 1;
if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID ||
Expand Down

0 comments on commit e5df957

Please sign in to comment.