]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: return EUCLEAN if extent_inline_ref type is invalid
authorSu Yue <suy.fnst@cn.fujitsu.com>
Fri, 22 Jun 2018 08:18:01 +0000 (16:18 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 6 Aug 2018 11:12:40 +0000 (13:12 +0200)
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>
fs/btrfs/backref.c
fs/btrfs/extent-tree.c
fs/btrfs/relocation.c

index 0a8e2e29a66b14b515e17ce9af85b6f7a6361c31..60f4afa8ecbc0273c855e365437b09638d16e93c 100644 (file)
@@ -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);
 
@@ -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);
index 37d8927015d9fa2b25082d04acf409614f3732f9..b28fa3d20ef72f62633311aef3efe558bb56ba0b 100644 (file)
@@ -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;
                }
 
index 22214033a4a2cbbaea816af9c94162281fe5970b..44722e939e341b47188e9e2c4bff4ba4cbd27033 100644 (file)
@@ -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;
@@ -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]);