Skip to content

Commit ec9d669

Browse files
zhangyi089tytso
authored andcommitted
ext4: make ext4_set_iomap() recognize IOMAP_DELALLOC map type
Since ext4_map_blocks() can recognize a delayed allocated only extent, make ext4_set_iomap() can also recognize it, and remove the useless separate check in ext4_iomap_begin_report(). Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 874eaba commit ec9d669

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

fs/ext4/inode.c

+3-29
Original file line numberDiff line numberDiff line change
@@ -3262,6 +3262,9 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
32623262
iomap->addr = (u64) map->m_pblk << blkbits;
32633263
if (flags & IOMAP_DAX)
32643264
iomap->addr += EXT4_SB(inode->i_sb)->s_dax_part_off;
3265+
} else if (map->m_flags & EXT4_MAP_DELAYED) {
3266+
iomap->type = IOMAP_DELALLOC;
3267+
iomap->addr = IOMAP_NULL_ADDR;
32653268
} else {
32663269
iomap->type = IOMAP_HOLE;
32673270
iomap->addr = IOMAP_NULL_ADDR;
@@ -3424,35 +3427,11 @@ const struct iomap_ops ext4_iomap_overwrite_ops = {
34243427
.iomap_end = ext4_iomap_end,
34253428
};
34263429

3427-
static bool ext4_iomap_is_delalloc(struct inode *inode,
3428-
struct ext4_map_blocks *map)
3429-
{
3430-
struct extent_status es;
3431-
ext4_lblk_t offset = 0, end = map->m_lblk + map->m_len - 1;
3432-
3433-
ext4_es_find_extent_range(inode, &ext4_es_is_delayed,
3434-
map->m_lblk, end, &es);
3435-
3436-
if (!es.es_len || es.es_lblk > end)
3437-
return false;
3438-
3439-
if (es.es_lblk > map->m_lblk) {
3440-
map->m_len = es.es_lblk - map->m_lblk;
3441-
return false;
3442-
}
3443-
3444-
offset = map->m_lblk - es.es_lblk;
3445-
map->m_len = es.es_len - offset;
3446-
3447-
return true;
3448-
}
3449-
34503430
static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,
34513431
loff_t length, unsigned int flags,
34523432
struct iomap *iomap, struct iomap *srcmap)
34533433
{
34543434
int ret;
3455-
bool delalloc = false;
34563435
struct ext4_map_blocks map;
34573436
u8 blkbits = inode->i_blkbits;
34583437

@@ -3493,13 +3472,8 @@ static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,
34933472
ret = ext4_map_blocks(NULL, inode, &map, 0);
34943473
if (ret < 0)
34953474
return ret;
3496-
if (ret == 0)
3497-
delalloc = ext4_iomap_is_delalloc(inode, &map);
3498-
34993475
set_iomap:
35003476
ext4_set_iomap(inode, iomap, &map, offset, length, flags);
3501-
if (delalloc && iomap->type == IOMAP_HOLE)
3502-
iomap->type = IOMAP_DELALLOC;
35033477

35043478
return 0;
35053479
}

0 commit comments

Comments
 (0)