• Q
    btrfs: Add sanity check for EXTENT_DATA when reading out leaf · 40c3c409
    Qu Wenruo 提交于
    Add extra checks for item with EXTENT_DATA type.  This checks the
    following thing:
    
    0) Key offset
       All key offsets must be aligned to sectorsize.
       Inline extent must have 0 for key offset.
    
    1) Item size
       Uncompressed inline file extent size must match item size.
       (Compressed inline file extent has no information about its on-disk size.)
       Regular/preallocated file extent size must be a fixed value.
    
    2) Every member of regular file extent item
       Including alignment for bytenr and offset, possible value for
       compression/encryption/type.
    
    3) Type/compression/encode must be one of the valid values.
    
    This should be the most comprehensive and strict check in the context
    of btrfs_item for EXTENT_DATA.
    Signed-off-by: NQu Wenruo <quwenruo.btrfs@gmx.com>
    Reviewed-by: NNikolay Borisov <nborisov@suse.com>
    Reviewed-by: NDavid Sterba <dsterba@suse.com>
    [ switch to BTRFS_FILE_EXTENT_TYPES, similar to what
      BTRFS_COMPRESS_TYPES does ]
    Signed-off-by: NDavid Sterba <dsterba@suse.com>
    40c3c409
disk-io.c 128.3 KB