• Qu Wenruo's avatar
    btrfs: move tree block parentness check into validate_extent_buffer() · 947a6299
    Qu Wenruo authored
    [BACKGROUND]
    Although both btrfs metadata and data has their read time verification
    done at endio time (btrfs_validate_metadata_buffer() and
    btrfs_verify_data_csum()), metadata has extra verification, mostly
    parentness check including first key/transid/owner_root/level, done at
    read_tree_block() and btrfs_read_extent_buffer().
    
    On the other hand, all the data verification is done at endio context.
    
    [ENHANCEMENT]
    This patch will make a new union in btrfs_bio, taking the space of the
    old data checksums, thus it will not increase the memory usage.
    
    With that extra btrfs_tree_parent_check inside btrfs_bio, we can just
    pass the check parameter into read_extent_buffer_pages(), and before
    submitting the bio, we can copy the check structure into btrfs_bio.
    
    And finally at endio time, we can grab btrfs_bio::parent_check and pass
    it to validate_extent_buffer(), to move the remaining checks into it.
    
    This brings the following benefits:
    
    - Much simpler btrfs_read_extent_buffer()
      Now it only needs to iterate through all mirrors.
    
    - Simpler read-time transid check
      Previously we go verify_parent_transid() after reading out the extent
      buffer.
      Now the transid check is done inside the endio function, no other
      code can modify the content.
      Thus no need to use the extent lock anymore.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    947a6299
extent_io.c 160 KB