[PATCH 0/4] fs/erofs: major alignment fixes

Michael Walle mwalle at kernel.org
Tue Mar 24 00:42:16 AEDT 2026


Throughout the whole fs code, large (4k) data buffers are allocated
on the stack. While it is not nice, to allocate that large buffers on
the stack, there is a much more fundamental problem: it's not
aligned.

This will result in a huge amount of cache misaligned messages on
arm32 SoCs, e.g.:

 CACHE: Misaligned operation at range [x, y]

While this is more or less a warning, as it will only invalidate
surrounding data, DMA is more of a problem. Some DMA controllers
have address restrictions and because of that there is
ARCH_DMA_MINALIGN. Thus as a first fix, move all the data buffers
from the stack to the heap with proper alignment.

There are still some misalignment warnings. I've traced it to
fs_devread(). Most of the calls to blk_dread() will pass an aligned
buffer. But the main blk_dread() will just pass buf, which might
have previously been advanced by readlen. Not sure how that could be
fixed in an elegant way. The simplest would probably be just a
bounce buffer, which there is already one in blk_read() if
BOUNCE_BUFFERS is enabled. But I haven't managed to get that
working. And now, I'm running out of time.

Michael Walle (4):
  fs/erofs: align the malloc'ed data
  fs/erofs: allocate data buffers on heap with alignment (1/3)
  fs/erofs: allocate data buffers on heap with alignment (2/3)
  fs/erofs: allocate data buffers on heap with alignment (3/3)

 fs/erofs/data.c     | 125 +++++++++++++++++++++++++++++---------------
 fs/erofs/fs.c       |  14 ++++-
 fs/erofs/internal.h |   5 +-
 fs/erofs/namei.c    |  47 ++++++++++++-----
 fs/erofs/super.c    |  40 ++++++++++----
 fs/erofs/zmap.c     |  61 +++++++++++++++------
 6 files changed, 205 insertions(+), 87 deletions(-)

-- 
2.47.3



More information about the Linux-erofs mailing list