[PATCH 0/7] ext4 extent split/convert refactor and kunit tests

Ojaswin Mujoo posted 7 patches 1 month ago
There is a newer version of this series
fs/ext4/extents-test.c   | 871 +++++++++++++++++++++++++++++++++++++++
fs/ext4/extents.c        | 591 +++++++++++++++-----------
fs/ext4/extents_status.c |   3 +
fs/ext4/inode.c          |   4 +
4 files changed, 1226 insertions(+), 243 deletions(-)
create mode 100644 fs/ext4/extents-test.c
[PATCH 0/7] ext4 extent split/convert refactor and kunit tests
Posted by Ojaswin Mujoo 1 month ago
Offlate we've have seen multiple issues and inconsistencies in the
our extent splitting and conversion logic causing subtle bugs. Recent
patches by Yhang Zi [1] helped address some of the issues however
the messy use of EXT4_EXT_DATA_VALID* and EXT4_EXT_MARK_UNWRIT* flags
made the implementation confusing and error prone.

This patchset aims to refactor the explent split and convert code paths
to make the code simpler and the behavior consistent and easy to
understand. It also adds several Kunit tests to stress various
permutations of extent splitting and conversion.

I've rebased this over [2] since it seems like it'll go in first. 

Another idea I want to try out after this is proactively zeroout
before even trying to split, as Jan suggested here [3], but before
trying to do that I wanted to refactor and add some tests hence sending
these patches out first.

[1] https://lore.kernel.org/linux-ext4/20251129103247.686136-1-yi.zhang@huaweicloud.com/
[2] https://lore.kernel.org/linux-ext4/20251223011802.31238-1-yi.zhang@huaweicloud.com/T/#t
[3] https://lore.kernel.org/linux-ext4/yro4hwpttmy6e2zspvwjfdbpej6qvhlqjvlr5kp3nwffqgcnfd@z6qual55zhfq/

Rest of the details can be found in the commit messages.

Patch 1-2: new kunit tests
Patch 3-4: minor fixes
Patch 5: refactoring zeroout and making sure zeroout handles all
        permutations correctly
Patch 6: Refactoring ext4_split_* functions.
Patch 7: Enable zeroout for writ to unwrit case

Testing:
- I've run kvm-xfstests for 4k, 1k and bigalloc_4k with -g quick and I
  see no failures.
- Some new kunit tests that were failing due to inconsistencies are not
  passing
- Due to dev servers being down for eoy maintanence I couldn't run more
  rigourous tests. In the coming week I'll run stress and auto group as
  well.

Thoughts and comments are welcome.

Ojaswin Mujoo (7):
  ext4: kunit tests for extent splitting and conversion
  ext4: kunit tests for higher level extent manipulation functions
  ext4: propagate flags to convert_initialized_extent()
  ext4: propagate flags to ext4_convert_unwritten_extents_endio()
  ext4: Refactor zeroout path and handle all cases
  ext4: Refactor split and convert extents
  ext4: Allow zeroout when doing written to unwritten split

 fs/ext4/extents-test.c   | 871 +++++++++++++++++++++++++++++++++++++++
 fs/ext4/extents.c        | 591 +++++++++++++++-----------
 fs/ext4/extents_status.c |   3 +
 fs/ext4/inode.c          |   4 +
 4 files changed, 1226 insertions(+), 243 deletions(-)
 create mode 100644 fs/ext4/extents-test.c

-- 
2.51.0
Re: [PATCH 0/7] ext4 extent split/convert refactor and kunit tests
Posted by Ojaswin Mujoo 1 month ago
On Sun, Jan 04, 2026 at 05:49:13PM +0530, Ojaswin Mujoo wrote:
> Offlate we've have seen multiple issues and inconsistencies in the
> our extent splitting and conversion logic causing subtle bugs. Recent
> patches by Yhang Zi [1] helped address some of the issues however
> the messy use of EXT4_EXT_DATA_VALID* and EXT4_EXT_MARK_UNWRIT* flags
> made the implementation confusing and error prone.
> 
> This patchset aims to refactor the explent split and convert code paths
> to make the code simpler and the behavior consistent and easy to
> understand. It also adds several Kunit tests to stress various
> permutations of extent splitting and conversion.
> 
> I've rebased this over [2] since it seems like it'll go in first. 
> 
> Another idea I want to try out after this is proactively zeroout
> before even trying to split, as Jan suggested here [3], but before
> trying to do that I wanted to refactor and add some tests hence sending
> these patches out first.
> 
> [1] https://lore.kernel.org/linux-ext4/20251129103247.686136-1-yi.zhang@huaweicloud.com/
> [2] https://lore.kernel.org/linux-ext4/20251223011802.31238-1-yi.zhang@huaweicloud.com/T/#t
> [3] https://lore.kernel.org/linux-ext4/yro4hwpttmy6e2zspvwjfdbpej6qvhlqjvlr5kp3nwffqgcnfd@z6qual55zhfq/
> 
> Rest of the details can be found in the commit messages.
> 
> Patch 1-2: new kunit tests
> Patch 3-4: minor fixes
> Patch 5: refactoring zeroout and making sure zeroout handles all
>         permutations correctly
> Patch 6: Refactoring ext4_split_* functions.
> Patch 7: Enable zeroout for writ to unwrit case
> 
> Testing:
> - I've run kvm-xfstests for 4k, 1k and bigalloc_4k with -g quick and I
>   see no failures.
> - Some new kunit tests that were failing due to inconsistencies are not
>   passing

Are *now* passing with the patches* :)

> - Due to dev servers being down for eoy maintanence I couldn't run more
>   rigourous tests. In the coming week I'll run stress and auto group as
>   well.
> 
> Thoughts and comments are welcome.
> 
> Ojaswin Mujoo (7):
>   ext4: kunit tests for extent splitting and conversion
>   ext4: kunit tests for higher level extent manipulation functions
>   ext4: propagate flags to convert_initialized_extent()
>   ext4: propagate flags to ext4_convert_unwritten_extents_endio()
>   ext4: Refactor zeroout path and handle all cases
>   ext4: Refactor split and convert extents
>   ext4: Allow zeroout when doing written to unwritten split
> 
>  fs/ext4/extents-test.c   | 871 +++++++++++++++++++++++++++++++++++++++
>  fs/ext4/extents.c        | 591 +++++++++++++++-----------
>  fs/ext4/extents_status.c |   3 +
>  fs/ext4/inode.c          |   4 +
>  4 files changed, 1226 insertions(+), 243 deletions(-)
>  create mode 100644 fs/ext4/extents-test.c
> 
> -- 
> 2.51.0
>