{
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
        struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
+       struct btrfs_bio *bbio = NULL;
        struct btrfs_path *path;
        const u32 sectorsize = fs_info->sectorsize;
        const u32 csum_size = fs_info->csum_size;
        u8 *csum;
        const unsigned int nblocks = orig_len >> fs_info->sectorsize_bits;
        int count = 0;
+       blk_status_t ret = BLK_STS_OK;
 
        if ((BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM) ||
            test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state))
                return BLK_STS_RESOURCE;
 
        if (!dst) {
-               struct btrfs_bio *bbio = btrfs_bio(bio);
+               bbio = btrfs_bio(bio);
 
                if (nblocks * csum_size > BTRFS_BIO_INLINE_CSUM_SIZE) {
                        bbio->csum = kmalloc_array(nblocks, csum_size, GFP_NOFS);
 
                count = search_csum_tree(fs_info, path, cur_disk_bytenr,
                                         search_len, csum_dst);
-               if (count <= 0) {
-                       /*
-                        * Either we hit a critical error or we didn't find
-                        * the csum.
-                        * Either way, we put zero into the csums dst, and skip
-                        * to the next sector.
-                        */
+               if (count < 0) {
+                       ret = errno_to_blk_status(count);
+                       if (bbio)
+                               btrfs_bio_free_csum(bbio);
+                       break;
+               }
+
+               /*
+                * We didn't find a csum for this range.  We need to make sure
+                * we complain loudly about this, because we are not NODATASUM.
+                *
+                * However for the DATA_RELOC inode we could potentially be
+                * relocating data extents for a NODATASUM inode, so the inode
+                * itself won't be marked with NODATASUM, but the extent we're
+                * copying is in fact NODATASUM.  If we don't find a csum we
+                * assume this is the case.
+                */
+               if (count == 0) {
                        memset(csum_dst, 0, csum_size);
                        count = 1;
 
-                       /*
-                        * For data reloc inode, we need to mark the range
-                        * NODATASUM so that balance won't report false csum
-                        * error.
-                        */
                        if (BTRFS_I(inode)->root->root_key.objectid ==
                            BTRFS_DATA_RELOC_TREE_OBJECTID) {
                                u64 file_offset;
        }
 
        btrfs_free_path(path);
-       return BLK_STS_OK;
+       return ret;
 }
 
 int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,