Lines Matching refs:em
1161 struct extent_map *em; in submit_one_async_extent() local
1212 em = btrfs_create_io_em(inode, start, &file_extent, BTRFS_ORDERED_COMPRESSED); in submit_one_async_extent()
1213 if (IS_ERR(em)) { in submit_one_async_extent()
1214 ret = PTR_ERR(em); in submit_one_async_extent()
1217 free_extent_map(em); in submit_one_async_extent()
1268 struct extent_map *em; in btrfs_get_extent_allocation_hint() local
1272 em = search_extent_mapping(em_tree, start, num_bytes); in btrfs_get_extent_allocation_hint()
1273 if (em) { in btrfs_get_extent_allocation_hint()
1279 if (em->disk_bytenr >= EXTENT_MAP_LAST_BYTE) { in btrfs_get_extent_allocation_hint()
1280 free_extent_map(em); in btrfs_get_extent_allocation_hint()
1281 em = search_extent_mapping(em_tree, 0, 0); in btrfs_get_extent_allocation_hint()
1282 if (em && em->disk_bytenr < EXTENT_MAP_LAST_BYTE) in btrfs_get_extent_allocation_hint()
1283 alloc_hint = extent_map_block_start(em); in btrfs_get_extent_allocation_hint()
1284 if (em) in btrfs_get_extent_allocation_hint()
1285 free_extent_map(em); in btrfs_get_extent_allocation_hint()
1287 alloc_hint = extent_map_block_start(em); in btrfs_get_extent_allocation_hint()
1288 free_extent_map(em); in btrfs_get_extent_allocation_hint()
1339 struct extent_map *em; in cow_file_range() local
1437 em = btrfs_create_io_em(inode, start, &file_extent, in cow_file_range()
1439 if (IS_ERR(em)) { in cow_file_range()
1442 ret = PTR_ERR(em); in cow_file_range()
1445 free_extent_map(em); in cow_file_range()
2158 struct extent_map *em; in run_delalloc_nocow() local
2160 em = btrfs_create_io_em(inode, cur_offset, in run_delalloc_nocow()
2163 if (IS_ERR(em)) { in run_delalloc_nocow()
2167 ret = PTR_ERR(em); in run_delalloc_nocow()
2170 free_extent_map(em); in run_delalloc_nocow()
2626 struct extent_map *em; in btrfs_find_new_delalloc_bytes() local
2630 em = btrfs_get_extent(inode, NULL, search_start, search_len); in btrfs_find_new_delalloc_bytes()
2631 if (IS_ERR(em)) in btrfs_find_new_delalloc_bytes()
2632 return PTR_ERR(em); in btrfs_find_new_delalloc_bytes()
2634 if (em->disk_bytenr != EXTENT_MAP_HOLE) in btrfs_find_new_delalloc_bytes()
2637 em_len = em->len; in btrfs_find_new_delalloc_bytes()
2638 if (em->start < search_start) in btrfs_find_new_delalloc_bytes()
2639 em_len -= search_start - em->start; in btrfs_find_new_delalloc_bytes()
2647 search_start = extent_map_end(em); in btrfs_find_new_delalloc_bytes()
2648 free_extent_map(em); in btrfs_find_new_delalloc_bytes()
4935 struct extent_map *em = NULL; in btrfs_cont_expand() local
4960 em = btrfs_get_extent(inode, NULL, cur_offset, block_end - cur_offset); in btrfs_cont_expand()
4961 if (IS_ERR(em)) { in btrfs_cont_expand()
4962 ret = PTR_ERR(em); in btrfs_cont_expand()
4963 em = NULL; in btrfs_cont_expand()
4966 last_byte = min(extent_map_end(em), block_end); in btrfs_cont_expand()
4970 if (!(em->flags & EXTENT_FLAG_PREALLOC)) { in btrfs_cont_expand()
5007 free_extent_map(em); in btrfs_cont_expand()
5008 em = NULL; in btrfs_cont_expand()
5013 free_extent_map(em); in btrfs_cont_expand()
6817 struct extent_map *em = NULL; in btrfs_get_extent() local
6821 em = lookup_extent_mapping(em_tree, start, len); in btrfs_get_extent()
6824 if (em) { in btrfs_get_extent()
6825 if (em->start > start || em->start + em->len <= start) in btrfs_get_extent()
6826 free_extent_map(em); in btrfs_get_extent()
6827 else if (em->disk_bytenr == EXTENT_MAP_INLINE && folio) in btrfs_get_extent()
6828 free_extent_map(em); in btrfs_get_extent()
6832 em = alloc_extent_map(); in btrfs_get_extent()
6833 if (!em) { in btrfs_get_extent()
6837 em->start = EXTENT_MAP_HOLE; in btrfs_get_extent()
6838 em->disk_bytenr = EXTENT_MAP_HOLE; in btrfs_get_extent()
6839 em->len = (u64)-1; in btrfs_get_extent()
6928 em->start = start; in btrfs_get_extent()
6929 em->len = found_key.offset - start; in btrfs_get_extent()
6930 em->disk_bytenr = EXTENT_MAP_HOLE; in btrfs_get_extent()
6934 btrfs_extent_item_to_extent_map(inode, path, item, em); in btrfs_get_extent()
6946 ASSERT(em->start == 0); in btrfs_get_extent()
6954 ASSERT(em->disk_bytenr == EXTENT_MAP_INLINE); in btrfs_get_extent()
6955 ASSERT(em->len == fs_info->sectorsize); in btrfs_get_extent()
6963 em->start = start; in btrfs_get_extent()
6964 em->len = len; in btrfs_get_extent()
6965 em->disk_bytenr = EXTENT_MAP_HOLE; in btrfs_get_extent()
6969 if (em->start > start || extent_map_end(em) <= start) { in btrfs_get_extent()
6972 em->start, em->len, start, len); in btrfs_get_extent()
6978 ret = btrfs_add_extent_mapping(inode, &em, start, len); in btrfs_get_extent()
6983 trace_btrfs_get_extent(root, inode, em); in btrfs_get_extent()
6986 free_extent_map(em); in btrfs_get_extent()
6989 return em; in btrfs_get_extent()
7127 struct extent_map *em; in btrfs_create_io_em() local
7167 em = alloc_extent_map(); in btrfs_create_io_em()
7168 if (!em) in btrfs_create_io_em()
7171 em->start = start; in btrfs_create_io_em()
7172 em->len = file_extent->num_bytes; in btrfs_create_io_em()
7173 em->disk_bytenr = file_extent->disk_bytenr; in btrfs_create_io_em()
7174 em->disk_num_bytes = file_extent->disk_num_bytes; in btrfs_create_io_em()
7175 em->ram_bytes = file_extent->ram_bytes; in btrfs_create_io_em()
7176 em->generation = -1; in btrfs_create_io_em()
7177 em->offset = file_extent->offset; in btrfs_create_io_em()
7178 em->flags |= EXTENT_FLAG_PINNED; in btrfs_create_io_em()
7180 extent_map_set_compression(em, file_extent->compression); in btrfs_create_io_em()
7182 ret = btrfs_replace_extent_map_range(inode, em, true); in btrfs_create_io_em()
7184 free_extent_map(em); in btrfs_create_io_em()
7189 return em; in btrfs_create_io_em()
8757 struct extent_map *em; in __btrfs_prealloc_file_range() local
8812 em = alloc_extent_map(); in __btrfs_prealloc_file_range()
8813 if (!em) { in __btrfs_prealloc_file_range()
8820 em->start = cur_offset; in __btrfs_prealloc_file_range()
8821 em->len = ins.offset; in __btrfs_prealloc_file_range()
8822 em->disk_bytenr = ins.objectid; in __btrfs_prealloc_file_range()
8823 em->offset = 0; in __btrfs_prealloc_file_range()
8824 em->disk_num_bytes = ins.offset; in __btrfs_prealloc_file_range()
8825 em->ram_bytes = ins.offset; in __btrfs_prealloc_file_range()
8826 em->flags |= EXTENT_FLAG_PREALLOC; in __btrfs_prealloc_file_range()
8827 em->generation = trans->transid; in __btrfs_prealloc_file_range()
8829 ret = btrfs_replace_extent_map_range(BTRFS_I(inode), em, true); in __btrfs_prealloc_file_range()
8830 free_extent_map(em); in __btrfs_prealloc_file_range()
9255 struct extent_map *em; in btrfs_encoded_read() local
9319 em = btrfs_get_extent(inode, NULL, start, lockend - start + 1); in btrfs_encoded_read()
9320 if (IS_ERR(em)) { in btrfs_encoded_read()
9321 ret = PTR_ERR(em); in btrfs_encoded_read()
9325 if (em->disk_bytenr == EXTENT_MAP_INLINE) { in btrfs_encoded_read()
9326 u64 extent_start = em->start; in btrfs_encoded_read()
9332 free_extent_map(em); in btrfs_encoded_read()
9333 em = NULL; in btrfs_encoded_read()
9344 encoded->len = min_t(u64, extent_map_end(em), in btrfs_encoded_read()
9346 if (em->disk_bytenr == EXTENT_MAP_HOLE || in btrfs_encoded_read()
9347 (em->flags & EXTENT_FLAG_PREALLOC)) { in btrfs_encoded_read()
9352 } else if (extent_map_is_compressed(em)) { in btrfs_encoded_read()
9353 *disk_bytenr = em->disk_bytenr; in btrfs_encoded_read()
9358 if (em->disk_num_bytes > count) { in btrfs_encoded_read()
9362 *disk_io_size = em->disk_num_bytes; in btrfs_encoded_read()
9363 count = em->disk_num_bytes; in btrfs_encoded_read()
9364 encoded->unencoded_len = em->ram_bytes; in btrfs_encoded_read()
9365 encoded->unencoded_offset = iocb->ki_pos - (em->start - em->offset); in btrfs_encoded_read()
9367 extent_map_compression(em)); in btrfs_encoded_read()
9372 *disk_bytenr = extent_map_block_start(em) + (start - em->start); in btrfs_encoded_read()
9385 free_extent_map(em); in btrfs_encoded_read()
9386 em = NULL; in btrfs_encoded_read()
9401 free_extent_map(em); in btrfs_encoded_read()
9431 struct extent_map *em; in btrfs_do_encoded_write() local
9604 em = btrfs_create_io_em(inode, start, &file_extent, BTRFS_ORDERED_COMPRESSED); in btrfs_do_encoded_write()
9605 if (IS_ERR(em)) { in btrfs_do_encoded_write()
9606 ret = PTR_ERR(em); in btrfs_do_encoded_write()
9609 free_extent_map(em); in btrfs_do_encoded_write()
9802 struct extent_map *em = NULL; in btrfs_swap_activate() local
9898 em = btrfs_get_extent(BTRFS_I(inode), NULL, start, len); in btrfs_swap_activate()
9899 if (IS_ERR(em)) { in btrfs_swap_activate()
9900 ret = PTR_ERR(em); in btrfs_swap_activate()
9904 if (em->disk_bytenr == EXTENT_MAP_HOLE) { in btrfs_swap_activate()
9909 if (em->disk_bytenr == EXTENT_MAP_INLINE) { in btrfs_swap_activate()
9921 if (extent_map_is_compressed(em)) { in btrfs_swap_activate()
9927 logical_block_start = extent_map_block_start(em) + (start - em->start); in btrfs_swap_activate()
9928 len = min(len, em->len - (start - em->start)); in btrfs_swap_activate()
9929 free_extent_map(em); in btrfs_swap_activate()
9930 em = NULL; in btrfs_swap_activate()
10025 if (!IS_ERR_OR_NULL(em)) in btrfs_swap_activate()
10026 free_extent_map(em); in btrfs_swap_activate()