• Qu Wenruo's avatar
    btrfs: track qgroup released data in own variable in insert_prealloc_file_extent · fbf48bb0
    Qu Wenruo authored
    There is a piece of weird code in insert_prealloc_file_extent(), which
    looks like:
    
    	ret = btrfs_qgroup_release_data(inode, file_offset, len);
    	if (ret < 0)
    		return ERR_PTR(ret);
    	if (trans) {
    		ret = insert_reserved_file_extent(trans, inode,
    						  file_offset, &stack_fi,
    						  true, ret);
    	...
    	}
    	extent_info.is_new_extent = true;
    	extent_info.qgroup_reserved = ret;
    	...
    
    Note how the variable @ret is abused here, and if anyone is adding code
    just after btrfs_qgroup_release_data() call, it's super easy to
    overwrite the @ret and cause tons of qgroup related bugs.
    
    Fix such abuse by introducing new variable @qgroup_released, so that we
    won't reuse the existing variable @ret.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    fbf48bb0
inode.c 295 KB