Re: [PATCH 12/20] ext4: get rid of ppath in ext4_split_extent_at()

From: Baokun Li
Date: Sat Jul 27 2024 - 02:43:10 EST


On 2024/7/25 19:07, Jan Kara wrote:
On Wed 10-07-24 12:06:46, libaokun@xxxxxxxxxxxxxxx wrote:
From: Baokun Li <libaokun1@xxxxxxxxxx>

The use of path and ppath is now very confusing, so to make the code more
readable, pass path between functions uniformly, and get rid of ppath.

To get rid of the ppath in ext4_split_extent_at(), the following is done
here:

* Free the extents path when an error is encountered.
* Its caller needs to update ppath if it uses ppath.
* Teach ext4_ext_show_leaf() to skip error pointer.
* Propagate ext4_find_extent() error return value in ext4_insert_range().

No functional changes.

Signed-off-by: Baokun Li <libaokun1@xxxxxxxxxx>
One nit below:

@@ -5596,6 +5606,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len)
path = ext4_find_extent(inode, offset_lblk, NULL, 0);
if (IS_ERR(path)) {
up_write(&EXT4_I(inode)->i_data_sem);
+ ret = PTR_ERR(path);
goto out_stop;
}
AFAICT this actually fixes a bug where we could have returned 0 although
ext4_find_extent() spotted an error?
Yeah, exactly.
This would deserve a separate patch so
that it could be easily pulled into stable.

Otherwise looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza
Ok, I'll put this in a separate patch in the next version.

Thank you very much for your review!

--
With Best Regards,
Baokun Li