Re: [PATCH 04/27] ext4: refactor ext4_punch_hole()

From: Jan Kara
Date: Wed Dec 04 2024 - 06:37:31 EST


On Tue 22-10-24 19:10:35, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@xxxxxxxxxx>
>
> The current implementation of ext4_punch_hole() contains complex
> position calculations and stale error tags. To improve the code's
> clarity and maintainability, it is essential to clean up the code and
> improve its readability, this can be achieved by: a) simplifying and
> renaming variables; b) eliminating unnecessary position calculations;
> c) writing back all data in data=journal mode, and drop page cache from
> the original offset to the end, rather than using aligned blocks,
> d) renaming the stale error tags.
>
> Signed-off-by: Zhang Yi <yi.zhang@xxxxxxxxxx>

Again, this should get slightly simplified with the new function (no need
for special data=journal handling) but overall it looks fine.

> -out_dio:
> +out_invalidate_lock:
> filemap_invalidate_unlock(mapping);
> -out_mutex:
> +out:
> inode_unlock(inode);
> return ret;
> }

I agree with Darrick that just 'out' is not a great name when we are
actually releasing inode->i_rwsem. So perhaps "out_inode_lock:"?

Honza

--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR