• Josef Bacik's avatar
    btrfs: hold a ref on the root->reloc_root · f44deb74
    Josef Bacik authored
    We previously were relying on root->reloc_root to be cleaned up by the
    drop snapshot, or the error handling.  However if btrfs_drop_snapshot()
    failed it wouldn't drop the ref for the root.  Also we sort of depend on
    the right thing to happen with moving reloc roots between lists and the
    fs root they belong to, which makes it hard to figure out who owns the
    reference.
    
    Fix this by explicitly holding a reference on the reloc root for
    roo->reloc_root.  This means that we hold two references on reloc roots,
    one for whichever reloc_roots list it's attached to, and the
    root->reloc_root we're on.
    
    This makes it easier to reason out who owns a reference on the root, and
    when it needs to be dropped.
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    f44deb74
relocation.c 116 KB