• Qu Wenruo's avatar
    btrfs: return correct error number for __extent_writepage_io() · 44e5801f
    Qu Wenruo authored
    [BUG]
    If we hit an error from submit_extent_page() inside
    __extent_writepage_io(), we could still return 0 to the caller, and
    even trigger the warning in btrfs_page_assert_not_dirty().
    
    [CAUSE]
    In __extent_writepage_io(), if we hit an error from
    submit_extent_page(), we will just clean up the range and continue.
    
    This is completely fine for regular PAGE_SIZE == sectorsize, as we can
    only hit one sector in one page, thus after the error we're ensured to
    exit and @ret will be saved.
    
    But for subpage case, we may have other dirty subpage range in the page,
    and in the next loop, we may succeeded submitting the next range.
    
    In that case, @ret will be overwritten, and we return 0 to the caller,
    while we have hit some error.
    
    [FIX]
    Introduce @has_error and @saved_ret to record the first error we hit, so
    we will never forget what error we hit.
    
    CC: stable@vger.kernel.org # 5.15+
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    44e5801f
extent_io.c 198 KB