EXT4 Extsize Hints Being Worked On As Step Toward Non-Torn/Atomic Writes

Written by Michael Larabel in Linux Storage on 12 September 2024 at 09:00 AM EDT. 2 Comments
LINUX STORAGE
Ojaswin Mujoo with IBM has posted an initial set of "request for comments" patches implementing extsize hints for EXT4, similar to the hints being worked on for the XFS file-system. This is important work in ultimately striving toward handling non-torn / atomic writes within the EXT4 file-system.

Mujoo explains of the extsize hints work for EXT4:
"extsize on ext4 is a hint to mballoc (multi-block allocator) and extent handling layer to do aligned allocations. We use allocation criteria 0 (CR_POWER2_ALIGNED) for doing aligned power-of-2 allocations. With extsize hint we try to align the logical start (m_lblk) and length(m_len) of the allocation to be extsize aligned. CR_POWER2_ALIGNED criteria in mballoc automatically make sure that we get the aligned physical start (m_pblk) as well. So in this way extsize can make sure that lblk, len and pblk all are aligned for the allocated extent w.r.t extsize.

Note that extsize feature is just a hinting mechanism to ext4 multi-block allocator. That means that if we are unable to get an aligned allocation for some reason, than we drop this flag and continue with unaligned allocation to serve the request. However when we will add atomic/untorn writes support, then we will enforce the aligned allocation and can return -ENOSPC if aligned allocation was not successful."

The patch that adds the actual extsize hints support for the EXT4 file-system goes on to elegantly sum it up as:
"** MOTIVATION **

1. This feature allows us to ask the allocator for blocks that are logically AS WELL AS physically aligned to an extent size hint (aka extsize), that is generally a power of 2.

2. This means both start and the length of the physical and logical range should be aligned to the extsize.

3. This sets up the infra we'll eventually need for supporting non-torn/atomic writes that need to follow a certain alignment as required by hardware.

4. This can also be extent to other use cases like stripe alignment"

As it's just in an RFC phase of development right now, it still may be some time before the design is solidified and the patches are ready for upstreaming into the Linux kernel. In any event for those wanting to learn more about the EXT4 extsize hints proposal can find the patches on the Linux kernel mailing list.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week