Re: [RFC] ext4: Add support for ext4_map_blocks_atomic()

From: IBM
Date: Fri Mar 08 2024 - 21:37:42 EST


"Ritesh Harjani (IBM)" <ritesh.list@xxxxxxxxx> writes:

> +int ext4_map_blocks_atomic(handle_t *handle, struct inode *inode,
> + struct ext4_map_blocks *map, int flags)
> +{
> + unsigned int mapped_len = 0, m_len = map->m_len;
> + ext4_lblk_t m_lblk = map->m_lblk;
> + int ret;
> +
> + WARN_ON(!(flags & EXT4_GET_BLOCKS_CREATE));
> +
> + do {
> + ret = ext4_map_blocks(handle, inode, map, flags);
> + if (ret < 0)
> + return ret;
> + mapped_len += map->m_len;
> + map->m_lblk += map->m_len;
> + map->m_len = m_len - mapped_len;
> + } while (mapped_len < m_len);
> +
> + map->m_lblk = m_lblk;
> + map->m_len = mapped_len;
> + return mapped_len;

ouch!
1. I need to make sure map.m_pblk is updated properly.
2. I need to make sure above call only happens with bigalloc.

Sorry about that. Generally not a good idea to send something that late
at night.
But I guess this can be fixed easily. so hopefully the algorithm should
still remain, more or less the same for ext4_map_blocks_atomic().

-ritesh