return ret;
 }
 
-static struct extent_map *get_chunk_map(struct btrfs_fs_info *fs_info,
-                                       u64 logical, u64 length)
+/*
+ * btrfs_get_chunk_map() - Find the mapping containing the given logical extent.
+ * @logical: Logical block offset in bytes.
+ * @length: Length of extent in bytes.
+ *
+ * Return: Chunk mapping or ERR_PTR.
+ */
+struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,
+                                      u64 logical, u64 length)
 {
        struct extent_map_tree *em_tree;
        struct extent_map *em;
        int i, ret = 0;
        struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 
-       em = get_chunk_map(fs_info, chunk_offset, 1);
+       em = btrfs_get_chunk_map(fs_info, chunk_offset, 1);
        if (IS_ERR(em)) {
                /*
                 * This is a logic error, but we don't want to just rely on the
        int i = 0;
        int ret = 0;
 
-       em = get_chunk_map(fs_info, chunk_offset, chunk_size);
+       em = btrfs_get_chunk_map(fs_info, chunk_offset, chunk_size);
        if (IS_ERR(em))
                return PTR_ERR(em);
 
        int miss_ndevs = 0;
        int i;
 
-       em = get_chunk_map(fs_info, chunk_offset, 1);
+       em = btrfs_get_chunk_map(fs_info, chunk_offset, 1);
        if (IS_ERR(em))
                return 1;
 
        struct map_lookup *map;
        int ret;
 
-       em = get_chunk_map(fs_info, logical, len);
+       em = btrfs_get_chunk_map(fs_info, logical, len);
        if (IS_ERR(em))
                /*
                 * We could return errors for these cases, but that could get
        struct map_lookup *map;
        unsigned long len = fs_info->sectorsize;
 
-       em = get_chunk_map(fs_info, logical, len);
+       em = btrfs_get_chunk_map(fs_info, logical, len);
 
        if (!WARN_ON(IS_ERR(em))) {
                map = em->map_lookup;
        struct map_lookup *map;
        int ret = 0;
 
-       em = get_chunk_map(fs_info, logical, len);
+       em = btrfs_get_chunk_map(fs_info, logical, len);
 
        if(!WARN_ON(IS_ERR(em))) {
                map = em->map_lookup;
        /* discard always return a bbio */
        ASSERT(bbio_ret);
 
-       em = get_chunk_map(fs_info, logical, length);
+       em = btrfs_get_chunk_map(fs_info, logical, length);
        if (IS_ERR(em))
                return PTR_ERR(em);
 
                return __btrfs_map_block_for_discard(fs_info, logical,
                                                     *length, bbio_ret);
 
-       em = get_chunk_map(fs_info, logical, *length);
+       em = btrfs_get_chunk_map(fs_info, logical, *length);
        if (IS_ERR(em))
                return PTR_ERR(em);
 
        u64 rmap_len;
        int i, j, nr = 0;
 
-       em = get_chunk_map(fs_info, chunk_start, 1);
+       em = btrfs_get_chunk_map(fs_info, chunk_start, 1);
        if (IS_ERR(em))
                return -EIO;