Skip to content

os/bluestore/BlueFS: fix envelope header alignment for non-4K page hosts - #71004

Merged
ming1 merged 2 commits into
ceph:mainfrom
ming1:wip-79141-bluefs-envelope-page-size
Sep 16, 2026
Merged

ming1 merged 2 commits into
ceph:mainfrom
ming1:wip-79141-bluefs-envelope-page-size

Conversation

@ming1

@ming1 ming1 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

On hosts whose VM page size exceeds the BlueFS block size (16K Apple Silicon, 64K aarch64 kernels), every OSD with WAL v2 envelope mode enabled (the default) aborts at startup:

FAILED ceph_assert(p2aligned(pos1 ^ pos2, ceph::_page_size))

The assert (introduced in 4c03bbe, first released in v20.2.3) requires the envelope header's buffer address to mirror its file position modulo the runtime VM page size, but the write path only maintains that congruence modulo min(page size, block size): envelope flushes pad the on-disk stream to super.block_size, while fresh appender chunks are page-aligned allocations. Direct I/O itself only needs block-size memory alignment, so check the congruence the code actually maintains.

A second latent issue is fixed alongside: the FileWriter appender sizing integer-truncated to 0 pages when bluefs_alloc_size <= page size, making append_hole() fall back to an unaligned buffer.

The added tests override ceph::_page_size to reproduce the abort deterministically on any architecture; both fail before the fix and pass after. Full ceph_test_bluefs passes (48/48) on two x86 hosts, plus a live-OSD smoke on real NVMe: restart on existing data (exercising WAL replay + append at an inherited offset, the field crash path) and a 4K-write bench, ~10k envelope WAL flushes, no asserts.

The regression shipped in v20.2.3, so this needs a tentacle backport; squid is unaffected (no envelope mode there).

Fixes: https://tracker.ceph.com/issues/79141

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

ming1 added 2 commits August 12, 2026 06:45
The envelope-header assert in append_try_flush() requires the memory
address of a new header to mirror its file position modulo
CEPH_PAGE_SIZE. CEPH_PAGE_SIZE is the host VM page size resolved at
runtime, but the write path only keeps the two positions congruent at
the smaller of the page size and the BlueFS block size: envelope
flushes pad the on-disk stream to super.block_size, while fresh
appender chunks are page-aligned allocations.

On hosts whose page size exceeds the BlueFS block size (16K Apple
Silicon, 64K aarch64 kernels) a block-aligned WAL position is usually
not page-aligned, so the assert fires on ordinary RocksDB WAL writes
and every OSD aborts at startup. Direct I/O only requires block-size
memory alignment (see KernelDevice's
rebuild_aligned_size_and_memory), so assert the congruence the code
actually maintains: modulo min(CEPH_PAGE_SIZE, super.block_size).

Also round up instead of truncating in the FileWriter appender sizing:
with bluefs_alloc_size at or below the page size (e.g. 4K alloc on a
16K-page host) min_pages integer-truncated to 0, making refill()
allocate nothing so append_hole() fell back to an unaligned buffer -
the assert would then fire even at block-size granularity.

