Skip to content

doc: Add EC sparse reads and logical allocation design documents - #69313

Merged
aainscow merged 2 commits into
ceph:mainfrom
aainscow:sparse_read_design
Sep 10, 2026
Merged

aainscow merged 2 commits into
ceph:mainfrom
aainscow:sparse_read_design

Conversation

@aainscow

@aainscow aainscow commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Add comprehensive design and implementation plan for supporting sparse reads and logical allocation preservation on Erasure Coded pools.

Key features:

  • Sparse read support that accurately reports allocation state
  • Force-allocated extent tracking to preserve explicitly written zeros
  • Support for both client-side and OSD-side zero detection
  • Optimized to only consult metadata during recovery/reconstruction
  • 4K block granularity aligned with EC, LUKS2, and fscrypt

The design addresses the core issue where EC pools cannot distinguish between explicitly written zeros and never-allocated regions during recovery/reconstruction, which prevents reliable use of encryption and other features requiring accurate logical allocation state.

Implementation plan includes 5 phases with 27 discrete stories and effort estimates of 67-89.5 days depending on implementation options.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Add comprehensive design and implementation plan for supporting sparse reads
and logical allocation preservation on Erasure Coded pools.

Key features:
- Sparse read support that accurately reports allocation state
- Force-allocated extent tracking to preserve explicitly written zeros
- Support for both client-side and OSD-side zero detection
- Optimized to only consult metadata during recovery/reconstruction
- 4K block granularity aligned with EC, LUKS2, and fscrypt

The design addresses the core issue where EC pools cannot distinguish
between explicitly written zeros and never-allocated regions during
recovery/reconstruction, which prevents reliable use of encryption and
other features requiring accurate logical allocation state.

Implementation plan includes 5 phases with 27 discrete stories and
effort estimates of 67-89.5 days depending on implementation options.

Signed-off-by: Alexander Ainscow <[email protected]>
@aainscow
aainscow force-pushed the sparse_read_design branch from 0ff2690 to 29dff26 Compare June 8, 2026 09:07

1. Enable zero-block tracking on the EC pool::

ceph osd pool set <ec-pool> set_pool_flags 4194304 --yes-i-really-mean-it

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.

This is a development tool and requires the --yes-i-really-mean-it confirmation flag.

How do you see the non-development interface looking like? Something along the lines of ceph osd pool set <ec-pool> track_zero_blocks true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am going to delete this whole section on configuration - its just repeating above and I don't think we need it yet. I will replace it with a section making clear that we need to update the docs.

**Current State**

CephFS fscrypt operates at the MDS level and does not have explicit EC pool
restrictions. The fscrypt implementation works with file metadata and should

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.

Nit: This makes sound like fscrypt only conceals file metadata and does nothing with file data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am going to delete this section, I don't think it adds any value.

Comment on lines +158 to +159
- If recovered block is all zeros, deallocate it
- Otherwise write it as-is

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.

Nit: I'd break this into "data has been recovered" and "no data has been recovered" branches, matching the structure of the force-allocated case for clarity.

Comment on lines +105 to +106
2. **Pool flag**: A pool flag (``FLAG_TRACK_ZERO_BLOCKS``) enables tracking for
all objects in the pool. Set via ``ceph osd pool set <pool> set_pool_flags

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.

I'm not sure if this sits with

Note: While object_info_t is generally suitable for this metadata, if extensive force-allocated extent tracking becomes necessary, alternative storage mechanisms should be evaluated.

well. If the user has a whole bunch of RBD images in the EC pool with only a few images encrypted and they set the flag because of them, the system would be entirely at the mercy of a pile of unencrypted workloads. In the extreme worst case, each OI would have 512 intervals (so taking up ~8K on disk), not to mention the continuous overhead from mem_is_zero().

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.

An alternative to a pool level flag would be to have a request (MOSDop or even per op in MOSDop) flag that indicates if zero block detection should be performed. This would require client side changes to set this flag for encrypted RBD images, but might avoid some of the concerns about performance / amount of extra metadata for unencrypted images.

We could of course implement both a pool level flag and an I/O level flag to provide options as to how this feature is deployed (the pool level flag has the advantage of not requiring clients to be upgraded)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are doing both options. I have updated the design so the pathological case works (2GiB object, with alternating blocks of data/force allocated extents).


**Note:** While object_info_t is generally suitable for this metadata, if
extensive force-allocated extent tracking becomes necessary, alternative
storage mechanisms should be evaluated.

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.

  1. What is the best way of tracing the force-allocated extents

