• Filipe Manana's avatar
    btrfs: fix missing error handling when adding delayed ref with qgroups enabled · 6ef8fbce
    Filipe Manana authored
    When adding a delayed ref head, at delayed-ref.c:add_delayed_ref_head(),
    if we fail to insert the qgroup record we don't error out, we ignore it.
    In fact we treat it as if there was no error and there was already an
    existing record - we don't distinguish between the cases where
    btrfs_qgroup_trace_extent_nolock() returns 1, meaning a record already
    existed and we can free the given record, and the case where it returns
    a negative error value, meaning the insertion into the xarray that is
    used to track records failed.
    
    Effectively we end up ignoring that we are lacking qgroup record in the
    dirty extents xarray, resulting in incorrect qgroup accounting.
    
    Fix this by checking for errors and return them to the callers.
    
    Fixes: 3cce39a8 ("btrfs: qgroup: use xarray to track dirty extents in transaction")
    Reviewed-by: default avatarQu Wenruo <wqu@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>
    6ef8fbce
delayed-ref.c 35.4 KB