• Filipe Manana's avatar
    btrfs: assert tree lock is held when linking free space · 9649bd9a
    Filipe Manana authored
    When linking a free space entry, at link_free_space(), the caller should
    be holding the spinlock 'tree_lock' of the given btrfs_free_space_ctl
    argument, which is necessary for manipulating the red black tree of free
    space entries (done by tree_insert_offset(), which already asserts the
    lock is held) and for manipulating the 'free_space', 'free_extents',
    'discardable_extents' and 'discardable_bytes' counters of the given
    struct btrfs_free_space_ctl.
    
    So assert that the spinlock 'tree_lock' of the given btrfs_free_space_ctl
    is held by the current task. We have multiple code paths that end up
    calling link_free_space(), and all currently take the lock before calling
    it.
    Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    9649bd9a
free-space-cache.c 115 KB