Introduced by 4c03bbe ("os/bluestore/bluefs: Add assert if write
buffer is not page aligned"); first released in v20.2.3.

Fixes: https://tracker.ceph.com/issues/79141
Signed-off-by: Ming Lei <[email protected]>
Override ceph::_page_size (plus mask/shift) to simulate a host whose
VM page size exceeds the BlueFS block size, then run the envelope-mode
small-writes workload; a second case repeats it with bluefs_alloc_size
below the simulated page size to cover the appender min_pages
truncation. Before the previous commit both cases reproduced,
deterministically and on any architecture, the startup abort from
https://tracker.ceph.com/issues/79141:

  BlueFS.cc: FAILED ceph_assert(p2aligned(pos1 ^ pos2, ceph::_page_size))

Related-to: https://tracker.ceph.com/issues/79141
Signed-off-by: Ming Lei <[email protected]>
@ming1

ming1 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

2 similar comments
@ming1

ming1 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@xiubli

xiubli commented Aug 25, 2026

Copy link
Copy Markdown
Member

jenkins test make check

@xiubli

xiubli commented Aug 25, 2026

Copy link
Copy Markdown
Member

jenkins test make check arm64

@xiubli

xiubli commented Aug 25, 2026

Copy link
Copy Markdown
Member

jenkins test signed

@xiubli

xiubli commented Aug 25, 2026

Copy link
Copy Markdown
Member

jenkins test submodules

@ming1

ming1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ifed01

Can you review this fix when you get time?

Thanks,

@aclamk
aclamk self-requested a review September 1, 2026 13:18
@aclamk

aclamk commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

I feel like the problem be addressed by modifying BlueFS.super.block_size on mkfs.
Will it work?

@ming1

ming1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

I feel like the problem be addressed by modifying BlueFS.super.block_size on mkfs. Will it work?

Hi @aclamk

Thanks for your review!

I guess you meant to align BlueFS.super.block_size with max(dev_block_size, CEPH_PAGE_SIZE), this way can not work:

  1. it can't avoid the panic on existing osd which block size is 4k, and mkfs only works on new osd.

  2. it is not space-efficient, because arm64 may take 64 page size, 64k block size can cause 16× WAL
    write amplification

  3. new kernel in the osd machine may change page size from 16k to 64k

Please share more details if that is not what your meant.

Thanks,

@hasan4791

Copy link
Copy Markdown
Contributor

@ming1

ming1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

This fails on ppc64le as well. https://jenkins.ceph.com/job/ceph-make-check-periodic-ppc64le/4/consoleText

Yeah, that is same issue because ppc64le doesn't take 4k page size.

Your report shows that 3 bugs(207, 215, 24) of failures are same with https://tracker.ceph.com/issues/79141

 24 - smoke.sh (Timeout)
207 - unittest_bluefs (Subprocess aborted)
215 - safe-to-destroy.sh (Failed)

Thanks,

@ming1
ming1 requested a review from ifed01 September 10, 2026 03:02
@ming1

ming1 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello @ifed01 @aclamk anyone,

Can you help to review and approve the fix(arm64 blocker) if you are fine?

Thanks,

@ben-efros

Copy link
Copy Markdown

I have tested this on aarch64 with 16KB page size (on two Minisforum MS-R1 (CIX P1 CP8180) systems) with ceph 20.2.4. Works great so far.

@ifed01 ifed01 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but may be it's worth to extend the test to cover all the possible page_size/alloc_unit layouts. See the attached patch..

a.patch

@ming1

ming1 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Looks good to me, but may be it's worth to extend the test to cover all the possible page_size/alloc_unit layouts. See the attached patch..

a.patch

Thanks for the review!

I am fine for the above patch. However, it increases ceph_test_bluefs test time from 6.5sec to 143sec in my VM.(16% of total time). Maybe we can figure very few generic tests for covering all related code path.

@hasan4791

Copy link
Copy Markdown
Contributor

Tested this patch on pppc64le and it works.

@ming1
ming1 merged commit 44fded0 into ceph:main Sep 16, 2026
9 of 10 checks passed
@ifed01

ifed01 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@ming1 - please do not merge PRs labelled with 'need qa' before they've passed teuthology QA and relevant approval(s)

@ming1

ming1 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

@ming1 - please do not merge PRs labelled with 'need qa' before they've passed teuthology QA and relevant approval(s)

Hi @ifed01

Thanks for sharing the rule, I really don't know it, sorry for that.

Please feel free to let me know if anything need to do for dealing the merge.

Thanks,

aainscow pushed a commit to aainscow/ceph that referenced this pull request Sep 18, 2026
…ge-size

os/bluestore/BlueFS: fix envelope header alignment for non-4K page hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants