• Josef Bacik's avatar
    btrfs: get correct owning_root when dropping snapshot · d8ba2a91
    Josef Bacik authored
    Dave reported a bug where we were aborting the transaction while trying
    to cleanup the squota reservation for an extent.
    
    This turned out to be because we're doing btrfs_header_owner(next) in
    do_walk_down when we decide to free the block.  However in this code
    block we haven't explicitly read next, so it could be stale.  We would
    then get whatever garbage happened to be in the pages at this point.
    The commit that introduced that is "btrfs: track owning root in
    btrfs_ref".
    
    Fix this by saving the owner_root when we do the
    btrfs_lookup_extent_info().  We always do this in do_walk_down, it is
    how we make the decision of whether or not to delete the block.  This is
    cheap because we've already done the extent item lookup at this point,
    so it's straightforward to just grab the owner root as well.
    
    Then we can use this when deleting the metadata block without needing to
    force a read of the extent buffer to find the owner.
    
    This fixes the problem that Dave reported.
    Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    d8ba2a91
ctree.c 133 KB