Skip to content

os/bluestore: do not merge blobs with csum chunk unaligned extents - #71811

Closed
ming1 wants to merge 2 commits into
ceph:mainfrom
ming1:wip-72848-merge-blob-csum
Closed

ming1 wants to merge 2 commits into
ceph:mainfrom
ming1:wip-72848-merge-blob-csum

Conversation

@ming1

@ming1 ming1 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

merge_blob() moves the csum data of the blob it dissolves one pextent at a time, in whole csum chunks. So every pextent of that blob must start and end at a csum chunk boundary. can_merge_blob() did not check this.

The case is real. With the alloc hint SEQUENTIAL_READ plus IMMUTABLE or APPEND_ONLY, the csum chunk becomes larger than min_alloc_size, but the allocator still works in min_alloc_size units. On a fragmented device a blob can then be split inside a csum chunk, and the next clone aborts:

BlueStore.cc: FAILED ceph_assert((len % (1 << csum_chunk_order)) == 0)

Removing the assert is not safe: the use tracker would count the same AU once per fragment. This PR makes can_merge_blob() refuse such a blob instead. The merge is only an optimization; the caller then uses a normal shared blob.

The unit test covers both cases: aligned blobs still merge, and a fragmented blob is refused. Without the fix it reproduces the tracker abort. The abort was also reproduced end to end on a fragmented device, through queue_transactions() -> _clone() -> merge_blob(), and that run passes with the fix.

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

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
ming1 requested a review from a team as a code owner September 16, 2026 01:00
@ming1
ming1 force-pushed the wip-72848-merge-blob-csum branch from c42d929 to 65f9ccc Compare September 16, 2026 01:02
merge_blob() moves the csum data of the dissolved blob one pextent at a
time, in whole csum chunks. So each valid pextent of that blob must start
and end at a csum chunk boundary. can_merge_blob() did not check this.

This can happen. With the alloc hint SEQUENTIAL_READ plus IMMUTABLE or
APPEND_ONLY, _choose_write_options() picks a csum chunk larger than
min_alloc_size, but the allocator still works in min_alloc_size units and
_do_alloc_write() keeps its extents unchanged. On a fragmented device the
blob can be split inside a csum chunk. The next clone then aborts:

  BlueStore.cc: FAILED ceph_assert((len % (1 << csum_chunk_order)) == 0)

Removing the assert is not safe: the use tracker loop after it would add
the same au once per fragment. Instead, refuse the merge. The merge is
only an optimization; the caller then uses a normal shared blob. The check
runs in the existing extent loop of can_merge_blob(), two compares per
valid extent. Only the dissolved blob is checked, because the extents of
the surviving blob are not moved.

Keeping the merge for fragmented blobs would need merge_blob() to copy
csum data per chunk and add the tracker only once. That is left for a
follow-up.

Fixes: https://tracker.ceph.com/issues/72848
Signed-off-by: Ming Lei <[email protected]>
Two cases. A blob with csum chunk aligned pextents is still merged into
the shared blob next to it. A blob whose allocation is split inside a
csum chunk is not merged, instead of hitting the assert in merge_blob().

Related-to: https://tracker.ceph.com/issues/72848
Signed-off-by: Ming Lei <[email protected]>
@ming1
ming1 force-pushed the wip-72848-merge-blob-csum branch from 65f9ccc to 8daa8f9 Compare September 22, 2026 16:59
@ming1

ming1 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aclamk aclamk 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.

The PR is not well targeted.

It is true that Blob::can_merge_blob() is a pre-check before Blob:merge_blob().
But there is an important assumption underlying both those function:
Both blobs must have the same blob_start.
blob_start is not a member of Blob, but can be extracted from any BlueStore::Extent that points to a Blob by blob_start().

It is true that the neither can_merge_blob() nor merge_blob() mention this blob_start requirement as a precondition.

Also please note that if blob_starts are not the same, merging is completely broken.

@ming1

ming1 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

The PR is not well targeted.

It is true that Blob::can_merge_blob() is a pre-check before Blob:merge_blob(). But there is an important assumption underlying both those function: Both blobs must have the same blob_start. blob_start is not a member of Blob, but can be extracted from any BlueStore::Extent that points to a Blob by blob_start().

It is true that the neither can_merge_blob() nor merge_blob() mention this blob_start requirement as a precondition.

Also please note that if blob_starts are not the same, merging is completely broken.

No.

Please look at find_mergable_companion() in which ->can_merge_blob() is only called with same
blob_start(), and the test code does trigger the assert with same blob_start() .

It is just not documented, but nothing to do with this fix.

Thanks,

@ming1

ming1 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test api

@ming1

ming1 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@ming1

ming1 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@ming1
ming1 requested a review from ifed01 September 23, 2026 07:53
@ming1 ming1 added the bug-fix label Sep 23, 2026
@aclamk aclamk mentioned this pull request Sep 24, 2026
4 of 14 tasks
@aclamk

aclamk commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@ming1
You were right, the merge_blob() problem had no relation to different blob_start.
The initial assessment that fragmented allocations was correct and excessive assumptions in merge_blob() were the problem.

@ming1

ming1 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

#72066 can solve this issue in better way, so close it.

@ming1 ming1 closed this Oct 8, 2026
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.

2 participants