Btrfs: Search data ordered extents first for checksums on read
[linux-block.git] / fs / btrfs / disk-io.c
index 86e84a8579e32dd3dd7cfb708ac3d17a3d8ef077..7ce3f83c5dd633bab76b3a535361b28013b134d3 100644 (file)
@@ -1011,9 +1011,16 @@ void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
        spin_lock(&em_tree->lock);
        em = lookup_extent_mapping(em_tree, offset, PAGE_CACHE_SIZE);
        spin_unlock(&em_tree->lock);
-       if (!em)
+       if (!em) {
+               __unplug_io_fn(bdi, page);
                return;
+       }
 
+       if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
+               free_extent_map(em);
+               __unplug_io_fn(bdi, page);
+               return;
+       }
        offset = offset - em->start;
        btrfs_unplug_page(&BTRFS_I(inode)->root->fs_info->mapping_tree,
                          em->block_start + offset, page);