• Qu Wenruo's avatar
    btrfs: add extra sanity checks for create_io_em() · e98bf64f
    Qu Wenruo authored
    The function create_io_em() is called before we submit an IO, to update
    the in-memory extent map for the involved range.
    
    This patch changes the following aspects:
    
    - Does not allow BTRFS_ORDERED_NOCOW type
      For real NOCOW (excluding NOCOW writes into preallocated ranges)
      writes, we never call create_io_em(), as we does not need to update
      the extent map at all.
    
      So remove the sanity check allowing BTRFS_ORDERED_NOCOW type.
    
    - Add extra sanity checks
      * PREALLOC
        - @block_len == len
          For uncompressed writes.
    
      * REGULAR
        - @block_len == @orig_block_len == @ram_bytes == @len
          We're creating a new uncompressed extent, and referring all of it.
    
        - @orig_start == @start
          We haven no offset inside the extent.
    
      * COMPRESSED
        - valid @compress_type
        - @len <= @ram_bytes
          This is to co-operate with encoded writes, which can cause a new
          file extent referring only part of a uncompressed extent.
    Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    e98bf64f
inode.c 312 KB