If force-allocated extents are rare then an interval map is the best way to track them as most objects will have an interval map with 0 or 1 entry.

The pathological worse case scenario is where every other 4K block of an object is force allocated. For a 4M object that would require 512 entries in the interval set. Here a bitmap would be the most efficient way of tracking allocated extents.

Bluestore has a similar problem with its allocators and switches between a complex data structure which is more efficient when there is little fragmentation and a bitmap which is more memory efficient. A similar approach could be used here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are going to switch between an interval_set of uint32_t and a bitmap, once the interval_set hits 128 entries. 128 represents the point at which sizeof(interval_set) == sizeof(bitmap) for a 4MiB object. Otherwise it is arbitrary. I don't think we need it as a config option.

stores this information in object metadata (``force_allocated_extents``), and
uses it during recovery/reconstruction to preserve the distinction between
allocated-zeros and unallocated regions.

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.

Is force_allocated_extents only an EC feature, or should we use this for Replica pools as well?

Perhaps the other way of asking this is should we make the same optimization of detecting and not writing zeros when recovering data in a Replica pool as we do in a FastEC pool?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There may be reasons for doing a zero-detect in replica - but I don't think we should use force_allocated_extents. The design is to only read force_allocated_extents on recovery - and this only applies to EC, not Replica.

Lets leave the zero-detection general, so it can be used later in Replica

**Behavior when tracking is enabled:**

1. If writing non-zero data: no action needed on ``force_allocated_extents``
2. If writing zeros: add the written extent to ``force_allocated_extents``

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.

Currently a writesame of zeros creates a write transaction, if we are tracking this in force_allocated_extents we could use a zero transaction instead which can be more efficient in EC and the ObjectStore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A "ZERO" operation is intended to deallocated. A write-same is intended to allocate zeros. An earlier design point is to not parse force_allocated_extents on non-recovery reads, so we cannot apply this optimisation without changing that design point.

Comment on lines +105 to +106
2. **Pool flag**: A pool flag (``FLAG_TRACK_ZERO_BLOCKS``) enables tracking for
all objects in the pool. Set via ``ceph osd pool set <pool> set_pool_flags

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.

An alternative to a pool level flag would be to have a request (MOSDop or even per op in MOSDop) flag that indicates if zero block detection should be performed. This would require client side changes to set this flag for encrypted RBD images, but might avoid some of the concerns about performance / amount of extra metadata for unencrypted images.

We could of course implement both a pool level flag and an I/O level flag to provide options as to how this feature is deployed (the pool level flag has the advantage of not requiring clients to be upgraded)

@aainscow aainscow added the no-backport-required Label that can be optionally added to show that we do not need to backport. label Jun 30, 2026
@aainscow
aainscow force-pushed the sparse_read_design branch 2 times, most recently from 49c4b5f to 75d2598 Compare July 8, 2026 13:01
@aainscow
aainscow requested review from bill-scales and idryomov July 8, 2026 13:03
@aainscow
aainscow force-pushed the sparse_read_design branch 2 times, most recently from a1738bb to cec663f Compare July 9, 2026 10:00
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Sep 7, 2026
@aainscow
aainscow marked this pull request as ready for review September 7, 2026 12:49
@aainscow
aainscow requested a review from a team as a code owner September 7, 2026 12:49
@aainscow aainscow removed the stale label Sep 7, 2026
and reconstruction. This requires zero-detect to be enabled.

The core technical challenge is that EC pools maintain allocation information
at 4K resolution during normal operations, but this information is lost during

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.

Is it always 4k?

by either of two independent mechanisms:

- **Pool property** (``preserve_allocation``): enables zero detection for
every write to every object in the pool. Simple to deploy — no client

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.

This is straightforward to implement without client changes.

During implementation of sparse reads, more design decisions have been required.
These are now reflected in the design document.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Assisted-by: IBM-Bob-2.1.0:Claude/GPT

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

LGTM

@aainscow
aainscow merged commit ebaa34c into ceph:main Sep 10, 2026
19 of 22 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I found one or more Fixes: tags in the commit messages in

git log ebaa34c8572f579ed40a3d710041dd5ebc8460cf^..ebaa34c8572f579ed40a3d710041dd5ebc8460cf

The referenced tickets are:

Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them.

Update Log: https://github.com/ceph/ceph/actions/runs/34474954047

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation no-backport-required Label that can be optionally added to show that we do not need to backport.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants