• ethanwu's avatar
    btrfs: Take trans lock before access running trans in check_delayed_ref · 998ac6d2
    ethanwu authored
    In preivous patch:
    Btrfs: kill trans in run_delalloc_nocow and btrfs_cross_ref_exist
    We avoid starting btrfs transaction and get this information from
    fs_info->running_transaction directly.
    
    When accessing running_transaction in check_delayed_ref, there's a
    chance that current transaction will be freed by commit transaction
    after the NULL pointer check of running_transaction is passed.
    
    After looking all the other places using fs_info->running_transaction,
    they are either protected by trans_lock or holding the transactions.
    
    Fix this by using trans_lock and increasing the use_count.
    
    Fixes: e4c3b2dc ("Btrfs: kill trans in run_delalloc_nocow and btrfs_cross_ref_exist")
    CC: stable@vger.kernel.org # 4.14+
    Signed-off-by: default avatarethanwu <ethanwu@synology.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    998ac6d2
extent-tree.c 303 KB