Re: [PATCH v2 10/13] ext4: add tracepoints for extent split and convert

From: Zhang Yi

Date: Thu Dec 03 2026 - 03:02:24 EST


On 11/27/2026 11:10 PM, Ojaswin Mujoo wrote:
> Add some useful tracepoint to track how the extent split, conversion and
> zeroout fallback behave. Also add a tracepoint to track conlicts in extent
> status cache.
>
> Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>
> ---
> fs/ext4/extents.c | 29 +++++++
> fs/ext4/extents_status.c | 2 +
> include/trace/events/ext4.h | 189 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 220 insertions(+)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index b816e9edb041..0f5d9f3c42a9 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3390,6 +3390,10 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
> pblk = ext4_ext_pblock(ex);
> err = ext4_issue_zeroout(handle, inode, lblk, pblk,
> len);
> + trace_ext4_extent_zeroout(inode, ee_block, ee_len,
> + ext4_ext_pblock(ex),
> + is_unwrit, lblk, pblk, len,
> + err);
> if (err)
> /* ZEROOUT failed, just return original error */
> return err;
> @@ -3402,6 +3406,10 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
> pblk = ext4_ext_pblock(ex) + (map_end - ee_block);
> err = ext4_issue_zeroout(handle, inode, lblk, pblk,
> len);
> + trace_ext4_extent_zeroout(inode, ee_block, ee_len,
> + ext4_ext_pblock(ex),
> + is_unwrit, lblk, pblk, len,
> + err);
> if (err)
> /* ZEROOUT failed, just return original error */
> return err;
> @@ -3421,6 +3429,9 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
> len = map->m_len;
> pblk = ext4_ext_pblock(ex) + (map->m_lblk - ee_block);
> err = ext4_issue_zeroout(handle, inode, lblk, pblk, len);
> + trace_ext4_extent_zeroout(inode, ee_block, ee_len,
> + ext4_ext_pblock(ex), is_unwrit,
> + lblk, pblk, len, err);
> if (err)
> /* ZEROOUT failed, just return original error */
> return err;
> @@ -3519,6 +3530,9 @@ static struct ext4_ext_path *ext4_split_extent(handle_t *handle,
> goto try_zeroout;
> }
>
> + trace_ext4_extent_split(inode, map, ee_block, ee_len, flags,
> + unwritten);
> +
> goto success;
>
> try_zeroout:
> @@ -3882,6 +3896,9 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> struct ext4_extent *ex;
> struct ext4_extent converted_ex;
> unsigned int ee_len;
> + ext4_lblk_t old_ee_block;
> + unsigned int old_ee_len;
> + bool old_unwrit;
> int split_flag = 0, depth, err = 0;
> bool did_zeroout = false;
>
> @@ -3897,6 +3914,9 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> ee_block = le32_to_cpu(ex->ee_block);
> ee_len = ext4_ext_get_actual_len(ex);
>
> + trace_ext4_split_convert_enter(inode, map, ee_block, ee_len, flags,
> + ext4_ext_is_unwritten(ex));
> +
> /* No split needed */
> if (ee_block == map->m_lblk && ee_len == map->m_len)
> goto convert;
> @@ -3933,6 +3953,10 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> if (err)
> goto err;
>
> + old_ee_block = le32_to_cpu(ex->ee_block);
> + old_ee_len = ext4_ext_get_actual_len(ex);
> + old_unwrit = ext4_ext_is_unwritten(ex);
> +
> if (flags & EXT4_GET_BLOCKS_CONVERT)
> ext4_ext_mark_initialized(ex);
> else if (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)
> @@ -3952,6 +3976,11 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> if (err)
> goto err;
> ex = &converted_ex;
> +
> + trace_ext4_extent_convert(inode, map, old_ee_block, old_ee_len,
> + old_unwrit, le32_to_cpu(ex->ee_block),
> + ext4_ext_get_actual_len(ex),
> + ext4_ext_is_unwritten(ex), flags);

This looks a bit odd here. You defined three temporary variables, but
old_ee_block and old_ee_len are actually the same as the values obtained
from the latest ex. I guess you probably wanted to print the extent
information before the conversion and the extent information after the
conversion and merge (if it happens), right?

Thanks,
Yi.