• Filipe Manana's avatar
    btrfs: replace BUG_ON() at split_item() with proper error handling · 7569141e
    Filipe Manana authored
    There's no need to BUG_ON() at split_item() if the leaf does not have
    enough free space for the new item, we can just return -ENOSPC since
    the caller can deal with errors from split_item(). Also, as this is a
    very unlikely condition to happen, because the caller has invoked
    setup_leaf_for_split() before calling split_item(), surround the
    condition with a WARN_ON() which makes it easier to notice this
    unexpected condition and tags the if branch with 'unlikely' as well.
    
    I've actually once hit this BUG_ON() with some incorrect code changes
    I had, which was very inconvenient as it required rebooting the VM.
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    7569141e
ctree.c 135 KB