Skip to content

osd: Sparse reads and logical allocation preservation for EC pools - #71288

Open
MattyWilliams22 wants to merge 54 commits into
ceph:mainfrom
MattyWilliams22:wip-ec-sparse-reads
Open

MattyWilliams22 wants to merge 54 commits into
ceph:mainfrom
MattyWilliams22:wip-ec-sparse-reads

Conversation

@MattyWilliams22

@MattyWilliams22 MattyWilliams22 commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Summary

This PR adds sparse read support and logical allocation preservation to Erasure Coded pools. It is motivated primarily by encrypted workloads (RBD with LUKS2/LUKS3, CephFS with fscrypt) where allocation state must survive recovery/reconstruction.

Problem

EC pools have three related deficiencies today:

  1. SPARSE_READ treats all regions as allocated — data is transferred for the entire requested range regardless of physical allocation state.
  2. MAPEXT returns -EOPNOTSUPP — there is no way to query logical extent state on an EC pool at all.
  3. Recovery loses allocation intent — when a shard is reconstructed from parity, the EC maths cannot distinguish an explicitly-written zero block from a hole. The current code zero-detects reconstructed data and silently deallocates regions that the client deliberately wrote as zeros.

For encrypted workloads the third point is critical: LUKS ciphertext can encrypt to all-zero bytes, so after a single recovery cycle an encrypted image may have holes where data should be, corrupting the volume.

Solution

force_allocated_extents metadata

A new force_allocated_extents field is added to object_info_t. It records every 4 KiB-aligned block that contained all-zero bytes at write time and therefore must remain physically allocated. The representation is chosen adaptively between a sparse interval_set<uint32_t> and a dense bitmap, whichever encodes smaller, so the OI footprint stays bounded (≤ object_size / 4 KiB / 8 bytes). Additionally, decoding is deferred until the data structure needs to be accessed, eliminating the need to decode upon every read of OI.

Zero detection in PrimaryLogPG

Zero detection is performed once, in PrimaryLogPG, before the write is dispatched to the backend. It runs on data already in CPU cache from EC encoding and uses a two-stage algorithm:

  • Stage 1 (quick): test the first 8 bytes of each 4 KiB block; skip immediately if non-zero.
  • Stage 2 (full): call the optimised mem_is_zero() only when stage 1 passes. For encrypted workloads the probability of reaching stage 2 is ~2⁻⁶⁴ per block.

Zero tracking is opt-in via either:

  • a new preserve_allocation pool property (coarse-grained; applies to all writes on the pool), or
  • a new CEPH_OSD_FLAG_PRESERVE_ALLOCATION flag on individual MOSDOp messages (fine-grained; lets clients such as RBD opt in per-I/O without affecting unencrypted images on the same pool).

Recovery rules

During EC recovery and backfill the reconstructed data is now cross-
referenced against force_allocated_extents:

  • Blocks listed in force_allocated_extents are written as-is (or as an explicit zero block if no data was recovered) — zero-detect is suppressed.
  • All other blocks follow the existing zero-detect / deallocation logic.

Parity shards continue to be zero-detected after encoding or reconstruction a parity extent that encodes to all zeros is deallocated as before.

SPARSE_READ and MAPEXT for Fast EC

Both operations are now implemented for Fast EC pools:

  • Good path: allocation state is queried directly from BlueStore on each shard and merged across shards; force_allocated_extents is not consulted.
  • Recovery/reconstruction path: Missing shards are reconstructed as normal using the BlueStore results from healthy shards. The reconstructed shards are passed through zero detection, with zero blocks being deallocated, unless the block is contained within force_allocated_extents.

MAPEXT is no longer EOPNOTSUPP on EC pools.

Testing

  • Unit and integration tests added in sparse_reads_cxx.cc covering the good path, recovery path, ZERO / TRUNCATE / WRITEFULL interactions, and misaligned ranges.
  • ceph_test_rados_io_sequence and ceph_test_rados extended with ZERO and MAPEXT operations and correct allocation-state modelling so that random op sequences exercise the full matrix of edge cases automatically.
  • RBD encryption QA tests enabled against EC data pools.

