• Qu Wenruo's avatar
    btrfs: relocation: review the call sites which can be interrupted by signal · 44d354ab
    Qu Wenruo authored
    Since most metadata reservation calls can return -EINTR when get
    interrupted by fatal signal, we need to review the all the metadata
    reservation call sites.
    
    In relocation code, the metadata reservation happens in the following
    sites:
    
    - btrfs_block_rsv_refill() in merge_reloc_root()
      merge_reloc_root() is a pretty critical section, we don't want to be
      interrupted by signal, so change the flush status to
      BTRFS_RESERVE_FLUSH_LIMIT, so it won't get interrupted by signal.
      Since such change can be ENPSPC-prone, also shrink the amount of
      metadata to reserve least amount avoid deadly ENOSPC there.
    
    - btrfs_block_rsv_refill() in reserve_metadata_space()
      It calls with BTRFS_RESERVE_FLUSH_LIMIT, which won't get interrupted
      by signal.
    
    - btrfs_block_rsv_refill() in prepare_to_relocate()
    
    - btrfs_block_rsv_add() in prepare_to_relocate()
    
    - btrfs_block_rsv_refill() in relocate_block_group()
    
    - btrfs_delalloc_reserve_metadata() in relocate_file_extent_cluster()
    
    - btrfs_start_transaction() in relocate_block_group()
    
    - btrfs_start_transaction() in create_reloc_inode()
      Can be interrupted by fatal signal and we can handle it easily.
      For these call sites, just catch the -EINTR value in btrfs_balance()
      and count them as canceled.
    
    CC: stable@vger.kernel.org # 5.4+
    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>
    44d354ab
volumes.c 204 KB