Skip to content

Commit

Permalink
btrfs: return EUCLEAN if extent_inline_ref type is invalid
Browse files Browse the repository at this point in the history
If type of extent_inline_ref found is not expected, filesystem may have
been corrupted, should return EUCLEAN instead of EINVAL.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Su Yue authored and David Sterba committed Aug 6, 2018
1 parent e4af400 commit af431dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/backref.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ static int add_inline_refs(const struct btrfs_fs_info *fs_info,
type = btrfs_get_extent_inline_ref_type(leaf, iref,
BTRFS_REF_TYPE_ANY);
if (type == BTRFS_REF_TYPE_INVALID)
return -EINVAL;
return -EUCLEAN;

offset = btrfs_extent_inline_ref_offset(leaf, iref);

Expand Down Expand Up @@ -1793,7 +1793,7 @@ static int get_extent_inline_ref(unsigned long *ptr,
*out_type = btrfs_get_extent_inline_ref_type(eb, *out_eiref,
BTRFS_REF_TYPE_ANY);
if (*out_type == BTRFS_REF_TYPE_INVALID)
return -EINVAL;
return -EUCLEAN;

*ptr += btrfs_extent_inline_ref_size(*out_type);
WARN_ON(*ptr > end);
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
iref = (struct btrfs_extent_inline_ref *)ptr;
type = btrfs_get_extent_inline_ref_type(leaf, iref, needed);
if (type == BTRFS_REF_TYPE_INVALID) {
err = -EINVAL;
err = -EUCLEAN;
goto out;
}

Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
type = btrfs_get_extent_inline_ref_type(eb, iref,
BTRFS_REF_TYPE_BLOCK);
if (type == BTRFS_REF_TYPE_INVALID) {
err = -EINVAL;
err = -EUCLEAN;
goto out;
}
key.type = type;
Expand Down Expand Up @@ -3801,7 +3801,7 @@ int add_data_references(struct reloc_control *rc,
ret = find_data_references(rc, extent_key,
eb, dref, blocks);
} else {
ret = -EINVAL;
ret = -EUCLEAN;
btrfs_err(rc->extent_root->fs_info,
"extent %llu slot %d has an invalid inline ref type",
eb->start, path->slots[0]);
Expand Down

0 comments on commit af431dc

Please sign in to comment.