Out of scope

  • Thick provisioning on EC pools — ZERO ops deallocate storage; the guarantee required by --thick-provision cannot be met.
  • Sub-4 KiB block sizes — LUKS1 / 512-byte blocks are not supported in this series.
  • ISA-L isal_zero_detect() integration — a potential follow-on optimisation tracked separately.

Signed-off-by: Matty Williams [email protected]
Assisted-by: IBM-Bob-2.0.3:Claude/GPT

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.

@MattyWilliams22
MattyWilliams22 requested review from a team as code owners August 24, 2026 14:32
@MattyWilliams22 MattyWilliams22 changed the title test: Add "DoesErrorInject" to the "NoOmapRecoveryZeroSized" test in omap_cxx.cc osd: Preserve Allocation and Enable Sparse Reads in EC Pools Aug 24, 2026
@MattyWilliams22
MattyWilliams22 marked this pull request as draft August 24, 2026 14:44
@MattyWilliams22 MattyWilliams22 changed the title osd: Preserve Allocation and Enable Sparse Reads in EC Pools osd: Sparse reads and logical allocation preservation for EC pools Aug 24, 2026
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@MattyWilliams22
MattyWilliams22 force-pushed the wip-ec-sparse-reads branch 2 times, most recently from b1d86e3 to 3223aa7 Compare September 1, 2026 16:25
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Previously, an unsupported op type would cause the test the crash.
Now, an unsupported op type will print a "Warning:" message and the test will continue without that op type. If there are no supported ops left, the test will fail.

I have added a RadosPoolSupport.h test file which is used to perform the checks which determine the ops that can and can't be supported. The goal was to make this code extensible so that new op types with complex pool requirements can be added to ceph_test_rados more easily.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: IBM-Bob-2.2.3:Claude/GPT
ceph_test_rados now skips any op-types that the pool can't support, so these ops can be safely added to these yamls.
zero and write_zeros are write operations so it only makes sense to add them to the overwrite yamls.
If ec_optimizations is off, mapext will be skipped.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: IBM-Bob-2.2.3:Claude/GPT
…ing shard

When reconstructing a data shard for a sparse read, the want set was rounded up to whole chunks, but the zero-padding and parity reads were clipped to the 4K-aligned object size. For an object smaller than a chunk, the decoder was left with a slice that had no inputs, so jerasure returned -1 and a copy_from failed with that error. Clamp the want set to the object's shard size so that it matches the other inputs.

Add unit tests which reproduce the failure and sweep object sizes and missing shards.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: IBM-Bob-2.3.0:Claude/GPT
Fix three ceph_test_rados model failures seen in teuthology jobs 767473, 767494 and 767536. The OSD behaved correctly in each case.

Zero reaching the end of the object (767473):
PrimaryLogPG::do_osd_op munges a ZERO whose offset+length >= oi.size into a TRUNCATE to the zero offset, so the object shrinks. ZeroGenerator still reported the old object size, so the model expected more bytes than the OSD returned and the read check reported corruption. ZeroGenerator now reports the zero offset as the object length in this case, and ObjectDesc::get_written_extents() treats such a layer as a truncation instead of a hole punch. ZeroOp logs when a zero reaches the end of the object.

Truncate down to an unaligned size (767494, 767536):
Every WriteOp ends with a truncate to the generator length. If an older layer wrote into the alignment block containing the new size T, that block stays allocated up to T after the truncate. get_written_extents() clamped older layers to [0, T) before rounding, so max_expected stopped at the last written block boundary and the sparse read/mapext check rejected the OSD's valid [align_down(T), T) tail. The model now adds that
fragment to the maximum written set when an older layer had data in
[T, align_up(T)). get_min_written_extents() is unchanged and still drops the fragment because it reads as all zeros.

