Instead of calling mapping_set_error in cow_file_range for the !locked_page case, make the submit_uncompressed_range call mapping_set_error also for the !locked_page as that is the only caller that might pass a NULL locked_page. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- fs/btrfs/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 46d04803d76f13..9305a100b5f809 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1074,6 +1074,7 @@ static void submit_uncompressed_range(struct btrfs_inode *inode, wbc_detach_inode(&wbc); if (ret < 0) { btrfs_cleanup_ordered_extents(inode, locked_page, start, end - start + 1); + mapping_set_error(inode->vfs_inode.i_mapping, ret); if (locked_page) { const u64 page_start = page_offset(locked_page); @@ -1085,7 +1086,6 @@ static void submit_uncompressed_range(struct btrfs_inode *inode, btrfs_page_clear_uptodate(inode->root->fs_info, locked_page, page_start, PAGE_SIZE); - mapping_set_error(locked_page->mapping, ret); unlock_page(locked_page); } } @@ -1525,8 +1525,6 @@ static noinline int cow_file_range(struct btrfs_inode *inode, * pages (except @locked_page) to ensure all the pages are unlocked. */ if ((flags & CFR_KEEP_LOCKED) && orig_start < start) { - if (!locked_page) - mapping_set_error(inode->vfs_inode.i_mapping, ret); extent_clear_unlock_delalloc(inode, orig_start, start - 1, locked_page, 0, page_ops); } -- 2.39.2