Skip to content

xfs: avoid IO issues unaligned memory allocation

Dave Chinner linux-block linux-mm linux-xfs lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 40 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3xfs: add kmem allocation trace pointsfs/xfs/kmem.c fs/xfs/libxfs/xfs_types.h fs/xfs/xfs_mount.h +1 more+50 -92 replies
2/3xfs: add kmem_alloc_io()fs/xfs/kmem.c fs/xfs/kmem.h fs/xfs/xfs_buf.c +3 more+50 -2120 replies
3/3xfs: alignment check bio buffersfs/xfs/xfs_bio_io.c fs/xfs/xfs_buf.c fs/xfs/xfs_linux.h +1 more+38 -518 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchBrian FosterChristoph Hellwig
1/3R-b R-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] xfs: avoid IO issues unaligned memory allocation

Hi folks,

These patches fix the issue reported by Vishal on 5.3-rc1 with pmem, reproduced on brd, and previously seen with xenblk.

The core issue is that when memory allocation debugging is turned on, heap memory is no longer naturally aligned and that means we attach memory with large memory regions with random alignment to bios. Some block drivers only support 512 byte aligned memory buffers, and these then silently break when fed an unaligned buffers.

This happens silently because nothing in the block or driver layers actually validates that memory buffers containing kernel memory are correctly aligned. Buffers may be bounced in the drivers if they are unaligned, but not all driver support this, hence the breakage.

This patchset added memory allocation tracing, 512 byte aligned allocation support via kmem_alloc_io(), and a re-implementation of bio_add_page() to add memory buffer alignment verification. The last patch causes unaligned allocations to fail fast, noisily and safely, such that any developer running KASAN will immediately notice if XFS attaches an unaligned mmemory buffer to a bio....

Cheers,

Dave.