EC head edge of an older zero:
The head edge block of an older zero was skipped entirely when a newer truncate cut through it. It is now clamped to the truncation point, as the tail edge already was.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: IBM-Bob-2.3.0:Claude/GPT
sparse_reads, like stretch_zones, records an upgrade commit and is set
automatically by the monitor, not by the operator. Drop it from the
flags the dashboard lists as settable, as is already done for
stretch_zones, and cover it with a test.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
@github-actions

Copy link
Copy Markdown

Config Diff Tool Output

+ added: mon_debug_no_sparse_reads (global.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@MattyWilliams22

MattyWilliams22 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

I've modified the upgrade code:

  • I've added a SPARSE_READS feature bit.
  • When all OSDs and quorum have this bit, sparse_reads is set in the OSDMap and all supported pools (replicated and Fast EC excl. Crimson) get the sparse_reads pool flag in the same epoch. Once set, it cannot be unset.
  • The preserve_allocation pool flag is distinct, but can only be enabled if the OSDMap has the sparse_reads flag.
  • Also added a health warning if some OSDs are preventing sparse reads support (e.g. dead OSDs).

Sparse reads on EC pools are now gated on the sparse_reads OSDMap flag and
the SPARSE_READS OSD feature bit, set automatically once every OSD
supports the feature, rather than on require_osd_release. Update the
pools.rst supports_sparse_reads description and the erasure-coding design
doc's upgrade/release-compatibility section, including the
OSD_SPARSE_READS_NOT_ENABLED health warning and the ceph osd purge escape
hatch for a stuck dead OSD.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8

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

Claude review does bring up a few points. Apologies for sitting this for a while, I wanted to go over and understand it myself.

Its possible some of what it poitns out is not true - and maybe it uses the wrong criteria, but please review its change.

I think it has spotted some genuine bugs. If you want, I can get it to create test scenarios and reproducers to demonstrate them.

Comment thread src/osd/PrimaryLogPG.cc Resolved
Comment thread src/osd/PrimaryLogPG.cc Outdated
}
auto *mapext_ctx = new ECMapextResult(
this, ctx, &osd_op.rval, &osd_op.outdata);
int r = pgbackend->objects_mapext_async(

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 genuine to me:

Claude description of scenario:
A MAPEXT that starts at or past the end of the object crashes the primary OSD on a fast-EC pool. SPARSE_READ is protected: do_sparse_read() clamps the range to the object size first and replies with an empty result itself. MAPEXT only special-cases oi.size == 0, so it passes the unclamped range to the backend.

Example: k=2, m=1, 4K chunks (8K stripe), an 8K object (shard 0 holds bytes 0-4K and shard 1 holds bytes 4K-8K, each at shard offset 0-4K), and a client sends mapext(12K, 4K):

  1. Bytes 12K-16K map to shard 1 at shard offset 4K-8K, so the request wants shard 1 at 4K-8K.
  2. get_min_avail_to_read_shards() intersects that with the read mask for an 8K object (0-4K on each shard), which leaves nothing to read. The zero mask only covers padding inside the last stripe, and this object ends on a stripe boundary, so shard 1 is not in zeros_for_decode either.
  3. prepare_sparse_read_request() sees a wanted data shard that is neither read nor zero. That is how it recognises a missing shard, so it sets needs_reconstruct. Nothing is missing; the range is just past the end of the object.
  4. The reconstruct branch rebuilds shard_want_to_read but skips every range at or past shard_limit (4K), so the second get_min_avail_to_read_shards() call produces no shard reads. The function still returns success.
  5. objects_mapext_async() calls start_read_op(), do_read_op() finds no shard reads, ceph_assert(reads_sent) (ECCommon.cc:687) fails, and the primary OSD crashes.

Any librados client can send this with ObjectReadOperation::mapext(size + 4096, 4096). When the PG gets a new primary the client resends the op, so I'd expect the new primary to crash the same way. On a replicated pool the same call returns an empty map. A MAPEXT with length 0 wants nothing from any shard, so I think it reaches the same assert, but I haven't traced that case all the way.

A range that starts inside the object and runs past its end, such as mapext(4K, 8K) on the same object, takes the same wrong turn at step 3. It doesn't crash, but the reconstruct path turns drop_data off, so a MAPEXT that should move no data reads it from every data shard.

Could MAPEXT clamp the range the way do_sparse_read() does: an empty map when offset >= size, and a shorter length when the range runs past the end? That covers oi.size == 0 as well, so the special case could go. It would also help if objects_mapext_async() and objects_sparse_read_async() asserted a non-empty range, so that a future caller fails at the entry point rather than deep in the read pipeline. A librados test on a fast-EC pool of mapext() at the object size, past it, and with length 0 would cover this.

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 have clamped the range the same way sparse read does.
See commit: "osd: Clamp mapext ops to the object size"

Comment thread src/osd/PrimaryLogPG.cc Outdated
if (whiteout) {
dout(20) << __func__ << " setting whiteout on " << soid << dendl;
oi.set_flag(object_info_t::FLAG_WHITEOUT);
oi.force_allocated_extents.clear();

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.

Claude found - but I think it needs explanation:

The whiteout branch clears the FAE, but the normal delete path only does oi.size = 0; oi.new_object();, and new_object() does not touch the FAE. The obc stays cached with exists == false and the old FAE, so the next write that re-creates the object (or a DELETE+WRITE in one op) persists the old blocks. Those blocks are now holes on disk, but a degraded sparse read or a recovery treats them as allocated. Could the clear move up next to oi.new_object() (or into new_object()), so both branches get it? A test: write zeros with the flag, remove, write elsewhere, then check get_force_allocated_extents() is empty.

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.

See "osd: Ensure FAE is cleared when an object is recreated"

Comment thread src/osd/PrimaryLogPG.cc
while (it != pg->in_progress_async_reads.end() && it->second != this)
++it;
ceph_assert(it != pg->in_progress_async_reads.end());
pg->in_progress_async_reads.erase(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.

(claude response) Normal EC client reads go through objects_read_and_reconstruct(), which queues them in in_progress_client_reads so kick_reads() completes them in order. The new sparse, mapext and copy-get reads call start_read_op() directly, and this hunk drops the assert that the completing ctx is at the front. Do we not promise in-order completion for reads on the same object any more, or should these reads join the same queue? A side effect of bypassing it: on an interval change, ReadPipeline::on_change() destroys the SparseReadCompleter/ECMapextCompleter without calling on_complete, so the ECSparseReadResult, ECMapextResult or C_CopyFrom_AsyncReadCb it points to is leaked. The queued path frees its callback through in_progress_client_reads.clear().

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 have changed the way completers are referenced here to avoid memory leaks.
See "osd: Avoid leaking completers for sparse reads and mapext".

I have not modified the completion order of reads. Do you think I need to refactor sparse reads to provide in-order completion?

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.

Some analysis shows that non-sparse reads in EC are ordered, until there is a new interval, when the outstanding reads are resubmitted out of order (indeed, in exactly reverse order).

From what I can tell, nothing relies on this behaviour and if it does, then it shouldn't. The RWORDERED flag appears to be honoured outside EC - so its not needed for that either.

So far from adopting this ordering, we should look at (in a new PR) removing the ordering of EC non-sparse reads!

Comment thread src/osd/osd_types.h
//
// All byte offsets/lengths accepted by the mutating methods are rounded
// outward to FAE_BLOCK_SIZE boundaries internally.
struct force_allocated_extents_t {

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.

Claude is saying that the lazy-decode is never actually used practically... and may just add complexity. I can't disagree with it and think maybe it at least merits a further review by you.

Claude's original comment:
Every consumer (sparse read, mapext, copy-get, recovery, operator==) calls get_intervals(), and every sparse read does it, so the lazy decode does not save anything on the read path. decode() also walks and decodes every word just to skip them. Two smaller things: insert_exact() is identical to add() (round_down_to(offset, 4K) / 4K == offset / 4K), and the PR description says 'interval_set or bitmap, whichever encodes smaller', which is not what the code does. Would a plain interval_set<uint64_t> in memory, with encode() choosing between an interval list and one bitmap over the object (whichever is smaller), do the job? That would drop the merge/split heuristics, FAE_MAP_NODE_BYTES, the mutable state that const methods change, and most of the ForceAllocatedExtents tests.

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 have removed the deferred decode and removed the add() method as it duplicates insert_exact.

See: "osd: Remove deferred decode for FAE"

Comment thread src/osd/ECBackend.cc Outdated
int result = 0;
};

struct ECMapextCompleter final : ECCommon::ReadCompleter {

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.

Claude simplicity nit:

(claude response) objects_sparse_read_async/objects_mapext_async, SparseReadCompleter/ECMapextCompleter and ECSparseReadResult/ECMapextResult differ only in whether data is returned (and for_mapext sets drop_data), and PGBackend and ECSwitch declare both too. One entry point with a nullable out_bl (mapext = nullptr, as ec_sparse_finish_read() already takes) would halve this code. The same goes for the three copies of the error/clog block in handle_sub_read() (fiemap, readv, read), which could be one lambda.

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've combined these data paths together with a nullable out_bl as suggested.
See: "osd: Combine objects_sparse_reads_async and objects_mapext_async"

Comment thread src/osd/ECUtil.cc Outdated
const auto &first_ptr = block_bl.front();
if (first_ptr.length() >= sizeof(uint64_t) &&
!mem_is_zero(first_ptr.c_str(), sizeof(uint64_t))) {
// Stage 1: first word non-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.

A claude found nit:

The 'stage 1 first word, stage 2 full scan' check is written out three times (detect_zero_blocks() in PrimaryLogPG, ec_sparse_scan_shard_extents() and ec_recovery_compute_shard_push()). mem_is_zero() already returns on the first non-zero 16 bytes (x86) or 32 bytes (NEON), so stage 1 saves nothing; block_bl.is_zero() is the whole test. The two ECUtil loops are also the same walk (per-block stride, FAE check, zero check) with different outputs, so they could share a 'for each kept block' helper.

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've changed zero detection to git rid of stage 1 as stage 2 duplicates this check, and will return early.
See: "osd: Remove redundant first stage from zero detection"

Comment thread src/osd/PrimaryLogPG.cc Outdated
if (result < 0)
return result;
// Replicated pool: get extent map via synchronous fiemap.
osd->store->fiemap(ch,

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.

(claude response) Two things in copy-from:

  1. For a replicated source, do_copy_get() now runs fiemap() and sends extent_map, but it does not set FLAG_SPARSE_READ, so the destination ignores the map. Either set the flag (and send only the allocated data) or drop the fiemap.
  2. In _write_copy_chunk() the sparse path skips the required_alignment() trim. If the destination is an EC pool without overwrites (rados cp from a fast-EC pool to an append-only EC pool), a chunk that ends off a stripe boundary, such as an 8 MiB chunk with a 12K stripe, is padded, and the next chunk's write then starts at an unaligned offset below the padded size, which ECTransactionL asserts on. Should the sparse path keep the trim, or fall back to dense copy for append-only destinations?

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 have stopped replicated sources from gathering or sending the extent map.
I have also converted sparse data to dense data if the destination is an append-only EC pool.
See: "osd: Avoid sending extent map during copies from replicated source"

Comment thread src/osd/PrimaryLogPG.cc
}
if (pool_info.is_erasure() && ctx->op && ctx->op->get_req()) {
const auto *m = ctx->op->get_req<MOSDOp>();
if (m && m->has_flag(CEPH_OSD_FLAG_PRESERVE_ALLOCATION)) {

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 don't think I particular care about what happens if you set this flag before the upgrade is finished, on an already unsupported fscrypt volume, so the following is largely irrelevant, since it does not describe a crash.

BUt here is the comment anyway...

With the release checks gone, this per-op flag is the one way the FAE gets modified that the mon does not gate. Any client can send CEPH_OSD_FLAG_PRESERVE_ALLOCATION (librados OPERATION_PRESERVE_ALLOCATION) before require_osd_release reaches vampire, and a new primary then records FAE. If an older OSD becomes primary for that PG during the upgrade, its next write to the object re-encodes the OI as v18 and drops the FAE. After the upgrade those zero blocks then read back as holes and are not kept through recovery, although the client asked for them. So 'FLAG_PRESERVE_ALLOCATION remains the only control over whether FAE is modified' (b68bbcb) is not quite true. Could the per-op flag count only once the pool has FLAG_SUPPORTS_SPARSE_READS (the mon sets it at the same commit, and only on fast-EC pools), or keep the release check for this path?

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.

The per-op flag now requires the FLAG_SUPPORTS_SPARSE_READS pool flag.
See: "osd: Require sparse reads pool flag for per-op preserve_allocation flag"

@github-project-automation github-project-automation Bot moved this from New to Review in progress in Ceph-Dashboard Nov 30, 2026
Mapext ops to an offset greater than the size of the object were causing an OSD to assert.

Now, mapext ops are limited to the object's size, and return early if there is nothing to read. This matches the sparse reads implementation.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
The whiteout path was clearing FAE, but the normal write path wasn't. So when an object was recreated, FAE would be populated when it shouldn't be.

I have removed the code that clears FAE for whiteouts, and instead, FAE is cleared when an object is recreated.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
The Fast-EC sparse-read, mapext and copy-get read paths dispatch reads by building a `ReadCompleter` and calling `ReadPipeline::start_read_op()` directly, instead of going through `objects_read_and_reconstruct()`. Those completers hold
the client callback (`ECSparseReadResult`, `ECMapextResult` or `C_CopyFrom_AsyncReadCb`) as a raw `Context *` with no destructor.

On an interval change, `ReadPipeline::on_change()` tears down every in-flight read op with `tid_to_read_map.clear()` without calling `complete_read_op()`/`finish()`. Destroying a completer therefore does not free the raw `Context *` it carries, so that callback is leaked.

The fix was to make the read completers own their callback, mirroring the classic `cb` struct's `std::unique_ptr<Context> on_complete`.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
The deferred decode wasn't improving performance because FAE was always being read byte-by-byte and then skipped. The deffered decode was just adding a second read in the case of sparse read ops.

Now, decoding isn't deferred.

The mechanism that allows encoding to be skipped if no changes were made to FAE has been kept.
The force_allocated_extents_t::add() method was identical to insert_exact(), so the add method was removed.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
These code paths have very similar code. The only difference is that mapext doesn't request or return data.

I have combined the functions and completers together, using a nullable out_bl to determine whether the read should keep or drop the data.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
detect_zero_blocks() was performing an initial sniff test of the first word, before performing a full scan of the buffer to determine if it was all-zeros.

This first stage is unnecessary as the buffer::list::is_zero() method returns immediately when it encounters a non-zero word, duplicating the behaviour of the first stage.

I have removed the first stage, which means the whole check can be replaced with a single call to is_zero().

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
And add a dense fallback for copies to an append-only EC destination.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
Previously, the per-op preserve_allocation flag would override the pool flags, and modify FAE even when the pool doesn't support sparse reads yet.

Now, the per-op flag is gated behing the sparse reads pool flag, which is the correct check to determine when it is safe to modify FAE.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
`in_progress_async_reads` entry per ctx

An op that contains a `READ`
followed by a `SPARSE_READ` (or `MAPEXT`) on a fast-EC pool (and the
op is not an `ec_direct_read`) ends up with two async reads in flight but
`inflightreads == 1` and two `in_progress_async_reads` entries pointing at the same `OpContext`.

Introduced the PrimaryLogPG::register_async_read() helper which every async-read dispatch site now uses. `inflightreads` reliably reflects "number of outstanding completions" and the first dispatch is the one that registers the
entry.

Fixes: https://tracker.ceph.com/issues/79804
Signed-off-by: Matty Williams <[email protected]>
Assisted-by: Claude Opus 4.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review in progress

Development

Successfully merging this pull request may close these issues.

4 participants