• Filipe Manana's avatar
    btrfs: add assertions when deleting batches of delayed items · 659192e6
    Filipe Manana authored
    There are a few impossible cases that btrfs_batch_delete_items() tries to
    deal with:
    
    1) Getting a path pointing to a NULL leaf;
    2) The leaf slot is pointing beyond the last item in the leaf;
    3) We can't find a single item to delete.
    
    The first case is impossible because the given path was returned by a
    successful call to btrfs_search_slot(). Replace the BUG_ON() with an
    ASSERT for this.
    
    The second case is impossible because we are always called when a delayed
    item matches an item in the given leaf. So add an ASSERT() for that and
    if that condition is not satisfied, trigger a warning and return an error.
    
    The third case is impossible exactly because of the same reason as the
    second case. The given delayed item matches one item in the leaf, so we
    know that our batch always has at least one item. Add an ASSERT to check
    that, trigger a warning if that expectation fails and return an error.
    Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
    Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    659192e6
delayed-inode.c 50.3 KB